[cs631apue] total num of blocks

Jan Schaumann jschauma at stevens.edu
Sat Oct 20 21:38:22 EDT 2012


ccui1 <ccui1 at stevens.edu> wrote:

> My Linux system will display the number of blocks using 1024 as the  
> default block size if there is on BLOCKSIZE environment value is set.
> If I set the BLOCKSIZE environment value, it will display the result  
> based on that number.
>
> In our project, the only difference is we use 512 as the default block  
> size. Am I correct?

Yes, that is correct.  Your program will report, as a default, using a
512 byte block size as explicitly mentioned in the manual page.  (The
Linux version does unfortunately not appear to include a mention of the
default blocksize it uses in its manual page.)

> In addition, if I change the BLOCKSIZE environment value, the total  
> number of blocks used by the directory will also change based on that  
> value.

Correct.

> Does that means no matter what environment value I gives, the output  
> just calculate the number of blocks by using the 512 block size?

No, any time that you are reporting physical disk blocks, you should
default to 512 byte blocks, but allow the user to override this setting
using the BLOCKSIZE environment variable.

You are correct that the manual page provided to you should be clearer
in this regard; I have updated it accordingly.

-Jan


More information about the cs631apue mailing list