dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

Blame SOURCES/0041-libmount-fix-mount-a-EBUSY-for-cifs.patch

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