bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: du reports different results for "." (proposed patch)


From: Bob Proulx
Subject: Re: du reports different results for "." (proposed patch)
Date: Wed, 20 Feb 2008 17:00:29 -0700
User-agent: Mutt/1.5.13 (2006-08-11)

Paul Eggert wrote:
> I see that this aspect of 'du' is not documented.  Here's a proposed patch
> to the documentation, which I hope improves things.
>
> +If two or more hard links point to the same file, only one of the hard
> +links is counted.  The @var{file} argument order affects which links
> +are counted, and changing the argument order may change the numbers
> +that @command{du} outputs.

Hardlinks!  Here is a modified test example to illustrate the behavior.

  $ mkdir testdir
  $ cd testdir
  $ dd if=/dev/zero of=a count=19
  $ dd if=/dev/zero of=b count=23
  $ dd if=/dev/zero of=c count=29

  $ ls -ldog .
  drwxrwxr-x 2 4096 2008-02-20 16:04 ./

  $ ls -ldog --block-size=1024 .
  drwxrwxr-x 2 4 2008-02-20 16:04 ./

  $ du -s *
  12      a
  12      b
  16      c

  $ ln a z

  $ du -s * .
  12      a
  12      b
  16      c
  32      .

  $ ln b y

  $ du -s * .
  12      a
  12      b
  16      c
  20      .

  $ ln c x

  $ du -s * .
  12      a
  12      b
  16      c
  4       .

Fun how the total directory size just keeps getting smaller and
smaller.  With enough hard links the directory has disappeared!  I
will add this to my list of stupid filesystem tricks.

This doesn't seem a particularly satisfying result as it doesn't seem
like a reasonable outcome.

Fortunately it is a very rare case.  Usually it is one (*) or the
other (.) and either of those produce reasonable results.

  $ du -s .
  44      .

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]