bug-coreutils
[Top][All Lists]
Advanced

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

Re: Bug#211591: du: -D option botches symlinks


From: Jim Meyering
Subject: Re: Bug#211591: du: -D option botches symlinks
Date: Fri, 19 Sep 2003 09:43:14 +0200

Jeff Sheinberg <address@hidden> wrote:
> It appears that "du -D SYMLINK_TO_DIRECTORY" botches each filename
> printed by omitting the "/" between the symlink and each contained
> directory name.
>
> Here is a typescript that demonstrates this problem,
>
>     $ /usr/bin/du -D ~jss/locl/Tsys
>     186     /home/jss/locl/Tsysbin
>     3       /home/jss/locl/Tsysinclude
>     28      /home/jss/locl/Tsyslib
>     2       /home/jss/locl/Tsysman/man3
>     3       /home/jss/locl/Tsysman
>     201     /home/jss/locl/Tsysobjs
>     4       /home/jss/locl/Tsysdepends
>     426     /home/jss/locl/Tsys

Thank you for reporting that!
That was due to a bug in code I wrote to work around nftw's
lack of support for --dereference-args (-D) semantics.
This is yet another reason to hurry up and make the
switch to using ftw instead.

Here's a fix:

        `du -D symlink-to-dir' would mistakenly omit the slash in
        lines like this:  24    symlink-to-dir/subdir
        * src/du.c (process_file): Fix offset calculation.
        Reported by Jeff Sheinberg as Debian bug #211591;
        http://bugs.debian.org/205251

Index: src/du.c
===================================================================
RCS file: /fetish/cu/src/du.c,v
retrieving revision 1.162
retrieving revision 1.163
diff -u -p -u -r1.162 -r1.163
--- src/du.c    19 Sep 2003 06:51:59 -0000      1.162
+++ src/du.c    19 Sep 2003 07:39:04 -0000      1.163
@@ -474,7 +474,8 @@ process_file (const char *file, const st
          fwrite (file, arg_length, 1, stdout);
          /* Print everything after what we appended.  */
          fputs (file + arg_length + suffix_length
-                + (file[arg_length + suffix_length] == '/'), stdout);
+                + (file[arg_length - 1] == '/'
+                   && file[arg_length + suffix_length] == '/'), stdout);
        }
       else
        {




reply via email to

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