diff options
author | Dave Reisner | 2012-03-02 04:46:59 +0100 |
---|---|---|
committer | Karel Zak | 2012-03-02 09:42:18 +0100 |
commit | eac83fbcf6476f82aca86fe9b69f60c3a9a43d92 (patch) | |
tree | 2131202e05bad5ef76ed05703c702c27ceaf7390 /sys-utils/mountpoint.c | |
parent | wipefs: always print devname (diff) | |
download | kernel-qcow2-util-linux-eac83fbcf6476f82aca86fe9b69f60c3a9a43d92.tar.gz kernel-qcow2-util-linux-eac83fbcf6476f82aca86fe9b69f60c3a9a43d92.tar.xz kernel-qcow2-util-linux-eac83fbcf6476f82aca86fe9b69f60c3a9a43d92.zip |
mountpoint: account for error from in mnt_fs_get_target
commit 04f087ec didn't take into consideration that mnt_fs_get_target()
could return an error, and would therefore show false positives, such
as:
$ mkdir foo; mountpoint foo
foo is a mountpoint
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'sys-utils/mountpoint.c')
-rw-r--r-- | sys-utils/mountpoint.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sys-utils/mountpoint.c b/sys-utils/mountpoint.c index bd9266759..a45cabdcc 100644 --- a/sys-utils/mountpoint.c +++ b/sys-utils/mountpoint.c @@ -45,6 +45,7 @@ static int dir_to_device(const char *spec, dev_t *dev) struct libmnt_table *tb = mnt_new_table_from_file("/proc/self/mountinfo"); struct libmnt_fs *fs; struct libmnt_cache *cache; + int rc = -1; if (!tb) { /* @@ -82,12 +83,14 @@ static int dir_to_device(const char *spec, dev_t *dev) mnt_table_set_cache(tb, cache); fs = mnt_table_find_target(tb, spec, MNT_ITER_BACKWARD); - if (fs && mnt_fs_get_target(fs)) + if (fs && mnt_fs_get_target(fs)) { *dev = mnt_fs_get_devno(fs); + rc = 0; + } mnt_free_table(tb); mnt_free_cache(cache); - return 0; + return rc; } static int print_devno(const char *devname, struct stat *st) |