6b9308
From e1e07c9aeacf71f3f95cbc4b2862e622962907cb Mon Sep 17 00:00:00 2001
6b9308
From: Roberto Bergantinos Corpas <rbergant@redhat.com>
6b9308
Date: Mon, 27 Apr 2020 15:46:02 +0200
6b9308
Subject: [PATCH] libmount: fix mount -a EBUSY for cifs
6b9308
6b9308
fstab:
6b9308
6b9308
 //rhel73/myshare/sub/path  /mnt   cifs
6b9308
6b9308
after mount in mountinfo:
6b9308
6b9308
 #  grep cifs /proc/self/mountinfo
6b9308
 47 39 0:40 /sub/path /mnt rw,relatime shared:60 - cifs //rhel73/myshare/sub/path ...
6b9308
            ^^^^^^^^^
6b9308
or:
6b9308
6b9308
 # grep cifs /proc/self/mountinfo
6b9308
 47 39 0:40 / /mnt rw,relatime shared:60 - cifs //rhel73/myshare/sub/path ...
6b9308
            ^
6b9308
6b9308
That is so since on kernel cifs code, cifs_get_root (which returns the
6b9308
entry associated with mnt_root) return s_root if
6b9308
CIFS_MOUNT_USE_PREFIX_PATH is set, no questions asked.
6b9308
6b9308
This situation can occurr often on CIFS mounts, as CIFS servers limit
6b9308
frequently scope of access to the root path.
6b9308
6b9308
[kzak@redhat.com: - add more info to the commit message,
6b9308
                  - clean up variable names]
6b9308
6b9308
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1826719
6b9308
Upstream: http://github.com/karelzak/util-linux/commit/31b3a523eca2fc7e5876ec5fd89094208fed0899
6b9308
Signed-off-by: Roberto Bergantinos Corpas <rbergant@redhat.com>
6b9308
Signed-off-by: Karel Zak <kzak@redhat.com>
6b9308
---
6b9308
 libmount/src/tab.c | 9 ++++++---
6b9308
 1 file changed, 6 insertions(+), 3 deletions(-)
6b9308
6b9308
diff --git a/libmount/src/tab.c b/libmount/src/tab.c
6b9308
index 575b33d8c..89c84c99b 100644
6b9308
--- a/libmount/src/tab.c
6b9308
+++ b/libmount/src/tab.c
6b9308
@@ -1181,9 +1181,12 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
6b9308
 
6b9308
 		if (root) {
6b9308
 			if (strcmp(mnt_fs_get_fstype(fs), "cifs") == 0) {
6b9308
-				const char *unc_subdir = get_cifs_unc_subdir_path(src);
6b9308
-				const char *path_on_fs = mnt_fs_get_root(fs);
6b9308
-				if (!unc_subdir || !path_on_fs || !streq_paths(unc_subdir, path_on_fs))
6b9308
+
6b9308
+				const char *sub = get_cifs_unc_subdir_path(src);
6b9308
+				const char *r = mnt_fs_get_root(fs);
6b9308
+
6b9308
+				if (!sub || !r || (!streq_paths(sub, r) &&
6b9308
+						   !streq_paths("/", r)))
6b9308
 					continue;
6b9308
 			} else {
6b9308
 				const char *r = mnt_fs_get_root(fs);
6b9308
-- 
6b9308
2.25.4
6b9308