What, exactly, are stat.st_blocks, statfs.f_bsize?

Richard Tobin richard at aiai.ed.ac.uk
Tue Mar 12 23:37:39 AEST 1991


In article <6558 at auspex.auspex.com> guy at auspex.auspex.com (Guy Harris) writes:
>>There is nothing in the NFS protocol that specifies a required filesystem
>>or directory block size.

>It also doesn't specify the units to be used in the "blocks" field of
>the "fattr" structure in an NFS GETATTR reply; this is extremely
>unfortunate,

Particularly given that it appears to specify it; the obvious
interpretation of the protocol specification is that it's in units of
"blocksize":

 "'blocksize' is the size in bytes of a block of the file ... 'blocks'
  is the number of blocks the file takes up on disk"

  [NFS: Version 2 Protocol Specification, reproduced in the SunOS
   4.1 documentation]

It would take a mind-reader to guess that the two uses of "block" in
one sentence had different meanings, and that the first use in fact
meant "the optimal transfer size".

>Given that most (modern UNIX) clients probably just use what they get
>back from the server in the "blocks" field, the most appropriate
>convention would probably be to say "'blocks' is in units of 512-byte
>chunks, regardless of what the block or fragment size of the underlying
>file system, or the disk block size, is."

This does seem the best solution.  Fortunately, disk block sizes are
usually a multiple of 512 bytes, so the space occupied can be reported
accurately.

-- Richard
-- 
Richard Tobin,                       JANET: R.Tobin at uk.ac.ed             
AI Applications Institute,           ARPA:  R.Tobin%uk.ac.ed at nsfnet-relay.ac.uk
Edinburgh University.                UUCP:  ...!ukc!ed.ac.uk!R.Tobin



More information about the Comp.unix.wizards mailing list