VFS flaw - was: cannot delete directory

Andries.Brouwer@cwi.nl
Sun, 3 Oct 1999 19:07:12 +0200 (MET DST)


Brian May wrote:

# rmdir /path/name
rmdir: /path/name: No such file or directory

in a situation where ls was quite willing to list /path/name.
This is a rather confusing error message, and I consider it
a kernel bug to return ENOENT for names that do exist when
one wants to do something other than removing them.

The reason this happens is the code

error = -ENOENT;
if (check_parent(dir, dentry))
error = vfs_rmdir(dir->d_inode, dentry);

in namei.c:do_rmdir().
Indeed, check_parent() was supposed to only check for races,
but it will always fail for mount points.
The patch below will give "Device or resource busy" instead
of "No such file or directory" when trying to rmdir a mount point.

Andries

===============================================================
--- ../../../linux-2.2.12/linux/fs/namei.c Thu May 13 00:23:36 1999
+++ ./namei.c Sun Oct 3 18:48:00 1999
@@ -555,6 +555,8 @@
* on removing (or moving) the same entry: the
* parent lock will serialize them, but the
* other process will be too late..
+ *
+ * Note that check_parent will fail for mount points.
*/
#define check_parent(dir, dentry) \
((dir) == (dentry)->d_parent && !list_empty(&dentry->d_hash))
@@ -974,6 +976,10 @@

error = -ENOENT;
if (!dentry->d_inode)
+ goto exit_dput;
+
+ error = -EBUSY;
+ if (dentry->d_covers != dentry)
goto exit_dput;

dir = dget(dentry->d_parent);

-
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/