diff mbox

[1/4] Btrfs-progs: introduce btrfs_get_subvols function

Message ID 1350019254-22036-2-git-send-email-Anand.Jain@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Anand Jain Oct. 12, 2012, 5:20 a.m. UTC
From: Anand Jain <anand.jain@oracle.com>

Having this not part of btrfs_list_subvols will help
code reuse.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 btrfs-list.c |   35 +++++++++++++++++++++--------------
 1 files changed, 21 insertions(+), 14 deletions(-)
diff mbox

Patch

diff --git a/btrfs-list.c b/btrfs-list.c
index 20da828..657e4db 100644
--- a/btrfs-list.c
+++ b/btrfs-list.c
@@ -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);