This is the mail archive of the
cygwin
mailing list for the Cygwin project.
bug in du
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Reini Urban reported a du bug on the cygwin list - using mount points (or
directory hard links on systems that support that) confuses the default
behavior, and files are being double-counted and inflating the actual disk
space in usage. In the example below, I used cygwin's mount feature to
mount dir3 atop dir1.
> $ ls -iRF
> .:
> 14952513712823677584 dir1/ 2251799813894795 file1
> 28147497671275154 dir2/ 2251799813894795 file2
> 14952513712823677584 dir3/
>
> ./dir1:
> 17343925114957410972 file
>
> ./dir2:
> 17343925114957410972 file
>
> ./dir3:
> 17343925114957410972 file
> $ du
> 1 ./dir1 # dir1/file counted...
> 0 ./dir2 # ...skipped since st_nlink is 2
> 0 ./dir3 # ...skipped since st_nlink is 2
> 2 . # and ./file[12] counted once
> $ du -l # ...where file was also linked outside linked directories
> 1 ./dir1 # dir1/file counted once...
> 1 ./dir2 # twice
> 1 ./dir3 # third time
> 5 . # plus 2 more for ./file[12]
> $ echo testing > dir3/file3
> $ ls -iRF
> .:
> 14952513712823677584 dir1/ 2251799813894795 file1
> 28147497671275154 dir2/ 2251799813894795 file2
> 14952513712823677584 dir3/
>
> ./dir1:
> 17343925114957410972 file 1970324837184162 file3
>
> ./dir2:
> 17343925114957410972 file
>
> ./dir3:
> 17343925114957410972 file 1970324837184162 file3
> $ du
> 2 ./dir1 # dir1/file and dir1/file3 counted
> 0 ./dir2 # dir2/file skipped
> 1 ./dir3 # dir3/file skipped, but dir3/file3 counted!
> 4 . # and ./file[12] counted once. This total should be 3
> $ du -l
> 2 ./dir1 # dir1/file and dir1/file3 counted
> 1 ./dir2 # dir2/file counted again
> 2 ./dir3 # dir3/file and dir3/file3 counted again
> 7 . # and ./file[12] each counted, for correct total.
> $ ls -l dir1
> total 2
> -rw-r--r-- 2 eblake None 8 May 18 06:38 file
> -rw-r--r-- 1 eblake None 8 May 18 06:50 file3
One possible fix is revisiting line 377 in src/du.c in CVS, which
currently skips hard links only if a file has multiple links. The other
fix would be to also check directories for identical inodes, and not
descending through a directory by a second spelling if it has already been
visited once.
- --
Life is short - so eat dessert first!
Eric Blake ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCi0CL84KuGfSFAYARAlTnAJ95ur2l0LxXXZjNrLPNQrcBIeTX3ACgoe5p
40GmfwNSFZJRZyp0AcWWics=
=N51g
-----END PGP SIGNATURE-----
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/