Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!spool.mu.edu!sdd.hp.com!ucsd!dog.ee.lbl.gov!elf.ee.lbl.gov!torek From: torek@elf.ee.lbl.gov (Chris Torek) Newsgroups: comp.unix.wizards Subject: Re: What, exactly, are stat.st_blocks, statfs.f_bsize? Message-ID: <10283@dog.ee.lbl.gov> Date: 26 Feb 91 00:05:33 GMT References: <1991Feb25.205932.16587@athena.mit.edu> Reply-To: torek@elf.ee.lbl.gov (Chris Torek) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 34 X-Local-Date: Mon, 25 Feb 91 16:05:34 PST In article <1991Feb25.205932.16587@athena.mit.edu> jik@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@ee.lbl.gov Brought to you by Super Global Mega Corp .com