From: Karel Zak Date: Wed, 10 Jun 2009 07:37:43 +0000 (+0200) Subject: mount: move MS_{PROPAGATION,BIND,MOVE} detection X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0fae284a7a13d4d2dba7a908e0662a6d9c46f877;p=util-linux mount: move MS_{PROPAGATION,BIND,MOVE} detection The previous commit does not properly fix the problem with "none" fstype and MS_{PROPAGATION,BIND,MOVE} flags. The real fstype has to be replaced with "none" before we try to use /sbin/mount. helper. Old version: # grep test /proc/self/mountinfo 16 18 0:19 / /mnt/test rw,relatime - tmpfs tmpfs rw # ./mount -v -v -v --make-private /mnt/test mount: fstab path: "/etc/fstab" mount: mtab path: "/etc/mtab" mount: lock path: "/etc/mtab~" mount: temp path: "/etc/mtab.tmp" mount: UID: 0 mount: eUID: 0 mount: spec: "tmpfs" mount: node: "/mnt/test" mount: types: "tmpfs" mount: opts: "rw" mount: external mount: argv[0] = "/sbin/mount.tmpfs" mount: external mount: argv[1] = "tmpfs" mount: external mount: argv[2] = "/mnt/test" mount: external mount: argv[3] = "-v" mount: external mount: argv[4] = "-o" mount: external mount: argv[5] = "rw" tmpfs on /mnt/test type tmpfs (rw) # grep test /proc/self/mountinfo 16 18 0:19 / /mnt/test rw,relatime - tmpfs tmpfs rw 17 16 0:20 / /mnt/test rw,relatime - tmpfs tmpfs rw Fixed version: # grep test /proc/self/mountinfo 16 18 0:19 / /mnt/test rw,relatime - tmpfs tmpfs rw # ./mount -v -v -v --make-private /mnt/test mount: fstab path: "/etc/fstab" mount: mtab path: "/etc/mtab" mount: lock path: "/etc/mtab~" mount: temp path: "/etc/mtab.tmp" mount: UID: 0 mount: eUID: 0 mount: spec: "tmpfs" mount: node: "/mnt/test" mount: types: "tmpfs" mount: opts: "rw" mount: mount(2) syscall: source: "tmpfs", target: "/mnt/test", filesystemtype: "none", mountflags: 262144, data: (null) # grep test /proc/self/mountinfo 16 18 0:19 / /mnt/test rw,relatime - tmpfs tmpfs rw Signed-off-by: Karel Zak --- diff --git a/mount/mount.c b/mount/mount.c index e002ebbb..c636e9dc 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -895,9 +895,6 @@ guess_fstype_and_mount(const char *spec, const char *node, const char **types, if (*types && strcasecmp (*types, "auto") == 0) *types = NULL; - if (flags & (MS_BIND | MS_MOVE | MS_PROPAGATION)) - *types = "none"; - if (!*types && !(flags & MS_REMOUNT)) { *types = guess_fstype_by_devname(spec); if (*types) { @@ -1302,6 +1299,9 @@ try_mount_one (const char *spec0, const char *node0, const char *types0, if (loop) opt_loopdev = loopdev; + if (flags & (MS_BIND | MS_MOVE | MS_PROPAGATION)) + types = "none"; + /* * Call mount.TYPE for types that require a separate mount program. * For the moment these types are ncpfs and smbfs. Maybe also vxfs.