[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug #27923] rm -f gives an error when trying to delete a non-existe
From: |
Jim Meyering |
Subject: |
Re: [bug #27923] rm -f gives an error when trying to delete a non-existent file on a read-only filesystem |
Date: |
Tue, 03 Nov 2009 14:18:29 +0100 |
Eric Blake wrote:
> According to Jim Meyering on 11/3/2009 4:04 AM:
>> + if (errno == EROFS)
>> + {
>> + struct stat st;
>> + if ( ! (fstatat (fts->fts_cwd_fd, ent->fts_accpath, &st,
>> + AT_SYMLINK_NOFOLLOW) && errno == ENOENT))
>
> Why not use lstatat, rather than fstatat(,AT_SYMLINK_NOFOLLOW)?
It's equivalent and more readable, but not standard (albeit guaranteed
by gnulib), and there is no other use in coreutils proper.
To be honest, I didn't even think about it.
But I do prefer it, so have adjusted.
Thanks.
Here's the incremental, from my git diff address@hidden address@hidden
diff --git a/src/remove.c b/src/remove.c
index a234829..c4b93fe 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -444,8 +444,8 @@ excise (FTS *fts, FTSENT *ent, struct rm_options const *x,
bool is_dir)
if (errno == EROFS)
{
struct stat st;
- if ( ! (fstatat (fts->fts_cwd_fd, ent->fts_accpath, &st,
- AT_SYMLINK_NOFOLLOW) && errno == ENOENT))
+ if ( ! (lstatat (fts->fts_cwd_fd, ent->fts_accpath, &st)
+ && errno == ENOENT))
errno = EROFS;
}