du does not find all directories

Jim Balter jqb@netcom.com
Thu Feb 6 21:51:00 GMT 1997


Scott Kempf wrote:
> 
> >I find that du finds 335637 (presumably times 512) Bytes on my hard drive.
> 
> On my win95 system, the conversion is 2K not 512.

st_blocks is supposed to contain the number of 512-byte blocks
(because that's what a block meant when st_blocks was invented
by BSD; st_blksize is the filesystem's block (cluster, on Windows) size,
which is a different beast, thus the confusion; st_blocks is *not*
supposed to be in terms of st_blksize), but cygwin sets st_blocks to the
number of 1024-byte blocks.  So ld and ls divide st_blocks by 2, making
them appear to report the number of 2048-byte blocks.  fhandler.c should
be fixed to report 512-byte blocks, but as a stopgap you can fudge
the ST_NBLOCKS macro in usersrc/fileutils/system.h to assume 1024-byte
blocks like is done for HP-UX, or to ignore st_blocks and just use
st_size (the difference is that st_blocks is supposed to include
filesystem overhead, such as unix indirect blocks, and exclude "sparse"
blocks), and then rebuild ls and du.

Is there any sort of mechanism for reporting such specific bugs and
fixes, or do we just hope that someone at cygnus notices and makes
the change?

> Find a large file and do:
> 
>         ls -l large_file
>         du -s large_file
> 
> This usually helps (unless it's sparse :-).

Sparse files are reported properly only on unix systems that support
st_blocks, but FAT (and, AFAIK, NTFS) does not have the notion
of sparse files (files with all-zero blocks that don't take any space
because the block number in the blocklist is 0).

--
<J Q B>
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".



More information about the Cygwin mailing list