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