summaryrefslogtreecommitdiff
path: root/src/remove.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/remove.c')
-rw-r--r--src/remove.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/remove.c b/src/remove.c
index 87fb32bf9..c4b93fe7e 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -437,6 +437,18 @@ excise (FTS *fts, FTSENT *ent, struct rm_options const *x, bool is_dir)
return RM_OK;
}
+ /* The unlinkat from kernels like linux-2.6.32 reports EROFS even for
+ nonexistent files. When the file is indeed missing, map that to ENOENT,
+ so that rm -f ignores it, as required. Even without -f, this is useful
+ because it makes rm print the more precise diagnostic. */
+ if (errno == EROFS)
+ {
+ struct stat st;
+ if ( ! (lstatat (fts->fts_cwd_fd, ent->fts_accpath, &st)
+ && errno == ENOENT))
+ errno = EROFS;
+ }
+
if (ignorable_missing (x, errno))
return RM_OK;