Re: mount does not accurately identify existing NFS mounts, and shouldn't try.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 19, 2015 at 12:08:41PM +1100, Neil Brown wrote:
> 	/* Refuse the same filesystem on the same mount point */
> 	err = -EBUSY;
> 	if (path->mnt->mnt_sb == newmnt->mnt.mnt_sb &&
> 	    path->mnt->mnt_root == path->dentry)
> 		goto unlock;
> 
> This is the *only* time that the kernel returns EBUSY for a "mount a new
> filesystem" request (remount can return EBUSY for other reasons I
> think).
> 
> So in the case where "mount" thinks it should check if the filesystem is
> already mounted and ignore the request if it is, the best thing it can
> do is to just try the mount and ignore any "EBUSY" error status - treat
> that the same as success.
> 
> So all that code for "is this the same mountpoint" can probably be
> discarded.

Well, we have many situations (another than mount -a) when you want to
know if the FS is mounted, but you have not permissions for mount(2)
or you don't want to try it (because mount(2) may trigger many another
things in userspace).

> Did I miss any important consideration there?

The problem is that the way between fstab entry and mount(2) is
sometimes pretty complex (mount.<type> helpers, loop devices,
UUID/LABEL translation, etc).

So, compare fstab with /proc/mounts is usually good compromise...

Your suggestion seems usable for mount -a, but it's one small use-case
(and for example systemd don't use "mount -a" during boot).

> Unfortunately this change could be awkward to implement as /sbin/mount
> decides whether to try the mount and (for NFS), /sbin/mount.nfs gives an
> error message if EBUSY is returned.  Would we need to pass a "noebusy"
> flag, but only if mount.nfs were willing to accept it....
> 
> Any suggestions?

We have kill(PID, 0) to detect if the PID is valid, you don't have to
parse all /proc. It would be nice to have the same for filesystems,
something like

    mount("/dev/sda1, "/mnt", "ext4", MS_NOMOUNT, NULL)

   Karel 

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux