[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: rm -r gives up before going deeper upon encountering hindrances
From: |
Jim Meyering |
Subject: |
Re: rm -r gives up before going deeper upon encountering hindrances |
Date: |
Sat, 08 May 2004 14:51:25 +0200 |
Paul Eggert <address@hidden> wrote:
> Jim Meyering <address@hidden> writes:
>
>> + /* Accept either EISDIR, EPERM, or EACCES as an indication that FILENAME
>> may
>> + be a directory. POSIX says that unlink must set errno to EPERM when it
>> + fails to remove a directory, while Linux-2.4.18 sets it to EISDIR.
>> + unlink fails with EACCES when the parent directory is write-protected.
>> */
>
> Aren't other error numbers possible? For example, suppose the
Yes, indeed.
I realized that as I was writing the above,
but didn't have the time to investigate just then.
...
> 2004-05-08 Paul Eggert <address@hidden>
>
> Fix bug where "rm" gave up too easily, reported by Dan Jacobsen in
> <http://mail.gnu.org/archive/html/bug-coreutils/2004-05/msg00013.html>.
>
> * src/remove.c (remove_entry): Check for errno values like ENOENT
> that show the file cannot be directory, instead of for errno
> values like EPERM that show the file might be a directory. This
> is necessary because, when a single unlink() call has multiple
> reasons to fail, it can set errno to any of those reasons; it's
> only the rare errno value like ENOENT that excludes all the other
> possible reasons to fail even when the file is a directory.
> (remove_cwd_entries): Don't attempt chdir if the file is known
> to not be a directory.
> (remove_dir): Use the same method that remove_cwd_entries uses
> (for some reason they differed). Don't assert that saved_errno
> must be EPERM; it might be just about anything.
That is a fine patch.
I've applied it and added a test. Thank you!