Bootscripts [HEAD]

Bryan Kadzban bryan at kadzban.is-a-geek.net
Wed Jun 30 04:05:43 PDT 2004


The Old Fellow wrote:
> This line: find . -xdev -mindepth 1 ! -name lost+found \
>     -exec rm -rf {} \; || failed=1
> 
> in cleanfs, is occasionally giving me problems with errors saying
> files don't exist.  The most frequent report is "./.X11-unix - no
> such file or directory".

The "problem" is the rm -rf part.  Well, sort of; the problem is really
the fact that you have directories there that find is trying to recurse
into.

For each file and directory that it finds (unless the dir is named
lost+found), it rm -rf's it.  That means that if your /tmp looks like this:

/tmp/
   |
   |-.X11-unix/
   |   |
   |   |-X0
   |
   |-temp-file

Then when find sees .X11-unix, it runs rm -rf on it.  But then find
attempts to recurse into .X11-unix (since it's a recursive search for
stuff), and fails because it just deleted the directory.

It does continue on and delete temp-file, so the message is harmless.

I *think* we could get rid of the message if we added a -maxdepth 1 to
find's arguments.  The only difference would be that the current find
command will delete the contents of lost+found, just not the directory
itself.  If we add -maxdepth 1, it won't delete anything in there.

If you had /tmp/.X11-unix/mountpoint (for some strange reason), where
mountpoint has another FS mounted on it, then at first it looks like
this find would not try to remove mountpoint.  However, it will (rm -rf
doesn't care about find's -xdev argument; that's why it can be so
dangerous).  I doubt that will ever happen, but the possibility is
there.



More information about the lfs-dev mailing list