Bug 8536 - rmdir shows wrong behaviour when trying to remove a mountpoint
Summary: rmdir shows wrong behaviour when trying to remove a mountpoint
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: kernel
Version: 6.1
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Michael K. Johnson
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2000-01-17 13:49 UTC by Dmitry Pugachov
Modified: 2008-05-01 15:37 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2000-01-17 13:49:11 UTC

Attachments (Terms of Use)

Description Dmitry Pugachov 2000-01-17 13:49:11 UTC
When rmdir() is called with a mounpoint (directory with a mounted
filesystem) name as the argument, it returns ENOENT error code. It appears
that there is a bug in the do_rmdir() routine (fs/namei.c module):

        dentry = lookup_dentry(name, NULL, 0);
        dir = dget(dentry->d_parent);
        error = -ENOENT;
        if (check_parent(dir, dentry))
                error = vfs_rmdir(dir->d_inode, dentry);

lookup_dentry() will return the dentry for the root of the mounted
filesystem, thus resulting in that dir will be the same as dentry (d_parent
field of "/" points to itself). After that, check_parent() will fail
(because dir == dentry), and ENOENT will be returned.

Clearly, "no such file or directory" is not the right way to tell the user
that she's trying to rmdir() a mountpoint. Changing check_parent() to:

#define check_parent(dir, dentry) \
        ((dir) == (dentry) || (dir) == (dentry)->d_parent &&

fixes the problem, but that might cause some trouble with parent locking,
or am I wrong?

Note You need to log in before you can comment on or make changes to this bug.