bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rm -r sometimes produces errors under NFS


From: Jim Meyering
Subject: Re: rm -r sometimes produces errors under NFS
Date: Tue, 06 Mar 2007 23:41:30 +0100

Vincent Lefevre <address@hidden> wrote:

> On 2007-03-06 20:45:24 +0100, Jim Meyering wrote:
>> Vincent Lefevre <address@hidden> wrote:
>> > On 2007-03-06 15:17:07 +0100, Jim Meyering wrote:
>> >> Such "remembering" would be prohibitively expensive, in general.
>> >
>> > I don't see why.
>>
>> Remembering means storing names, potentially many of them.
>> That's why it would be prohibitively expensive.
>
> No need to store names: if it's the second pass, all the files have
> already been unlinked.

Not necessarily.  Have you looked at the code?
New files may have been added since the original opendir
or since the most recent rewinddir.  We'd need some way
to distinguish those new names from the ones we've already
successfully unlinked.

>> > In fact, it isn't necessarily useful to remember anything.
>> > When rm attempts to remove a file in a recurse phase,
>> > no errors should be reported if the file doesn't exist.
>>
>> No.  Any POSIX-conforming rm implementation is required to
>> report such errors, unless you specify -f.
>
> Wrong. In the recurse phase, if rm tries to unlink a file, this means
> that the file has existed. So, this wouldn't be contrary to POSIX.

Your conclusion is invalid.
What if some other process removed it first?

If you're still convinced you have a case,
you're going to have to start quoting the standard.
I based my statement on what I know of POSIX, e.g., from this part
of the rm specification:

      4. If the current file is a directory, ...
      If the current file is not a directory, rm shall perform actions
      equivalent to the unlink() function defined in the System
      Interfaces volume of IEEE Std 1003.1-200x called with a pathname
      of the current file used as the path argument. If this
      fails for any reason, rm shall write a diagnostic message
      to standard error, do nothing more with the current file,
      and go on to any remaining files.


> But there's still a race condition (unrelated to NFS) in the rm code.

Something new?  Please give details.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]