Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <428B408B.7050902@byu.net> Date: Wed, 18 May 2005 07:18:03 -0600 From: Eric Blake Reply-To: bug-coreutils AT gnu DOT org User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) MIME-Version: 1.0 To: bug-coreutils AT gnu DOT org CC: Reini Urban , cygwin AT cygwin DOT com Subject: bug in du References: <302d72f2c4cb7d883558c713e211f68b AT NO-ID-FOUND DOT mhonarc DOT org> <428A7ADF DOT 20409 AT x-ray DOT at> <428B3B5C DOT 60306 AT byu DOT net> In-Reply-To: <428B3B5C.60306@byu.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes -----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 AT byu DOT 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/