diff options
author | Karel Zak | 2012-03-02 15:53:55 +0100 |
---|---|---|
committer | Karel Zak | 2012-03-02 15:53:55 +0100 |
commit | 6699e742f238d4bc15ac396dd56f0df1480bd36c (patch) | |
tree | 97461a5025b8e3dfda498a79b26367ca89ffcef6 /libmount/src/fs.c | |
parent | blkid: add DEVNAME= to export output format (diff) | |
download | kernel-qcow2-util-linux-6699e742f238d4bc15ac396dd56f0df1480bd36c.tar.gz kernel-qcow2-util-linux-6699e742f238d4bc15ac396dd56f0df1480bd36c.tar.xz kernel-qcow2-util-linux-6699e742f238d4bc15ac396dd56f0df1480bd36c.zip |
libmount: add mnt_fs_streq_target() and export all mnt_fs_streq_*
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/fs.c')
-rw-r--r-- | libmount/src/fs.c | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/libmount/src/fs.c b/libmount/src/fs.c index ba57dabb3..167d7acef 100644 --- a/libmount/src/fs.c +++ b/libmount/src/fs.c @@ -350,22 +350,48 @@ int mnt_fs_set_source(struct libmnt_fs *fs, const char *source) return rc; } +/** + * mnt_fs_streq_srcpath: + * @fs: fs + * @path: source path + * + * Compares @fs source path with @path. The tailing slash is ignored. + * See also mnt_fs_match_source(). + * + * Returns: 1 if @fs source path equal to @path, otherwise 0. + */ int mnt_fs_streq_srcpath(struct libmnt_fs *fs, const char *path) { - const char *p = mnt_fs_get_srcpath(fs); + const char *p; - if (p == NULL && path == NULL) - return 1; - if (p == NULL || path == NULL) + if (!fs) return 0; - if (mnt_fs_is_pseudofs(fs)) - /* don't think about pseudo-fs source as about path */ - return strcmp(p, path) == 0; + p = mnt_fs_get_srcpath(fs); - return streq_except_trailing_slash(p, path); + if (!mnt_fs_is_pseudofs(fs)) + return streq_except_trailing_slash(p, path); + + if (!p && !path) + return 1; + + return p && path && strcmp(p, path) == 0; } +/** + * mnt_fs_streq_target: + * @fs: fs + * @path: mount point + * + * Compares @fs target path with @path. The tailing slash is ignored. + * See also mnt_fs_match_target(). + * + * Returns: 1 if @fs target path equal to @path, otherwise 0. + */ +int mnt_fs_streq_target(struct libmnt_fs *fs, const char *path) +{ + return fs && streq_except_trailing_slash(mnt_fs_get_target(fs), path); +} /** * mnt_fs_get_tag: @@ -1128,7 +1154,7 @@ int mnt_fs_match_target(struct libmnt_fs *fs, const char *target, return 0; /* 1) native paths */ - rc = !strcmp(target, fs->target); + rc = mnt_fs_streq_target(fs, target); if (!rc && cache) { /* 2) - canonicalized and non-canonicalized */ |