summaryrefslogtreecommitdiffstats
path: root/libmount/src
diff options
context:
space:
mode:
authorPetr Uzel2011-11-08 16:25:01 +0100
committerKarel Zak2011-11-08 16:25:01 +0100
commitb106d052383083b80c0dc41f1555d2661db00374 (patch)
tree1a47a77f18b6935b7c67a219617091951e236d94 /libmount/src
parentlib,loopdev: add LOOP_CTL_GET_FREE support (diff)
downloadkernel-qcow2-util-linux-b106d052383083b80c0dc41f1555d2661db00374.tar.gz
kernel-qcow2-util-linux-b106d052383083b80c0dc41f1555d2661db00374.tar.xz
kernel-qcow2-util-linux-b106d052383083b80c0dc41f1555d2661db00374.zip
libmount: ignore tailing slash in netfs source paths
Addresses: https://bugzilla.novell.com/show_bug.cgi?id=728480 Signed-off-by: Petr Uzel <petr.uzel@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
-rw-r--r--libmount/src/fs.c5
-rw-r--r--libmount/src/tab.c17
-rw-r--r--libmount/src/tab_parse.c11
3 files changed, 24 insertions, 9 deletions
diff --git a/libmount/src/fs.c b/libmount/src/fs.c
index 1c7068dd0..26560d161 100644
--- a/libmount/src/fs.c
+++ b/libmount/src/fs.c
@@ -16,6 +16,7 @@
#include <stddef.h>
#include "mountP.h"
+#include "strutils.h"
/**
* mnt_new_fs:
@@ -1142,7 +1143,7 @@ int mnt_fs_match_source(struct libmnt_fs *fs, const char *source, struct libmnt_
return 0;
/* 1) native paths/tags */
- if (!strcmp(source, fs->source))
+ if (streq_except_trailing_slash(source, fs->source))
return 1;
if (!cache)
@@ -1156,7 +1157,7 @@ int mnt_fs_match_source(struct libmnt_fs *fs, const char *source, struct libmnt_
/* 2) canonicalized and native */
src = mnt_fs_get_srcpath(fs);
- if (src && !strcmp(cn, src))
+ if (src && streq_except_trailing_slash(cn, src))
return 1;
/* 3) canonicalized and canonicalized */
diff --git a/libmount/src/tab.c b/libmount/src/tab.c
index c06409d29..2bc49e3b7 100644
--- a/libmount/src/tab.c
+++ b/libmount/src/tab.c
@@ -44,6 +44,7 @@
#include <blkid.h>
#include "mountP.h"
+#include "strutils.h"
/**
* mnt_new_table:
@@ -506,7 +507,7 @@ struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *pa
if (path == NULL && src == NULL)
return fs; /* source is "none" */
- if (path && p && strcmp(p, path) == 0)
+ if (path && p && streq_except_trailing_slash(p, path))
return fs;
if (!p && src)
ntags++; /* mnt_fs_get_srcpath() returs nothing, it's TAG */
@@ -520,7 +521,7 @@ struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *pa
mnt_reset_iter(&itr, direction);
while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
p = mnt_fs_get_srcpath(fs);
- if (p && strcmp(p, cn) == 0)
+ if (p && streq_except_trailing_slash(p, cn))
return fs;
}
}
@@ -551,7 +552,7 @@ struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *pa
if (mnt_fs_get_tag(fs, &t, &v))
continue;
x = mnt_resolve_tag(t, v, tb->cache);
- if (x && !strcmp(x, cn))
+ if (x && streq_except_trailing_slash(x, cn))
return fs;
}
}
@@ -566,7 +567,7 @@ struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *pa
p = mnt_fs_get_srcpath(fs);
if (p)
p = mnt_resolve_path(p, tb->cache);
- if (p && strcmp(cn, p) == 0)
+ if (p && streq_except_trailing_slash(cn, p))
return fs;
}
}
@@ -856,8 +857,14 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
*t = mnt_fs_get_target(fs),
*r = mnt_fs_get_root(fs);
+ /*
+ * Note that kernel can add tailing slash to the
+ * network filesystem source paths.
+ */
if (t && s && r &&
- !strcmp(t, tgt) && !strcmp(s, src) && !strcmp(r, root))
+ strcmp(t, tgt) == 0 &&
+ streq_except_trailing_slash(s, src) &&
+ strcmp(r, root) == 0)
break;
}
if (fs)
diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c
index 18a124345..4ee590889 100644
--- a/libmount/src/tab_parse.c
+++ b/libmount/src/tab_parse.c
@@ -14,6 +14,7 @@
#include "mangle.h"
#include "mountP.h"
#include "pathnames.h"
+#include "strutils.h"
static inline char *skip_spaces(char *s)
{
@@ -654,8 +655,14 @@ static struct libmnt_fs *mnt_table_merge_user_fs(struct libmnt_table *tb, struct
if (fs->flags & MNT_FS_MERGED)
continue;
- if (s && t && r && !strcmp(t, target) &&
- !strcmp(s, src) && !strcmp(r, root))
+ /*
+ * Note that kernel can add tailing slash to the network
+ * filesystem source path
+ */
+ if (s && t && r &&
+ strcmp(t, target) == 0 &&
+ streq_except_trailing_slash(s, src) &&
+ strcmp(r, root) == 0)
break;
}