Re: rmdir of a busy directory

Martin Tessun (martin.tessun@class.de)
Mon, 15 Feb 1999 09:31:06 +0100


Thierry Danis wrote:
> You are able to unlink a file that is opened and used by yourself
> or another process.
> You are able to rmdir your current directory by typing
> rmdir `pwd`. So I do not see why we should take care of the
> name of the directory to reject the deletion (`pwd` versus '.').

That exactly isn't correct (at least in Solaris 2.5.1). See my posting
on the list to the topic

rmdir of one's pwd (was Re: rmdir of a busy directory)

There you see, that SunOS 5.5.1 returns EINVAL also on rmdir `pwd`. As I
now understand I think EBUSY isn't correct, because you can remove a
busy directory. As rmdir() doesn't delete the cwd it should be EINVAL. I
think the soluton Alexander added is the correct one.

> And yes, the 2.0.xx kernels returned an 'Operation not permitted'
> on 'rmdir .' and the only serious reason to revert to that test
> is to maintain compatibility.

Well the 2.0.xx kernels aren't the point here. And you shouldn't revert
it to the 2.0.xx behaviour, because this was (as I remember) an EBUSY
and even then an error occured, when the directory was busy by another
process.

OK. Here once again the tests under Solaris 2.5.1:

godzilla% cd /tmp
godzilla% mkdir x
godzilla% cd x
godzilla% rmdir ../x
rmdir: directory "../x": Can't remove current directory or ..
godzilla% rmdir /tmp/x
rmdir: directory "/tmp/x": Can't remove current directory or ..
godzilla% (sleep 10; pwd) &
[1] 2186
godzilla% cd ..
godzilla% rmdir x
godzilla% pwd: cannot determine current directory!

[1] Exit 2 ( sleep 10; pwd )
godzilla% uname -sr
SunOS 5.5.1

BTW: The error-code is EINVAL every time this comman fails. If you want,
I can send you the trace.

Bye
Martin

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/