From 239d400abe783ad297b547e4e5a281cc1613ef70 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Tue, 10 Nov 2009 14:26:56 +0100 Subject: [PATCH] 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. --- ChangeLog | 7 +++++++ lib/fts.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-) diff --git a/ChangeLog b/ChangeLog index 599a2ab..2ecd268 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-11-10 Kamil Dudka + + 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-09 Eric Blake rename: detect FreeBSD bug diff --git a/lib/fts.c b/lib/fts.c index 40a837e..6720946 100644 --- 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 traverse. But do it only for utilities which use + * FTS_TIGHT_CYCLE_CHECK. Therefore only find and du can + * benefit 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 -- 1.6.2.5