delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/05/18/09:18:35

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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 <ebb9 AT byu DOT net>
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 <rurban AT x-ray DOT at>, cygwin AT cygwin DOT com
Subject: bug in du
References: <302d72f2c4cb7d883558c713e211f68b AT NO-ID-FOUND DOT mhonarc DOT org> <Pine DOT GSO DOT 4 DOT 61 DOT 0505161419510 DOT 6277 AT slinky DOT cs DOT nyu DOT edu> <428A7ADF DOT 20409 AT x-ray DOT at> <428B3B5C DOT 60306 AT byu DOT net>
In-Reply-To: <428B3B5C.60306@byu.net>
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019