summaryrefslogtreecommitdiff
path: root/testing/util-linux/libmount-canonicalize-targets-from-fstab-on-mount-a.patch
blob: 46ff5526044b8a8ee6bbc5b8c262c6a16de8d677 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From 6eba938376c2c870d9258ef9d7b6a3690cfa78dd Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 24 Feb 2012 22:52:45 +0100
Subject: [PATCH 11/12] libmount: canonicalize targets from fstab on mount -a

Signed-off-by: Karel Zak <kzak@redhat.com>
---
 libmount/src/tab.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libmount/src/tab.c b/libmount/src/tab.c
index 66a9e4d..21b05c7 100644
--- a/libmount/src/tab.c
+++ b/libmount/src/tab.c
@@ -830,8 +830,8 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
 {
 	char *root = NULL;
 	struct libmnt_fs *src_fs;
-	const char *src, *tgt;
-	char *xsrc = NULL;
+	const char *src;
+	char *xsrc = NULL, *tgt;
 	int flags = 0, rc = 0;
 
 	assert(tb);
@@ -852,7 +852,7 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
 		src = xsrc = mnt_resolve_spec(mnt_fs_get_source(fstab_fs),
 					      tb->cache);
 
-	tgt = mnt_fs_get_target(fstab_fs);
+	tgt = mnt_resolve_path(mnt_fs_get_target(fstab_fs), tb->cache);
 
 	if (tgt && src && root) {
 		struct libmnt_iter itr;
@@ -870,7 +870,7 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
 			 * network filesystem source paths.
 			 */
 			if (t && s && r &&
-			    strcmp(t, tgt) == 0 &&
+			    streq_except_trailing_slash(t, tgt) &&
 			    streq_except_trailing_slash(s, src) &&
 			    strcmp(r, root) == 0)
 				break;
@@ -881,6 +881,8 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
 
 	if (xsrc && !tb->cache)
 		free(xsrc);
+	if (!tb->cache)
+		free(tgt);
 
 	free(root);
 	return rc;
-- 
1.7.9.2