Skip to contentSkip to conversation

`rmdir .` doesn't work in 2.4

DISCUSSION [email protected] 3 participants 3 messages Jan 8, 2001 – Jan 9, 2001

lore
Share & tools
lore
#0 lore raw

From: Andrea Arcangeli <[email protected]>

> But in fact it fails with EINVAL, and
>
> [EINVAL]: The path argument contains a last component that is dot.

I can't confirm. The specs I'm checking are here:

http://www.opengroup.org/onlinepubs/007908799/xsh/rmdir.html

That is the SUSv2 text, one of the ingredients for the new POSIX standard. I quoted the current Austin draft, the current draft for the next version of the POSIX standard.

Quoting a text fragment:

The rmdir( ) function shall remove a directory whose name is given by path. The directory is removed only if it is an empty directory. If the directory is the root directory or the current working directory of any process, it is unspecified whether the function succeeds, or whether it shall fail and set errno to [EBUSY]. If path names a symbolic link, then rmdir( ) shall fail and set errno to [ENOTDIR]. If the path argument refers to a path whose final component is either dot or dot-dot, rmdir( ) shall fail. ...

> Indeed, rmdir("P/D") does roughly the following:
> (i) check that P/D is a directory
> (ii) check that P/D does not have entries other than . and .. > (iii) delete the names . and .. from P/D
> (iv) delete the name D from P

SUSv2 is straightforward. It doesn't talk about (iv).

I just made explicit what rmdir() actually does, in order to show that a trailing dot really is a different case where other rules than the usual ones would have to be applied. Indeed, rmdir("foo/bar") finishes by removing the name "bar" from the directory "foo", but rmdir("foo/.") does not finish by removing the name "." from the directory "foo".

Andries

[Think classical Unix: there are inodes, and there are names. The rmdir call, just like rm, removes names. Now foo and foo/. may both be names for the same inode, but they are not the same name.] -
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#1 lore raw
Quoted 16 lines · On Mon, Jan 08, 2001 at 11:50:44PM +0100, [email protected] wrote:

From: Andrea Arcangeli <[email protected]>

> But in fact it fails with EINVAL, and
>
> [EINVAL]: The path argument contains a last component that is dot.

I can't confirm. The specs I'm checking are here:

http://www.opengroup.org/onlinepubs/007908799/xsh/rmdir.html

That is the SUSv2 text, one of the ingredients for the new POSIX standard. I quoted the current Austin draft, the current draft for the next version of the POSIX standard.

Quoting a text fragment:

Quoted 9 lines

The rmdir( ) function shall remove a directory whose name is given by path. The directory is removed only if it is an empty directory. If the directory is the root directory or the current working directory of any process, it is unspecified whether the function succeeds, or whether it shall fail and set errno to [EBUSY]. If path names a symbolic link, then rmdir( ) shall fail and set errno to [ENOTDIR]. If the path argument refers to a path whose final component is either dot or dot-dot, rmdir( ) shall fail. ...

I trust your specs said so, however I'm not sure which are the specs we should follow for Linux.

At least for LFS 2.2.x fixage I always followed the SuSv2 specs and they doesn't even say that rmdir can return -EINVAL. So returning -EINVAL is wrong in first place according to SuSv2.

Quoted 2 lines

from the directory "foo", but rmdir("foo/.") does not finish by removing the name "." from the directory "foo".

Sure. Also rmdir . doesn't mean remove "." from current directory but it means "remove the directory pointed out by path `.'". The kernel/We definitely knows which is such directory. That is in sync with the specs: "The rmdir() function removes a directory whose name is given by path". You agree that the path "." identifys one directory.

Andrea
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
In reply to [email protected]
Quoted 16 lines · On Mon, Jan 08, 2001 at 11:50:44PM +0100, [email protected] wrote:

From: Andrea Arcangeli <[email protected]>

> But in fact it fails with EINVAL, and
>
> [EINVAL]: The path argument contains a last component that is dot.

I can't confirm. The specs I'm checking are here:

http://www.opengroup.org/onlinepubs/007908799/xsh/rmdir.html

That is the SUSv2 text, one of the ingredients for the new POSIX standard. I quoted the current Austin draft, the current draft for the next version of the POSIX standard.

Quoting a text fragment:

Quoted 9 lines

The rmdir( ) function shall remove a directory whose name is given by path. The directory is removed only if it is an empty directory. If the directory is the root directory or the current working directory of any process, it is unspecified whether the function succeeds, or whether it shall fail and set errno to [EBUSY]. If path names a symbolic link, then rmdir( ) shall fail and set errno to [ENOTDIR]. If the path argument refers to a path whose final component is either dot or dot-dot, rmdir( ) shall fail. ...

At the bottom of Andrea Arcangeli's url, it says:
Derived from the POSIX.1-1988 standard.

I think it makes sense that if POSIX changed it, that we should follow POSIX, and not SuS v2, specially if it simplify's things in the kernel.

Kurt

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/