@@ -1323,6 +1323,26 @@ static int __list_subvol_fill_paths(int fd, struct root_lookup *root_lookup)
return 0;
}
+static int btrfs_get_subvols(int fd, struct root_lookup *root_lookup)
+{
+ int ret;
+
+ ret = __list_subvol_search(fd, root_lookup);
+ if (ret) {
+ fprintf(stderr, "ERROR: can't perform the search - %s\n",
+ strerror(errno));
+ return ret;
+ }
+
+ /*
+ * now we have an rbtree full of root_info objects, but we need to fill
+ * in their path names within the subvol that is referencing each one.
+ */
+ ret = __list_subvol_fill_paths(fd, root_lookup);
+
+ return ret;
+}
+
static void print_subvolume_column(struct root_info *subv,
enum btrfs_list_column_enum column)
{
@@ -1471,20 +1491,7 @@ int btrfs_list_subvols(int fd, struct btrfs_list_filter_set *filter_set,
struct root_lookup root_sort;
int ret;
- ret = __list_subvol_search(fd, &root_lookup);
- if (ret) {
- fprintf(stderr, "ERROR: can't perform the search - %s\n",
- strerror(errno));
- return ret;
- }
-
- /*
- * now we have an rbtree full of root_info objects, but we need to fill
- * in their path names within the subvol that is referencing each one.
- */
- ret = __list_subvol_fill_paths(fd, &root_lookup);
- if (ret < 0)
- return ret;
+ ret = btrfs_get_subvols(fd, &root_lookup);
__filter_and_sort_subvol(&root_lookup, &root_sort, filter_set,
comp_set, fd);