All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libmount: Skip root comparison for cifs in mnt_table_is_fs_mounted()
@ 2016-08-01 16:25 Stanislav Brabec
  2016-08-03 17:23   ` Stanislav Brabec
  0 siblings, 1 reply; 16+ messages in thread
From: Stanislav Brabec @ 2016-08-01 16:25 UTC (permalink / raw)
  To: util-linux

In mountinfo of cifs filesystem, root is filled with a relative path to the root
of the exported volume. There is no reasonable way to compare it without making
a network look-up.

This causes false negative result in some cases.

Skipping root comparison in mnt_table_is_fs_mounted() makes things better,
however it still does not cover all possible setups.

How to reproduce:
1) Create and export a cifs volume (with guest allowed).
2) Make a subdirectory in this volume.
3) Mount this subdirectory using fstab:
   //server/volume/subdir /mnt cifs guest 0 0
4) Call mount -a twice.
   Depending on a system running, you either get:
     mount error(16): Device or resource busy
     Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
   or you get a volume mounted twice.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
---
 libmount/src/tab.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libmount/src/tab.c b/libmount/src/tab.c
index 155c65e..aa9185a 100644
--- a/libmount/src/tab.c
+++ b/libmount/src/tab.c
@@ -1562,7 +1562,10 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
 #endif
 		}
 
-		if (root) {
+		/* For cifs, root contains a relative path to the exported volume,
+		 * i. e. something we cannot compare.
+		 */
+		if (root && strcmp(mnt_fs_get_fstype(fs), "cifs")) {
 			const char *r = mnt_fs_get_root(fs);
 			if (!r || strcmp(r, root) != 0)
 				continue;
-- 
2.9.2

-- 
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                         e-mail: sbrabec@suse.com
Křižíkova 148/34 (Corso IIa)                  tel: +49 911 7405384547
186 00 Praha 8-Karlín                          fax:  +420 284 084 001
Czech Republic                                    http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-09-29  9:55 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-01 16:25 [PATCH] libmount: Skip root comparison for cifs in mnt_table_is_fs_mounted() Stanislav Brabec
2016-08-03 17:23 ` nfs/cifs mountinfo differences (was: Re: [PATCH] libmount: Skip root comparison for cifs in mnt_table_is_fs_mounted()) Stanislav Brabec
2016-08-03 17:23   ` Stanislav Brabec
     [not found]   ` <5eb96b3e-d463-bf11-49de-f614247d6b29-AlSwsSmVLrQ@public.gmane.org>
2016-08-03 20:32     ` Steve French
2016-08-05 17:22   ` Aurélien Aptel
2016-08-05 17:22     ` Aurélien Aptel
2016-08-16 17:44     ` nfs/cifs mountinfo differences Stanislav Brabec
2016-08-16 17:44       ` Stanislav Brabec
2016-08-23 17:23       ` Stanislav Brabec
2016-08-23 17:23         ` Stanislav Brabec
2016-08-23 17:25         ` [PATCH] libmount: Special handling of root comparison for cifs in mnt_table_is_fs_mounted() Stanislav Brabec
2016-08-23 17:25           ` Stanislav Brabec
2016-09-02 18:58           ` Aurélien Aptel
2016-09-02 18:58             ` Aurélien Aptel
2016-09-29  9:55             ` Karel Zak
2016-09-29  9:55               ` Karel Zak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.