bugSystem V style init programs - Bugs: bug #37114, mountpoint returns false for bind...


bug #37114: mountpoint returns false for bind mounts

Submitted by:  None
Submitted on:  Wed 15 Aug 2012 11:00:59 PM UTC  
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Jesse <newguy>
Open/Closed: Closed

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Wed 07 Mar 2018 08:28:55 PM UTC, comment #2:

Update, I found a way to work around this on Linux. We can find circular or grandparent binds on Linux using /proc/mounts. I have added this function as an option using the -p flag. It's not enabled by default as this seems to be a corner case. But if you think you're dealing with circular mount binds, -p will fix the issue.

Jesse <newguy>
Project MemberIn charge of this item.
Wed 07 Mar 2018 06:39:14 PM UTC, comment #1:

I confirmed the mount test script does return the wrong result when we mount ".." under the current directory, creating a loop in the file system.

mountpoint does correctly handle other situations though, like binding /home to another location such as /opt.

I think mountpoint is only failing because we check ".." to compare its device and inode against the target. In other words if we are testing the directory /a/b/c and /a/b/c is a bind back to /a/b, we check the device and inode for /a/b/c and then compare it to /a/b/c/.. which is the same as /a/b.

So mountpoint will always (or only) fail when we are checking a mountpoint which is binded to its parent.

We could, in theory, work around this by checking system data like /proc/mounts, but that would be a lot of working around for one special case which should probably never be used in practise. Binding a mount point to a parent directory isn't exactly a good/common practise. And it would mean mountpoint is less portable. Instead, I propose the manual page be updated to mention this corner case as a possible bug/limitation.

Jesse <newguy>
Project MemberIn charge of this item.
Wed 15 Aug 2012 11:00:59 PM UTC, original submission:

If you use mount --bind, then mountpoint won't recognize that the directory is a mount point, since stat returns the same device number for both.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #26365:  mountpointtest-bind.sh added by None (242B - application/x-shellscript)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by newguy (Posted a comment)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 07 Mar 2018 08:28:55 PM UTCnewguyStatusConfirmed=>Fixed
    Wed 07 Mar 2018 06:39:14 PM UTCnewguyStatusNone=>Confirmed
      Assigned toNone=>newguy
    Wed 15 Aug 2012 11:00:59 PM UTCNoneAttached File-=>Added mountpointtest-bind.sh, #26365

    Back to the top

    Powered by Savane 3.1-cleanup1