Bug 8536 - rmdir shows wrong behaviour when trying to remove a mountpoint
rmdir shows wrong behaviour when trying to remove a mountpoint
Product: Red Hat Linux
Classification: Retired
Component: kernel (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Michael K. Johnson
Depends On:
  Show dependency treegraph
Reported: 2000-01-17 08:49 EST by Dmitry Pugachov
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2000-01-17 08:49:11 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Dmitry Pugachov 2000-01-17 08:49:11 EST
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.