Subject: Re: rmdir(".")
To: None <tech-kern@NetBSD.org>
From: Roland Illig <rillig@NetBSD.org>
List: tech-kern
Date: 09/09/2005 11:16:45
Roland Illig wrote:
> Hi folks,
> 
> is there any technical reason for not allowing rmdir("."), or is it just 
> to protect the user from something {s,}he might eventually not want to 
> do? I'm not interested in a flame war, I just want to know the reasons 
> for it. (I'm still too young to know everything about Unix-like systems. 
> ;))
> 
> http://www.opengroup.org/onlinepubs/009695399/functions/rmdir.html says 
> removing the current working directory is allowed.
> 
> By the way, the error code is wrong. It should not be EINVAL, but EBUSY.

This is wrong.

As Terry Moore told me, when you call rmdir("."), the "last component" 
is either dot or dot-dot, and so rmdir(2) is required to return EINVAL, 
according to paragraph 4 of the DESCRIPTION. Paragraph 2 of the 
DESCRIPTION has a completely other purpose.

And after a little bit of thinking, I realized that you cannot reliably 
say for directories with more than one name, which of the names should 
be deleted. So I answered the question myself, with a little help from 
you. ;) Thanks.

Roland