libmount/tab: always trust the source of a pseudofs
PATCH 1/2 libmount/tab: always trust the source of a pseudofs
Since nodev FSs have no backing block device, it's unreasonable to try and resolve the source back to a path on the filesystem. Always trust the source of the FS given in /etc/fstab to avoid remounting the device when a directory of the same name exists in the current working directory.
Example reproduction:
# mkdir /foo # echo 'foo /foo tmpfs defaults 0 0' >> /etc/fstab # mount -a # cd /root; mkdir foo # mount -a # mount | grep /foo foo on /foo type tmpfs (rw,relatime) /root/foo on /foo type tmpfs (rw,relatime)
--- libmount/src/tab.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
libmount/src/tab.c +3 -0
@@ -45,6 +45,7 @@#include "mountP.h" #include "strutils.h" +#include "utils.h" /** * mnt_new_table:
@@ -841,6 +842,8 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs) src_fs =mnt_table_get_fs_root (tb, fstab_fs, flags, &root);if (src_fs) src =mnt_fs_get_srcpath (src_fs); +else if (mnt_fstype_is_pseudofs (mnt_fs_get_fstype (fstab_fs))) + src =mnt_fs_get_source (fstab_fs);else src =mnt_resolve_spec (mnt_fs_get_source (fstab_fs), tb->cache);
Signature · 1 line
1.7.8.1
PATCH 2/2 libmount/context: avoid resolving pseudofs source on update
Similar to the previous commit, when mounting a pseudofs, trust the source of the fs, as it cannot be matched to backing device on the filesystem.
Similar situation, but slightly different bug:
# mkdir /foo /root/foo # echo 'foo /foo tmpfs defaults 0 0' >> /etc/fstab # cd /root # mount -a # mount | grep /foo /root/foo on /foo type tmpfs (rw,relatime)
This fixes the pure libmount based mount utility, but the legacy mount tool will still fail to handle this properly.
---
Two things:
- Since this touched a different file than the previous commit, I thought it best to keep them separate. Karel, if you disagree, I'm happy to rebase for you.
- Legacy mount has defeated me. Uggh.
libmount/src/context.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
libmount/src/context.c +3 -1
@@ -32,6 +32,7 @@*/ #include "mountP.h" +#include "utils.h" #include <sys/wait.h>
@@ -1105,7 +1106,8 @@ int mnt_context_prepare_srcpath(struct libmnt_context *cxt)/* * Source is PATH (canonicalize) */ - path =mnt_resolve_path (src, cache); +if (!mnt_fstype_is_pseudofs (mnt_fs_get_fstype (cxt->fs))) + path =mnt_resolve_path (src, cache);if (path &&strcmp (path, src)) rc =mnt_fs_set_source (cxt->fs, path); }
Signature · 1 line
1.7.8.1
Re: [PATCH 2/2] libmount/context: avoid resolving pseudofs source on update
Quoted 2 lines · Dave Reisner
libmount/src/context.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
PATCH 1/1 mount: don't canonicalize the source of a pseudofs
In reply to Dave ReisnerIn line with previous patches, the source of a pseudofs is strictly semantic; do not attempt to resolve it to a filesystem path.
As a side effect of this, nspec needs to be initialized to NULL since it may not be assigned null by spec_to_devname when the FS is deemed a pseudofs.
---
This wasn't as evil as I thought, after all...
mount/mount.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
mount/mount.c +3 -2
@@ -2016,7 +2016,7 @@ is_existing_file (const char *s) {static int mount_one (const char *spec,const char *node,const char *types,const char *fstabopts,char *cmdlineopts,int freq,int pass) { -const char *nspec; +const char *nspec =NULL ;char *opts;/* Substitute values in opts, if required */
@@ -2046,7 +2046,8 @@ mount_one (const char *spec, const char *node, const char *types, strncmp(types, "nfs", 3) && strncmp(types, "cifs", 4) && strncmp(types, "smbfs", 5))) { - nspec =spec_to_devname (spec); +if (!is_pseudo_fs (types)) + nspec =spec_to_devname (spec);if (nspec) spec = nspec; }
Signature · 1 line
1.7.8.1
Karel Zak
maintainerRe: [PATCH] mount: don't canonicalize the source of a pseudofs
Quoted 28 lines · Dave Reisner
In line with previous patches, the source of a pseudofs is strictly semantic; do not attempt to resolve it to a filesystem path.
As a side effect of this, nspec needs to be initialized to NULL since it may not be assigned null by
spec_to_devnamewhen the FS is deemed a pseudofs.Signed-off-by Dave Reisner <[email protected]>---
This wasn't as evil as I thought, after all...mount/mount.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)mount/mount.c +1
-1@@ -2016,7 +2016,7 @@ is_existing_file (const char *s) {static int mount_one (const char *spec,const char *node,const char *types,const char *fstabopts,char *cmdlineopts,int freq,int pass) { -const char *nspec; +const char *nspec =NULL ;char *opts;/* Substitute values in opts, if required */
mount/mount.c mount_one (const char *spec, const char *node, const char *types, · line 2050
Quoted 6 lines
mount/mount.c +2
-1@@ -2046,7 +2046,8 @@ mount_one (const char *spec, const char *node, const char *types, strncmp(types, "nfs", 3) && strncmp(types, "cifs", 4) && strncmp(types, "smbfs", 5))) { - nspec =spec_to_devname (spec); +if (!is_pseudo_fs (types)) + nspec =spec_to_devname (spec);
Exactly this is implemented in spec_to_devname(), it does not canonicalize pseudo filesystems.
Quoted 11 lines
mount/mount.c +0
-0if (nspec) spec = nspec; }Signature · 6 lines
1.7.8.1 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Re: [PATCH] mount: don't canonicalize the source of a pseudofs
In reply to Dave ReisnerQuoted 2 lines · Dave Reisner
mount/mount.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Quoted 2 lines · Dave Reisner
libmount/src/tab.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com