[cs631apue] Midterm Question

Jan Schaumann jschauma at stevens.edu
Sun Sep 23 13:56:33 EDT 2012


tparisi <tparisi at stevens.edu> wrote:
> I'm still unclear on how to get the total number of blocks for the
> directory, if the blocksize is 512 of course.  It is my understanding
> that the st_blocks in the stat structure is only for the directory
> entry and not the entire file.

Each file's inode contains a field st_blocks that contains the value of
512 byte blocks used by this file.  So in order to identify the total
number of blocks used by all files in a given directory, you have to add
all those up.

This does not recurse through sub directories, however.  That is, for
each directory, the total only refers to the entries in the given
directory.

Does that help?

-Jan


More information about the cs631apue mailing list