fts: do not fail on a submount during traversal
authorKamil Dudka <kdudka@redhat.com>
Tue, 10 Nov 2009 13:26:56 +0000 (14:26 +0100)
committerJim Meyering <meyering@redhat.com>
Thu, 12 Nov 2009 11:39:34 +0000 (12:39 +0100)
* lib/fts.c (fts_build): Read the stat info again after opening
a directory if the FTS_TIGHT_CYCLE_CHECK flag is set.
Original report at http://bugzilla.redhat.com/501848.

ChangeLog
lib/fts.c

index 9224704a45e5760c04fd8f6c45efe94344e72912..a3ed685b921b706c7c3207259427bd36fd06ad61 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-11-10  Kamil Dudka  <kdudka@redhat.com>
+
+       fts: do not fail on a submount during traversal
+       * lib/fts.c (fts_build): Read the stat info again after opening
+       a directory if the FTS_TIGHT_CYCLE_CHECK flag is set.
+       Original report at http://bugzilla.redhat.com/501848.
+
 2009-11-12  Jim Meyering  <meyering@redhat.com>
 
        bootstrap: sync from coreutils
index 40a837ed87211053b881c278c6d379cf625bd9d9..21c66583ac48c9b2e0a2b5863fe67bfb3fde5378 100644 (file)
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -1268,6 +1268,20 @@ fts_build (register FTS *sp, int type)
          opening it.  */
        if (cur->fts_info == FTS_NSOK)
         cur->fts_info = fts_stat(sp, cur, false);
+       else if (sp->fts_options & FTS_TIGHT_CYCLE_CHECK) {
+               /* Now read the stat info again after opening a directory to
+                * reveal eventual changes caused by a submount triggered by
+                * the traversal.  But do it only for utilities which use
+                * FTS_TIGHT_CYCLE_CHECK.  Therefore, only find and du
+                * benefit/suffer from this feature for now.
+                */
+               LEAVE_DIR (sp, cur, "4");
+               fts_stat (sp, cur, false);
+               if (! enter_dir (sp, cur)) {
+                        __set_errno (ENOMEM);
+                        return NULL;
+               }
+       }
 
        /*
         * Nlinks is the number of possible entries of type directory in the