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


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to