Newsgroups: fj.questions.unix
Path: galaxy.trc.rwcp.or.jp!jaist-news!cs.titech!wnoc-tyo-news!sh.wide!wnoc-kyo!kyu-cs!hakata!ie.u-ryukyu.ac.jp!yas
From: yas@ocean.ie.u-ryukyu.ac.jp (Yasushi Shinjo)
Subject: Re: Like du command..
In-Reply-To: makino@icphimiko.ic.epson.co.jp's message of 18 Aug 93 06:21:22 GMT
Message-ID: <YAS.93Aug19112131@ocean.ie.u-ryukyu.ac.jp>
Lines: 185
Sender: news@spn.ie.u-ryukyu.ac.jp (News System Admin)
Organization: Dept. of Elect. & Info. Eng., Univ. of the Ryukyus, Okinawa,
	Japan
References: <MAKINO.93Aug18152122@icpshikibu.icphimiko.ic.epson.co.jp>
Date: Thu, 19 Aug 1993 02:21:29 GMT
Xref: galaxy.trc.rwcp.or.jp fj.questions.unix:4026
X-originally-archived-at: http://galaxy.rwcp.or.jp/text/cgi-bin/newsarticle2?ng=fj.questions.unix&nb=4026&hd=a
X-reformat-date: Mon, 18 Oct 2004 15:18:22 +0900
X-reformat-comment: Tabs were expanded into 4 column tabstops by the Galaxy's archiver. See http://katsu.watanabe.name/ancientfj/galaxy-format.html for more info.

$B?7>k!wN05eBg3X$G$9!#$3$s$K$A$O!#(B

$B:G6a%M%C%H%o!<%/$ND4;R$,0-$+$C$?$;$$$+!"KRLn$5$s$N:G=i$N5-;v(B
<MAKINO.93Aug3180755@icpshikibu.icphimiko.ic.epson.co.jp>$B$,(B
$B$&$A$K$OFO$$$F$$$^$;$s$,!"(B

In article <MAKINO.93Aug18152122@icpshikibu.icphimiko.ic.epson.co.jp> 
makino@icphimiko.ic.epson.co.jp (Kenichi Makino) writes:
> $BKRLn!w%;%$%3!<%(%W%=%s$G$9!#(B

> $B;d$,CN$j$?$+$C$?$N$O!V%U%!%$%k$N%5%$%:!W$G$O$J$/!"!V$=$N%U%!(B
> $B%$%k$,@j$a$k%G%#%9%/$NMFNL!W$G$9!#(B

stat(2) $B$G!"(Bst_blocks $B$r8+$k$H!"$$$$$H;W$$$^$9!#(B

man stat(2) $B$h$j(B:
----------------------------------------------------------------------
    off_t     st_size;       /* total size of file, in bytes */
    ...
    long      st_blocks;     /* actual number of blocks allocated */
----------------------------------------------------------------------

$B$A$g$C$H;n$7$F$_$^$7$?!#(B
------------------------------------------------------------
94% limit coredumpsize unlimited
95% cat
^\Quit (core dumped)
96% ls -ls core
  80 -rw-r--r--  1 yas       8430000 Aug 19 10:42 core
97%
------------------------------------------------------------

$B$3$N$h$&$K!"(Bcore $B$r:n$C$F!"(Bls -ls $B$G8+$k$H!"%5%$%:$O(B 8M $B$b$"(B
$B$k$N$K!"<B:]$K;H$o$l$F$$$kNN0h$O!"(B80k $B%P%$%H$G$9!#!J$3$l$O!"(B
SunOS $B$G<B9T$7$?>l9g$G$9!#!K(B

$B$5$F!"(Bcore $B$r(B stat(2) $B$7$F$_$^$9!#(B
------------------------------------------------------------
97% stat core
path: core
dev: 130,0
ino: 21295
mode: 0100644
nlink: 1
uid: 3520
gid: 200
rdev: 181,184
size: 8430000
atime: Thu Aug 19 10:42:32 1993
mtime: Thu Aug 19 10:42:37 1993
ctime: Thu Aug 19 10:42:37 1993
blksize: 8192
blocks: 160
98%
------------------------------------------------------------
st_blocks $B$N(B 160 $B$H$$$&$N$,2x$7$$$H$$$&$3$H$,$o$+$j$^$9!#$?(B
$B$V$s!"(Bls -s $B$O!"$3$NCM$r#2$G3d$C$FI=<($7$F$$$k$N$G$7$g$&!#(B
$B!J(Bblocks $B$O!"(B512$B%P%$%HC10L!#!K(B

$B$3$N(B stat $B%3%^%s%I$N%=!<%9$rKvHx$KIU$1$^$9$+$i!"3hMQ$7$F2<$5$$!#(B

$B$*$C$H!"$3$$$D$rK:$l$F$O$$$1$^$;$s!#(B
------------------------------------------------------------
98% rm core
99%
------------------------------------------------------------

$B!@!@!!?7>k!!Lw!!!J$7$s$8$g$&!!$d$9$7!K!!!@!@(B
$B!@!@!!N05eBg3X!!EE;R!&>pJs!!!!!!!!!!!!!!!@!@(B

$B;29M!'(B% man stat
% man ls

------------------------------------------------------------
/*
 *stat.c -- stat(2) lstat(2) shell interface.
 *$Header: /home/h1/yas/c/util/stat/RCS/stat.c,v 1.3 1993/08/19 02:12:36 yas Exp $
 *
 *$BCx<T!'?7>k!!Lw!"(B $BN05eBg3X!!EE;R!&>pJs(B
 *Author: Yasushi Shinjo, University of the Ryukyus
 *E-Mail: yas@ie.u-ryukyu.ac.jp
 *
 *$B$3$N%W%m%0%i%`$N$$$+$J$kJ#<L!$0\?"!$2~JQ!$=$@5$b5vBz$7$^$9!#(B
 *Everyone is permitted to do anything on this program
 *including copying, transplanting, debugging, and modifying.
 *
 */

#include <sys/types.h>
#include <sys/stat.h>
#ifdefined(sun)
#include <sys/sysmacros.h>
#endifdefined(sun)
#include <stdio.h>

static int lflag ;

main( argc,argv,envp )
    int argc ;
    char *argv[] ;
    char **envp[] ;
{
    extern char *optarg;
    extern int optind;
    register int c,i ;

if( argc == 1 )
{
    fprintf( stderr,"Usage:%% %s [-l] filename ... \n",argv[0] );
    exit( 1 );
}

while( (c = getopt(argc, argv, "l")) != -1 )
{
    switch( c )
    {
    case 'l':
lflag = 1 ;
break;
    case '?':
fprintf( stderr,"Usage:%% %s [-l] filename ... \n",argv[0] );
exit( 1 );
    }
}

if( lflag == 0 )
    for( i=optind ;  i < argc ; i++ )
    {
    statprint( argv[i] );
    }
else
    for( i=optind ;  i < argc ; i++ )
    {
    lstatprint( argv[i] );
    }
exit( 0 );
}

statprint( path )
    char *path ;
{
    struct stat buf ;

if( stat( path,&buf ) == -1 )
{
    perror( path );
    return( 0 );
}
statbufprint( path,&buf );
return( 1 );
}

lstatprint( path )
    char *path ;
{
    struct stat buf ;

if( lstat( path,&buf ) == -1 )
{
    perror( path );
    return( 0 );
}
statbufprint( path,&buf );
return( 1 );
}

statbufprint( path,buf )
    char *path ;
    register struct stat *buf ;
{
    printf("path: %s\n",path );
printf("dev: %d,%d\n",major(buf->st_dev),minor(buf->st_dev) );
printf("ino: %d\n",buf->st_ino );
printf("mode: 0%o\n",buf->st_mode );
printf("nlink: %d\n",buf->st_nlink );
printf("uid: %d\n",buf->st_uid );
printf("gid: %d\n",buf->st_gid );
printf("rdev: %d,%d\n",major(buf->st_rdev),minor(buf->st_rdev) );
printf("size: %d\n",buf->st_size );
printf("atime: %s",ctime(&buf->st_atime) );
printf("mtime: %s",ctime(&buf->st_mtime) );
printf("ctime: %s",ctime(&buf->st_ctime) );
printf("blksize: %d\n",buf->st_blksize );
printf("blocks: %d\n",buf->st_blocks );
}
