What, exactly, are stat.st_blocks, statfs.f_bsize?
Chris Torek
torek at elf.ee.lbl.gov
Tue Feb 26 11:05:33 AEST 1991
In article <1991Feb25.205932.16587 at athena.mit.edu> jik at athena.mit.edu
(Jonathan I. Kamens) writes:
>... on a 4.3BSD system, the stat structure contains the st_blocks field,
>which tells the "actual number of blocks allocated." Given that
>description, the question becomes, what exactly is a "block?" There are two
>possible answers:
>
>1. The size specified by DEV_BSIZE.
>2. The size in the f_bsize field of the statfs structure of the filesystem on
> which the file resides.
The answer is `none of the above'.
>Now, it seemed to me that f_bsize would be the logical choice,
No: f_bsize is the `block' size and not the `fragment' size under
4.3BSD-reno, i.e., typically 8K rather than 1K. (SunOS and 4BSD are
different here; SunOS defines f_bsize as the fragment size.)
>The 4.3reno stat(2) man page goes even further; it describes st_blocks
>as "The actual number of blocks allocated for the file in 512-byte units."
>But that leaves me with another question -- is it DEV_BSIZE, or 512 bytes?
It is 512 bytes; it does not matter what DEV_BSIZE is. Under 4.3tahoe
on the Tahoe, DEV_BSIZE was 1024; 4.3reno has no DEV_BSIZE at all (well,
it has one as a compatibility hack) and each disk's block size is a
property of that disk.
Note that there may be (probably are) some systems out there in which
st_blocks is in terms of 1 kbyte blocks; these should dwindle away,
but will probably leave a lingering stench. :-)
--
In-Real-Life: Chris Torek, Lawrence Berkeley Lab EE div (+1 415 486 5427)
Berkeley, CA Domain: torek at ee.lbl.gov
More information about the Comp.unix.wizards
mailing list