From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH 1/4] btrfs-progs: Remove fprintf() in find_mount_root().
Date: Wed, 23 Jul 2014 13:47:34 +0800 [thread overview]
Message-ID: <1406094457-3100-1-git-send-email-quwenruo@cn.fujitsu.com> (raw)
find_mount_root() function in utils.c should not print error string.
Caller should be responsible to print error string.
This patch will remove the only fprintf in find_mount_root() and modify
the caller a little to use strerror() to prompt users.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
cmds-receive.c | 4 ++--
cmds-send.c | 4 ++--
utils.c | 6 +-----
3 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/cmds-receive.c b/cmds-receive.c
index 48380a5..72afe2a 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -980,9 +980,9 @@ static int do_receive(struct btrfs_receive *r, const char *tomnt, int r_fd,
ret = find_mount_root(dest_dir_full_path, &r->root_path);
if (ret < 0) {
- ret = -EINVAL;
fprintf(stderr, "ERROR: failed to determine mount point "
- "for %s\n", dest_dir_full_path);
+ "for %s: %s\n", dest_dir_full_path, strerror(-ret));
+ ret = -EINVAL;
goto out;
}
r->mnt_fd = open(r->root_path, O_RDONLY | O_NOATIME);
diff --git a/cmds-send.c b/cmds-send.c
index 9a73b32..48c3df4 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -356,9 +356,9 @@ static int init_root_path(struct btrfs_send *s, const char *subvol)
ret = find_mount_root(subvol, &s->root_path);
if (ret < 0) {
- ret = -EINVAL;
fprintf(stderr, "ERROR: failed to determine mount point "
- "for %s\n", subvol);
+ "for %s: %s\n", subvol, strerror(-ret));
+ ret = -EINVAL;
goto out;
}
diff --git a/utils.c b/utils.c
index 11250d9..2d0f18e 100644
--- a/utils.c
+++ b/utils.c
@@ -2422,12 +2422,8 @@ int find_mount_root(const char *path, char **mount_root)
}
endmntent(mnttab);
- if (!longest_match) {
- fprintf(stderr,
- "ERROR: Failed to find mount root for path %s.\n",
- path);
+ if (!longest_match)
return -ENOENT;
- }
ret = 0;
*mount_root = realpath(longest_match, NULL);
--
2.0.2
next reply other threads:[~2014-07-23 5:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-23 5:47 Qu Wenruo [this message]
2014-07-23 5:47 ` [PATCH v2 2/4] btrfs-progs: Check fstype in find_mount_root() Qu Wenruo
2014-07-29 13:57 ` David Sterba
2014-07-23 5:47 ` [PATCH 3/4] btrfs-progs: Fix wrong indent in btrfs-progs Qu Wenruo
2014-07-23 5:47 ` [PATCH v3 4/4] btrfs-progs: Add mount point output for 'btrfs fi df' Qu Wenruo
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=1406094457-3100-1-git-send-email-quwenruo@cn.fujitsu.com \
--to=quwenruo@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).