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