btrfs-progs: Remove fprintf() in find_mount_root().
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Wed, 23 Jul 2014 05:47:34 +0000 (13:47 +0800)
committerDavid Sterba <dsterba@suse.cz>
Fri, 22 Aug 2014 13:07:02 +0000 (15:07 +0200)
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>
Signed-off-by: David Sterba <dsterba@suse.cz>
cmds-receive.c
cmds-send.c
utils.c

index 87dc1b4..20b3db0 100644 (file)
@@ -842,9 +842,10 @@ 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) {
+               fprintf(stderr,
+                       "ERROR: failed to determine mount point for %s: %s\n",
+                       dest_dir_full_path, strerror(-ret));
                ret = -EINVAL;
-               fprintf(stderr, "ERROR: failed to determine mount point "
-                       "for %s\n", dest_dir_full_path);
                goto out;
        }
        r->mnt_fd = open(r->root_path, O_RDONLY | O_NOATIME);
index 0e5bb54..9ec52dc 100644 (file)
@@ -349,9 +349,10 @@ static int init_root_path(struct btrfs_send *s, const char *subvol)
 
        ret = find_mount_root(subvol, &s->root_path);
        if (ret < 0) {
+               fprintf(stderr,
+                       "ERROR: failed to determine mount point for %s: %s\n",
+                       subvol, strerror(-ret));
                ret = -EINVAL;
-               fprintf(stderr, "ERROR: failed to determine mount point "
-                               "for %s\n", subvol);
                goto out;
        }
 
diff --git a/utils.c b/utils.c
index 18034e1..3d467c5 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -2356,12 +2356,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);