bug-gnulib
[Top][All Lists]
Advanced

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

Re: Possible spurious cycle detection with fts


From: Jim Meyering
Subject: Re: Possible spurious cycle detection with fts
Date: Tue, 09 Aug 2005 17:34:17 +0200

James Youngman <address@hidden> wrote:
> If I invoke fts_open() with the FTS_LOGICAL flag and do not set
> FTS_TIGHT_CYCLE_CHECK, then fts_read() returns FTS_DC in
> ent->fts_info.  However, with the same directory layout FTS_DC is not
> set if FTS_TIGHT_CYCLE_CHECK is set.
>
> fts_options                                   Result
> FTS_NOSTAT|FTS_LOGICAL|FTS_TIGHT_CYCLE_CHECK    OK
> FTS_NOSTAT|FTS_LOGICAL                          Loop (wrongly) detected
> FTS_NOSTAT|FTS_PHYSICAL                               OK

Hi James,

Thanks for reporting that.
You're right that fts cycle detection could
get false positives with FTS_NOSTAT|FTS_LOGICAL.
Here's a barely-tested fix (tested only with an instrumented chown-core.c
via `chown -RL' since I don't have the latest find sources here):

Barring negative feedback, I'll check it in to gnulib
in a day or two.

2005-08-09  Jim Meyering  <address@hidden>

        * fts-cycle.c (setup_dir, enter_dir, leave_dir, free_dir):
        Use the hash-table-based cycle-detection code not just when
        FTS_TIGHT_CYCLE_CHECK if specified, but also with FTS_LOGICAL.
        Reported by James Youngman

Index: lib/fts-cycle.c
===================================================================
RCS file: /home/meyering/tmp/cu-repo/cu/lib/fts-cycle.c,v
retrieving revision 1.2
diff -u -p -r1.2 fts-cycle.c
--- lib/fts-cycle.c     21 May 2005 06:42:41 -0000      1.2
+++ lib/fts-cycle.c     9 Aug 2005 14:47:09 -0000
@@ -50,7 +50,7 @@ AD_hash (void const *x, size_t table_siz
 static bool
 setup_dir (FTS *fts)
 {
-  if (fts->fts_options & FTS_TIGHT_CYCLE_CHECK)
+  if (fts->fts_options & (FTS_TIGHT_CYCLE_CHECK | FTS_LOGICAL))
     {
       enum { HT_INITIAL_SIZE = 31 };
       fts->fts_cycle.ht = hash_initialize (HT_INITIAL_SIZE, NULL, AD_hash,
@@ -74,7 +74,7 @@ setup_dir (FTS *fts)
 static bool
 enter_dir (FTS *fts, FTSENT *ent)
 {
-  if (fts->fts_options & FTS_TIGHT_CYCLE_CHECK)
+  if (fts->fts_options & (FTS_TIGHT_CYCLE_CHECK | FTS_LOGICAL))
     {
       struct stat const *st = ent->fts_statp;
       struct Active_dir *ad = malloc (sizeof *ad);
@@ -125,7 +125,7 @@ enter_dir (FTS *fts, FTSENT *ent)
 static void
 leave_dir (FTS *fts, FTSENT *ent)
 {
-  if (fts->fts_options & FTS_TIGHT_CYCLE_CHECK)
+  if (fts->fts_options & (FTS_TIGHT_CYCLE_CHECK | FTS_LOGICAL))
     {
       struct stat const *st = ent->fts_statp;
       struct Active_dir obj;
@@ -144,7 +144,7 @@ leave_dir (FTS *fts, FTSENT *ent)
 static void
 free_dir (FTS *sp)
 {
-  if (sp->fts_options & FTS_TIGHT_CYCLE_CHECK)
+  if (sp->fts_options & (FTS_TIGHT_CYCLE_CHECK | FTS_LOGICAL))
     {
       if (sp->fts_cycle.ht)
        hash_free (sp->fts_cycle.ht);




reply via email to

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