mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
rm -f: ignore EROFS when it's really ENOENT
rm -f must not print a diagnostic for a nonexistent file. However, most linux-based kernel unlinkat functions set errno to EROFS when the named file (regardless of whether it exists) would lie on a read-only file system. remove.c now performs an extra fstatat call in that case, to determine whether the file exists. * src/remove.c (excise): Map EROFS to ENOENT, if a file is nonexistent. Reported by Steven Drake in <http://savannah.gnu.org/bugs/?27923>. * NEWS (Changes in behavior): Mention it.
This commit is contained in:
1 parent
87bf834dd3
commit
7bf2e3db23
3 files changed
+19
No files matched your search
@@ -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;
|
||||
|
||||
|
||||
Reference in new issue
Block a user