@@ -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);
@@ -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;
}
@@ -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);
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(-)