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

 
 

bug #37114: mountpoint returns false for bind mounts

Submitter:  None
Submitted:  Wed 15 Aug 2012 11:00:59 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  newguy
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group administrator
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>
Group administrator
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.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

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
  • -email is unavailable- added by newguy (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-03-07 newguy StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2018-03-07 newguy StatusNone Confirmed
        Assigned toNone newguy
    2012-08-15 None Attached File- Added mountpointtest-bind.sh, #26365

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code