Btrfs-progs: ignore subvols above BTRFS_LAST_FREE_OBJECTID
[platform/upstream/btrfs-progs.git] / send-utils.c
index af495a0..b1d3873 100644 (file)
@@ -21,9 +21,7 @@
 #include "ctree.h"
 #include "send-utils.h"
 #include "ioctl.h"
-
-/* btrfs-list.c */
-char *path_for_root(int fd, u64 root);
+#include "btrfs-list.h"
 
 static struct rb_node *tree_insert(struct rb_root *root,
                                   struct subvol_info *si,
@@ -228,7 +226,7 @@ int subvol_uuid_search_init(int mnt_fd, struct subvol_uuid_search *s)
 
                        if ((sh->objectid != 5 &&
                            sh->objectid < BTRFS_FIRST_FREE_OBJECTID) ||
-                           sh->objectid == BTRFS_FREE_INO_OBJECTID)
+                           sh->objectid > BTRFS_LAST_FREE_OBJECTID)
                                goto skip;
 
                        if (sh->type == BTRFS_ROOT_ITEM_KEY) {
@@ -242,11 +240,13 @@ int subvol_uuid_search_init(int mnt_fd, struct subvol_uuid_search *s)
                                memcpy(&root_item, root_item_ptr,
                                                sizeof(root_item));
                                root_item_valid = 1;
-                       } else if (sh->type == BTRFS_ROOT_BACKREF_KEY) {
+                       } else if (sh->type == BTRFS_ROOT_BACKREF_KEY ||
+                                  root_item_valid) {
                                if (!root_item_valid)
                                        goto skip;
 
-                               path = path_for_root(mnt_fd, sh->objectid);
+                               path = btrfs_list_path_for_root(mnt_fd,
+                                                               sh->objectid);
                                if (!path)
                                        path = strdup("");
                                if (IS_ERR(path)) {
@@ -275,7 +275,6 @@ int subvol_uuid_search_init(int mnt_fd, struct subvol_uuid_search *s)
                                subvol_uuid_search_add(s, si);
                                root_item_valid = 0;
                        } else {
-                               root_item_valid = 0;
                                goto skip;
                        }