aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelien Aptel <aaptel@suse.com>2016-09-01 13:57:42 +0200
committerKarel Zak <kzak@redhat.com>2016-09-29 11:51:38 +0200
commit76d4fba2e47808264f5c4c883127b0d275e31949 (patch)
treedc940371737371e051e9b0b2c659c01216a0c825
parentf20b214edc6e0c422a9a8991929fb793ee543dda (diff)
downloadutil-linux-76d4fba2e47808264f5c4c883127b0d275e31949.tar.gz
libmount: fix mount -a for cifs
when mounting a cifs share, the src is actually an UNC path which can in in several forms: simple: //host/share, //host/share/ including subpath: //host/share/sub/path to check if the cifs fs is mounted we have to extract the subpath and compare *that* to the root. Signed-off-by: Aurelien Aptel <aaptel@suse.com>
-rw-r--r--libmount/src/tab.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/libmount/src/tab.c b/libmount/src/tab.c
index 341e5e343e..9c49ec885b 100644
--- a/libmount/src/tab.c
+++ b/libmount/src/tab.c
@@ -1329,6 +1329,20 @@ err:
}
#endif /* HAVE_BTRFS_SUPPORT */
+static const char *get_cifs_unc_subdir_path (const char *unc)
+{
+ /*
+ * 1 or more slash: %*[/]
+ * 1 or more non-slash: %*[^/]
+ * number of byte read: %n
+ */
+ int share_end = 0;
+ int r = sscanf(unc, "%*[/]%*[^/]%*[/]%*[^/]%n", &share_end);
+ if (r == EOF || share_end == 0)
+ return NULL;
+ return unc + share_end;
+}
+
/*
* tb: /proc/self/mountinfo
* fs: filesystem
@@ -1563,9 +1577,16 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
}
if (root) {
- const char *r = mnt_fs_get_root(fs);
- if (!r || strcmp(r, root) != 0)
- continue;
+ if (strcmp(mnt_fs_get_fstype(fs), "cifs") == 0) {
+ const char *unc_subdir = get_cifs_unc_subdir_path(src);
+ const char *path_on_fs = mnt_fs_get_root(fs);
+ if (!unc_subdir || !path_on_fs || !streq_paths(unc_subdir, path_on_fs))
+ continue;
+ } else {
+ const char *r = mnt_fs_get_root(fs);
+ if (!r || strcmp(r, root) != 0)
+ continue;
+ }
}
/*