bug-coreutils
[Top][All Lists]
Advanced

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

Re: Bug#367691: coreutils: behaviour of du -x[LDP] differs from that of


From: Jim Meyering
Subject: Re: Bug#367691: coreutils: behaviour of du -x[LDP] differs from that of du -[LDP]x
Date: Fri, 19 May 2006 16:05:29 +0200

Justin Pryzby <address@hidden> wrote:

> Package: coreutils
> Version: 5.94-1
> Severity: normal
>
> I was reading du.c, and saw this:
...
> A patch (assuming I understand the intended state of things) would
> look something like:
>
>           bit_flags|= FTS_COMFOLLOW;
> [...]
>           bit_flags = FTS_LOGICAL;
>           bit_flags&=~FTS_PHYSICAL;
> [...]
>           bit_flags|=FTS_PHYSICAL;
>           bit_flags&=~FTS_LOGICAL;
>
> This also avoids clearing FTS_TIGHT_CYCLE_CHECK, which I'm guessing is
> not intentional?

You're right.
Thanks for spotting that.

Here's the change I've checked in for 6.0 -- note that clearing
FTS_TIGHT_CYCLE_CHECK had no discernible effect in the tests I ran.
If it did, the result would be that the pre-fix version would detect
a symlink cycle (or hard-directory cycle) later than it could have,
and du would print more than one line for some directories in the cycle.

2006-05-19  Jim Meyering  <address@hidden>

        * src/du.c (main): Don't let -D, -L, or -P turn off the internal
        FTS_TIGHT_CYCLE_CHECK directory traversal option.
        Reported by Justin Pryzby in http://bugs.debian.org/367691

Index: src/du.c
===================================================================
RCS file: /fetish/cu/src/du.c,v
retrieving revision 1.224
retrieving revision 1.225
diff -u -p -u -r1.224 -r1.225
--- src/du.c    4 Nov 2005 10:08:51 -0000       1.224
+++ src/du.c    19 May 2006 12:36:18 -0000      1.225
@@ -1,5 +1,5 @@
 /* du -- summarize disk usage
-   Copyright (C) 1988-1991, 1995-2005 Free Software Foundation, Inc.
+   Copyright (C) 1988-1991, 1995-2006 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -681,7 +681,11 @@ main (int argc, char **argv)
   struct Tokens tok;
 
   /* Bit flags that control how fts works.  */
-  int bit_flags = FTS_PHYSICAL | FTS_TIGHT_CYCLE_CHECK;
+  int bit_flags = FTS_TIGHT_CYCLE_CHECK;
+
+  /* Select one of the three FTS_ options that control if/when
+     to follow a symlink.  */
+  int symlink_deref_bit = FTS_PHYSICAL;
 
   /* If true, display only a total for each argument. */
   bool opt_summarize_only = false;
@@ -803,15 +807,15 @@ main (int argc, char **argv)
          break;
 
        case 'D': /* This will eventually be 'H' (-H), too.  */
-         bit_flags = FTS_COMFOLLOW;
+         symlink_deref_bit = FTS_COMFOLLOW;
          break;
 
        case 'L': /* --dereference */
-         bit_flags = FTS_LOGICAL;
+         symlink_deref_bit = FTS_LOGICAL;
          break;
 
        case 'P': /* --no-dereference */
-         bit_flags = FTS_PHYSICAL;
+         symlink_deref_bit = FTS_PHYSICAL;
          break;
 
        case 'S':
@@ -1000,6 +1004,7 @@ main (int argc, char **argv)
     ok = (i == j);
   }
 
+  bit_flags |= symlink_deref_bit;
   ok &= du_files (files, bit_flags);
 
   /* This isn't really necessary, but it does ensure we




reply via email to

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