Yang Chen wrote:
> Andrew,
>
> Thanks for your info. I will try the fix. Btw , have you tested below
> fix with more cases?
I've been running the Kernel on a few of our systems with this fix and haven't
found any weird issues yet. It was more important that ls wasn't getting stuck
in a loop. Our system would lock up,.
> I searched archived mails and found an old mailloop regarding the rewind
> change . Looks like that was for rm -rf issues of busybox ...
If rm -rf did leave something behind, that's less of a problem for us. At least
we could modify our scripts to handle that case. Check for the existence of
the directory after it's removal and try again.
My coworker had done some digging for info for me and came up with this:
-------------------------------------------------------------------------------
Some stuff from the posix standard:
"If a file is removed from or added to the directory after the most recent call
to opendir() or rewinddir(), whether a subsequent call to readdir() returns an
entry for that file is unspecified."
In other words, "readdir" is not expected to care if new files are added to a
directory while it is running.
<
http://www.opengroup.org/onlinepubs/009695399/functions/readdir.html>
Rm is not guaranteed to succeed in the posix std.
"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."
<
http://www.opengroup.org/onlinepubs/009695399/utilities/rm.html>
Also,
"Some implementations do not permit the removal of the last link to an
executable binary file that is being executed; see the [EBUSY] error in the
unlink() function defined in the System Interfaces volume of IEEE Std
1003.1-2001. Thus, the rm utility can fail to remove such files."
-------------------------------------------------------------------------------
So rm -rf leaving stuff behind doesn't break posix standards and is definitely
less of an issue than readdir never returning NULL and putting applications into
endless loops, or causing them to use up all the memory in the system (ls
buffers everything before trying to write it out to the terminal).
Andrew