Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.internals Subject: Re: What, exactly, are stat.st_blocks, statfs.f_bsize? Message-ID: <1991Mar4.001026.3043@athena.mit.edu> Date: 4 Mar 91 00:10:26 GMT References: <1991Feb25.205932.16587@athena.mit.edu> <10283@dog.ee.lbl.gov> <124359@uunet.UU.NET> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 40 In article , kre@cs.mu.OZ.AU (Robert Elz) writes: |> st_blocks should be in units of the most elementary allocation amount |> (which is typically disc sectors) - that's required for accuracy in the |> count. Factors of that number are OK, but wasteful, multiples of it |> (picking a "nice" number) are simply wrong. This is definitely a |> system dependant number (and could be file system dependant). OK, so how do you find out the number for a particular filesystem? We've seen one answer that says it should be in terms of 512-byte blocks on any systems, and that systems that use something other than 512-byte blocks are broken. Now you say that in fact it's OK for different systems to use different block sizes when calculating st_blocks. What neither of you have said is how to *find out* the block size on any particular system, or on any particular filesystem. That is the piece of information I most need to know, because without it, I can't make my program correctly report the actual amount of space taken up by files. |> Programs reporting this number should probably convert it to a useful |> standard unit in most cases, for this purpose it doesn't matter much |> what that unit is - I believe POSIX chose units of 512 for most |> applications, I would have thought 1K was more human friendly. As I said in my original posting, the POSIX stat structure doesn't have st_blocks, or at least it doesn't according to the POSIX book I looked in. So what exactly are you talking about here? I *want* my program to convert from st_blocks to k. I just don't know how to do it, because I don't know how to reliably predict what st_blocks represents. So, for now, I'm just ignoring it. So, any suggestions? -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710