diff --git a/btrfs-list.c b/btrfs-list.c index 4b95bcdf..2bf8f4cf 100644 --- a/btrfs-list.c +++ b/btrfs-list.c @@ -1528,10 +1528,14 @@ int btrfs_list_subvols_print(int fd, struct btrfs_list_filter_set *filter_set, int ret = 0; u64 top_id = 0; - if (full_path) - ret = btrfs_list_get_path_rootid(fd, &top_id); - if (ret) - return ret; + if (full_path) { + ret = lookup_path_rootid(fd, &top_id); + if (ret) { + errno = -ret; + error("cannot resolve rootid for path: %m"); + return ret; + } + } ret = btrfs_list_subvols(fd, &root_lookup); if (ret) @@ -1560,9 +1564,12 @@ int btrfs_get_toplevel_subvol(int fd, struct root_info *the_ri) struct root_info *ri; u64 root_id; - ret = btrfs_list_get_path_rootid(fd, &root_id); - if (ret) + ret = lookup_path_rootid(fd, &root_id); + if (ret) { + errno = -ret; + error("cannot resolve rootid for path: %m"); return ret; + } ret = btrfs_list_subvols(fd, &rl); if (ret) @@ -1591,9 +1598,12 @@ int btrfs_get_subvol(int fd, struct root_info *the_ri) struct root_info *ri; u64 root_id; - ret = btrfs_list_get_path_rootid(fd, &root_id); - if (ret) + ret = lookup_path_rootid(fd, &root_id); + if (ret) { + errno = -ret; + error("cannot resolve rootid for path: %m"); return ret; + } ret = btrfs_list_subvols(fd, &rl); if (ret) @@ -1809,9 +1819,12 @@ char *btrfs_list_path_for_root(int fd, u64 root) int ret; u64 top_id; - ret = btrfs_list_get_path_rootid(fd, &top_id); - if (ret) + ret = lookup_path_rootid(fd, &top_id); + if (ret) { + errno = -ret; + error("cannot resolve rootid for path: %m"); return ERR_PTR(ret); + } ret = list_subvol_search(fd, &root_lookup); if (ret < 0) diff --git a/cmds/receive.c b/cmds/receive.c index 781e3751..48c774ce 100644 --- a/cmds/receive.c +++ b/cmds/receive.c @@ -1064,9 +1064,12 @@ static int do_receive(struct btrfs_receive *rctx, const char *tomnt, * subvolume we're sitting in so that we can adjust the paths of any * subvols we want to receive in. */ - ret = btrfs_list_get_path_rootid(rctx->mnt_fd, &subvol_id); - if (ret) + ret = lookup_path_rootid(rctx->mnt_fd, &subvol_id); + if (ret) { + errno = -ret; + error("cannot resolve rootid for path: %m"); goto out; + } root_subvol_path[0] = 0; ret = btrfs_subvolid_resolve(rctx->mnt_fd, root_subvol_path, diff --git a/cmds/subvolume.c b/cmds/subvolume.c index ba21d247..f5a1230b 100644 --- a/cmds/subvolume.c +++ b/cmds/subvolume.c @@ -674,9 +674,12 @@ static int cmd_subvol_list(const struct cmd_struct *cmd, int argc, char **argv) btrfs_list_setup_filter(&filter_set, BTRFS_LIST_FILTER_FLAGS, flags); - ret = btrfs_list_get_path_rootid(fd, &top_id); - if (ret) + ret = lookup_path_rootid(fd, &top_id); + if (ret) { + errno = -ret; + error("cannot resolve rootid for path: %m"); goto out; + } if (is_list_all) btrfs_list_setup_filter(&filter_set, diff --git a/common/send-utils.c b/common/send-utils.c index 6778e2c6..a4f824e8 100644 --- a/common/send-utils.c +++ b/common/send-utils.c @@ -25,6 +25,8 @@ #include "kernel-shared/ctree.h" #include "common/send-utils.h" +#include "common/messages.h" +#include "common/utils.h" #include "ioctl.h" #include "btrfs-list.h" @@ -44,7 +46,11 @@ static int btrfs_get_root_id_by_sub_path(int mnt_fd, const char *sub_path, return ret; } - ret = btrfs_list_get_path_rootid(subvol_fd, root_id); + ret = lookup_path_rootid(subvol_fd, root_id); + if (ret) { + errno = -ret; + error("cannot resolve rootid for path: %m"); + } close(subvol_fd); return ret; }