summaryrefslogtreecommitdiff
path: root/src/chmod.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/chmod.c')
-rw-r--r--src/chmod.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/chmod.c b/src/chmod.c
index 29611366c..7858c0a66 100644
--- a/src/chmod.c
+++ b/src/chmod.c
@@ -193,6 +193,19 @@ process_file (FTS *fts, FTSENT *ent)
return true;
case FTS_NS:
+ /* For a top-level file or directory, this FTS_NS (stat failed)
+ indicator is determined at the time of the initial fts_open call.
+ With programs like chmod, chown, and chgrp, that modify
+ permissions, it is possible that the file in question is
+ accessible when control reaches this point. So, if this is
+ the first time we've seen the FTS_NS for this file, tell
+ fts_read to stat it "again". */
+ if (ent->fts_level == 0 && ent->fts_number == 0)
+ {
+ ent->fts_number = 1;
+ fts_set (fts, ent, FTS_AGAIN);
+ return true;
+ }
error (0, ent->fts_errno, _("cannot access %s"), quote (file_full_name));
ok = false;
break;