Hello,
> When an entry was added to the subvol search tree, the root_id was
> always 0 (not set at all) and therefore only the first one was
> added, all the others had been ignored. This commit adds a function
> to retrieve the root_id for a given fd, and this function is used
> to set the root_id before the entry is added.
>
> Signed-off-by: Stefan Behrens <sbehrens@xxxxxxxxxxxxxxxx>
> ---
> cmds-receive.c | 3 +++
> send-utils.c | 20 ++++++++++++++++++++
> send-utils.h | 1 +
> 3 files changed, 24 insertions(+)
>
> diff --git a/cmds-receive.c b/cmds-receive.c
> index dc72e9e..eedff13 100644
> --- a/cmds-receive.c
> +++ b/cmds-receive.c
> @@ -125,6 +125,9 @@ static int finish_subvol(struct btrfs_receive *r)
> goto out;
> }
>
> + ret = btrfs_get_root_id(subvol_fd, &r->cur_subvol->root_id);
There has been a function in btrfs-list.c named 'btrfs_list_get_path_rootid'
which does the same things as 'btrfs_get_root_id'.I think you can reuse it.
Thanks,
Wang
> + if (ret < 0)
> + goto out;
> subvol_uuid_search_add(&r->sus, r->cur_subvol);
> r->cur_subvol = NULL;
> ret = 0;
> diff --git a/send-utils.c b/send-utils.c
> index 182778a..b2d544c 100644
> --- a/send-utils.c
> +++ b/send-utils.c
> @@ -23,6 +23,26 @@
> #include "ioctl.h"
> #include "btrfs-list.h"
>
> +int btrfs_get_root_id(int fd, u64 *root_id)
> +{
> + struct btrfs_ioctl_ino_lookup_args ino_args;
> + int ret;
> +
> + memset(&ino_args, 0, sizeof(ino_args));
> + ino_args.objectid = BTRFS_FIRST_FREE_OBJECTID;
> +
> + /* this ioctl fills in ino_args->treeid */
> + ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &ino_args);
> + if (ret) {
> + fprintf(stderr, "ERROR: Failed to lookup root_id - %s\n",
> + strerror(errno));
> + return ret;
> + }
> +
> + *root_id = ino_args.treeid;
> + return 0;
> +}
> +
> static struct rb_node *tree_insert(struct rb_root *root,
> struct subvol_info *si,
> enum subvol_search_type type)
> diff --git a/send-utils.h b/send-utils.h
> index 78abf94..3c8b7b7 100644
> --- a/send-utils.h
> +++ b/send-utils.h
> @@ -61,6 +61,7 @@ struct subvol_uuid_search {
> struct rb_root path_subvols;
> };
>
> +int btrfs_get_root_id(int fd, u64 *root_id);
> int subvol_uuid_search_init(int mnt_fd, struct subvol_uuid_search *s);
> void subvol_uuid_search_finit(struct subvol_uuid_search *s);
> struct subvol_info *subvol_uuid_search(struct subvol_uuid_search *s,
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html