From: Dave Reisner <d@falconindy.com>
To: util-linux@vger.kernel.org
Cc: Dave Reisner <dreisner@archlinux.org>
Subject: [PATCH 1/2] mountpoint: account for error from in mnt_fs_get_target
Date: Thu, 1 Mar 2012 22:46:59 -0500 [thread overview]
Message-ID: <1330660020-32542-1-git-send-email-dreisner@archlinux.org> (raw)
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>
---
sys-utils/mountpoint.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/sys-utils/mountpoint.c b/sys-utils/mountpoint.c
index bd92667..a45cabd 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)
--
1.7.9.2
next reply other threads:[~2012-03-02 3:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-02 3:46 Dave Reisner [this message]
2012-03-02 3:47 ` [PATCH 2/2] libmount: don't treat "none" differently Dave Reisner
2012-03-02 12:39 ` Karel Zak
2012-03-02 8:58 ` [PATCH 1/2] mountpoint: account for error from in mnt_fs_get_target Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1330660020-32542-1-git-send-email-dreisner@archlinux.org \
--to=d@falconindy.com \
--cc=dreisner@archlinux.org \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox