Skip to contentSkip to conversation

`rmdir .` doesn't work in 2.4

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

lore
Share & tools
lore
#0 lore raw
Quoted 3 lines

why rmdir . is been deprecated in 2.4.x?

rmdir . makes perfect sense, the cwd dentry remains pinned

You think that it fails with EBUSY. That would be allowed but not required:

[EBUSY]: The directory to be removed is currently in use by
the system or some process and the implementation considers this to be an error.

Here we are free to consider this "in use" an error or not. But in fact it fails with EINVAL, and

[EINVAL]: The path argument contains a last component that is dot.

(Quoted from the last Austin draft.)
Thus, for POSIX compliance we do need the current behaviour.

Also logically rmdir(".") is a doubtful operation. 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

You see that rmdir("P/.") would have to do something other than (iv), namely deleting something from the parent directory of P. In cases where hard links to directories are permitted,
it is not even clear we can talk about "the parent directory". So, I do not think that "rmdir ." makes perfect sense.

Andries

-
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 7 lines · On Mon, Jan 08, 2001 at 09:56:18PM +0100, [email protected] wrote:

You think that it fails with EBUSY. That would be allowed but not required:

[EBUSY]: The directory to be removed is currently in use by
the system or some process and the implementation considers this to be an error.

Here we are free to consider this "in use" an error or not.

I think the above is to allow implementations without something like our dcache to not be declared "broken" w.r.t. specs.

Quoted 3 lines

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

They definitely don't say that rmdir . must return -EINVAL.

Quoted 5 lines

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

The definition of rmdir according to 2.2.19pre6 and the single unix specification version 2 is this:

int rmdir(const char *path);

DESCRIPTION
The rmdir() function removes a directory whose name is given by path. The directory is removed only if it is an empty directory.

That is strightforward. It doesn't talk about (iv).

Quoted 2 lines

In cases where hard links to directories are permitted, it is not even clear we can talk about "the parent directory".

Hardlinks have nothing to do with rmdir .. See rmdir . as the equivalent pointed out by Alexander: "rmdir pwd". pwd returns the same thing regardless the current directory has nlink > 1 or not (even if it has nlink = 0 infact). The parent directory is still identified as "pwd/.." (or in kernel terms read_lock(current->fs->lock); current->fs->pwd->d_parent). hardlinks (of files or directories) only matters at the inode level, not at the dentry level.

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 3 lines · Andrea Arcangeli

On Mon, Jan 08, 2001 at 09:56:18PM +0100, [email protected] wrote:
Hardlinks have nothing to do with rmdir .. See rmdir . as the equivalent pointed out by Alexander: "rmdir pwd". pwd returns the same thing

You can't delete immutable directories such as . and .. Plus, don't ever dare to think of interpreting rmdir arguments. Just do what is written. rmdir . makes no sense. If someone wants rmdir pwd he's free to write just that. Of course, it's ugly because getcwd and the like are kludges, but you should only delete things you know anyhow.

Signature · 5 lines
Matthias Andree
-
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/