From: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
To: linux-btrfs@vger.kernel.org
Cc: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Subject: [PATCH 1/4] btrfs-progs: judge the return value of check_mounted more accurately
Date: Thu, 20 Feb 2014 10:49:03 +0800 [thread overview]
Message-ID: <1392864546-545-1-git-send-email-guihc.fnst@cn.fujitsu.com> (raw)
For btrfs-convert, btrfstune, btrfs rescue, they report "device busy"
when given a device that does not actually exist e.g.
# btrfstune -x abcdefg (this device does not exist)
$ ...device busy...
We deal with this case by add "ret < 0" error check when
judging the return value of check_mounted.
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
---
btrfs-convert.c | 7 ++++++-
btrfstune.c | 7 ++++++-
cmds-rescue.c | 14 +++++++++++---
3 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/btrfs-convert.c b/btrfs-convert.c
index 1b66de7..a8b2c51 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -2729,7 +2729,12 @@ int main(int argc, char *argv[])
}
file = argv[optind];
- if (check_mounted(file)) {
+ ret = check_mounted(file);
+ if (ret < 0) {
+ fprintf(stderr, "Could not check mount status: %s\n",
+ strerror(-ret));
+ return 1;
+ } else if (ret) {
fprintf(stderr, "%s is mounted\n", file);
return 1;
}
diff --git a/btrfstune.c b/btrfstune.c
index da82f36..2e623f3 100644
--- a/btrfstune.c
+++ b/btrfstune.c
@@ -151,7 +151,12 @@ int main(int argc, char *argv[])
return 1;
}
- if (check_mounted(device)) {
+ ret = check_mounted(device);
+ if (ret < 0) {
+ fprintf(stderr, "Could not check mount status: %s\n",
+ strerror(-ret));
+ return 1;
+ } else if (ret) {
fprintf(stderr, "%s is mounted\n", device);
return 1;
}
diff --git a/cmds-rescue.c b/cmds-rescue.c
index e18eb98..f20a206 100644
--- a/cmds-rescue.c
+++ b/cmds-rescue.c
@@ -80,9 +80,13 @@ int cmd_chunk_recover(int argc, char *argv[])
file = argv[optind];
ret = check_mounted(file);
- if (ret) {
+ if (ret < 0) {
+ fprintf(stderr, "Could not check mount status: %s\n",
+ strerror(-ret));
+ return 1;
+ } else if (ret) {
fprintf(stderr, "the device is busy\n");
- return ret;
+ return 1;
}
ret = btrfs_recover_chunk_tree(file, verbose, yes);
@@ -133,7 +137,11 @@ int cmd_super_recover(int argc, char **argv)
dname = argv[optind];
ret = check_mounted(dname);
- if (ret) {
+ if (ret < 0) {
+ fprintf(stderr, "Could not check mount status: %s\n",
+ strerror(-ret));
+ return 1;
+ } else if (ret) {
fprintf(stderr, "the device is busy\n");
return 1;
}
--
1.8.1.4
next reply other threads:[~2014-02-20 2:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-20 2:49 Gui Hecheng [this message]
2014-02-20 2:49 ` [PATCH 2/4] btrfs-progs: fix segment fault when exec btrfs-debug-tree as non-root Gui Hecheng
2014-02-20 8:48 ` Mike Fleetwood
2014-02-20 9:59 ` Gui Hecheng
2014-02-20 2:49 ` [PATCH 3/4] btrfs-progs: fix wrong error msg for exec btrfsck " Gui Hecheng
2014-02-20 2:49 ` [PATCH 4/4] btrfs-progs: clean the unnecessary error msg of btrfs-file-show Gui Hecheng
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=1392864546-545-1-git-send-email-guihc.fnst@cn.fujitsu.com \
--to=guihc.fnst@cn.fujitsu.com \
--cc=linux-btrfs@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;
as well as URLs for NNTP newsgroup(s).