From 6699e742f238d4bc15ac396dd56f0df1480bd36c Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 2 Mar 2012 15:53:55 +0100 Subject: libmount: add mnt_fs_streq_target() and export all mnt_fs_streq_* Signed-off-by: Karel Zak --- libmount/src/tab.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'libmount/src/tab.c') diff --git a/libmount/src/tab.c b/libmount/src/tab.c index d2a954bba..9992c9cf1 100644 --- a/libmount/src/tab.c +++ b/libmount/src/tab.c @@ -438,7 +438,7 @@ struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *pat /* native @target */ mnt_reset_iter(&itr, direction); while(mnt_table_next_fs(tb, &itr, &fs) == 0) { - if (fs->target && streq_except_trailing_slash(fs->target, path)) + if (mnt_fs_streq_target(fs, path)) return fs; } if (!tb->cache || !(cn = mnt_resolve_path(path, tb->cache))) @@ -447,7 +447,7 @@ struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *pat /* canonicalized paths in struct libmnt_table */ mnt_reset_iter(&itr, direction); while(mnt_table_next_fs(tb, &itr, &fs) == 0) { - if (fs->target && strcmp(fs->target, cn) == 0) + if (mnt_fs_streq_target(fs, cn)) return fs; } @@ -461,7 +461,8 @@ struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *pat continue; p = mnt_resolve_path(fs->target, tb->cache); - if (strcmp(cn, p) == 0) + /* both canonicalized, strcmp() is fine here */ + if (p && strcmp(cn, p) == 0) return fs; } return NULL; @@ -544,7 +545,9 @@ 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 && streq_except_trailing_slash(x, cn)) + + /* both canonicalized, strcmp() is fine here */ + if (x && strcmp(x, cn) == 0) return fs; } } @@ -559,7 +562,9 @@ 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 && streq_except_trailing_slash(cn, p)) + + /* both canonicalized, strcmp() is fine here */ + if (p && strcmp(p, cn) == 0) return fs; } } @@ -853,14 +858,11 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs) mnt_reset_iter(&itr, MNT_ITER_FORWARD); while(mnt_table_next_fs(tb, &itr, &fs) == 0) { - const char *t = mnt_fs_get_target(fs), - *r = mnt_fs_get_root(fs); + const char *r = mnt_fs_get_root(fs); - if (t && r - && mnt_fs_get_srcpath(fs) + if (r && strcmp(r, root) == 0 && mnt_fs_streq_srcpath(fs, src) - && streq_except_trailing_slash(t, tgt) - && strcmp(r, root) == 0) + && mnt_fs_streq_target(fs, tgt)) break; } if (fs) -- cgit v1.2.3-55-g7522