linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand jain <Anand.Jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 4/5] Btrfs-progs: make provision to print subvol list tree format
Date: Sat, 15 Dec 2012 19:52:07 +0800	[thread overview]
Message-ID: <1355572328-32281-5-git-send-email-Anand.Jain@oracle.com> (raw)
In-Reply-To: <1355572328-32281-1-git-send-email-Anand.Jain@oracle.com>

From: Anand Jain <anand.jain@oracle.com>

Currently we have default (name <value>) and table format to
list the subvol. This patch will help to accommodate the
enhancement to provide the tree display for the subvol-snapshot
list.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 btrfs-list.c     |   34 ++++++++++++++++++++++------------
 cmds-subvolume.c |    6 +++---
 2 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/btrfs-list.c b/btrfs-list.c
index 45d8d05..571efd0 100644
--- a/btrfs-list.c
+++ b/btrfs-list.c
@@ -1444,22 +1444,32 @@ static void print_all_volume_info_tab_head()
 }
 
 static void print_all_volume_info(struct root_lookup *sorted_tree,
-				  int is_tab_result)
+				int layout)
 {
 	struct rb_node *n;
 	struct root_info *entry;
 
-	if (is_tab_result)
+	switch (layout) {
+	case 0: // default: name <value>
+		n = rb_first(&sorted_tree->root);
+		while (n) {
+			entry = rb_entry(n, struct root_info, sort_node);
+			print_single_volume_info_default(entry);
+			n = rb_next(n);
+		}
+		break;
+	case 1: // table
 		print_all_volume_info_tab_head();
-
-	n = rb_first(&sorted_tree->root);
-	while (n) {
-		entry = rb_entry(n, struct root_info, sort_node);
-		if (is_tab_result)
+		n = rb_first(&sorted_tree->root);
+		while (n) {
+			entry = rb_entry(n, struct root_info, sort_node);
 			print_single_volume_info_table(entry);
-		else
-			print_single_volume_info_default(entry);
-		n = rb_next(n);
+			n = rb_next(n);
+		}
+		break;
+	default:
+		printf("ERROR: default switch print_all_volume_info\n");
+		return;
 	}
 }
 
@@ -1484,7 +1494,7 @@ int btrfs_list_subvols(int fd, struct root_lookup *root_lookup)
 
 int btrfs_list_subvols_print(int fd, struct btrfs_list_filter_set *filter_set,
 		       struct btrfs_list_comparer_set *comp_set,
-		       int is_tab_result)
+		       int layout)
 {
 	struct root_lookup root_lookup;
 	struct root_lookup root_sort;
@@ -1496,7 +1506,7 @@ int btrfs_list_subvols_print(int fd, struct btrfs_list_filter_set *filter_set,
 	__filter_and_sort_subvol(&root_lookup, &root_sort, filter_set,
 				 comp_set, fd);
 
-	print_all_volume_info(&root_sort, is_tab_result);
+	print_all_volume_info(&root_sort, layout);
 	__free_all_subvolumn(&root_lookup);
 
 	return 0;
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index b481a3b..411a5de 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -306,7 +306,7 @@ static int cmd_subvol_list(int argc, char **argv)
 	int ret;
 	int c;
 	char *subvol;
-	int is_tab_result = 0;
+	int layout = 0;
 	int is_list_all = 0;
 	struct option long_options[] = {
 		{"sort", 1, NULL, 'S'},
@@ -331,7 +331,7 @@ static int cmd_subvol_list(int argc, char **argv)
 			is_list_all = 1;
 			break;
 		case 't':
-			is_tab_result = 1;
+			layout = 1;
 			break;
 		case 's':
 			btrfs_list_setup_filter(&filter_set,
@@ -410,7 +410,7 @@ static int cmd_subvol_list(int argc, char **argv)
 					top_id);
 
 	ret = btrfs_list_subvols_print(fd, filter_set, comparer_set,
-				is_tab_result);
+				layout);
 	if (ret)
 		return 19;
 	return 0;
-- 
1.7.1


  parent reply	other threads:[~2012-12-15 11:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-15 11:52 [PATCH 0/5] add tree format display for btrfs subvol list subcommand Anand jain
2012-12-15 11:52 ` [PATCH 1/5] Btrfs-progs: add parent uuid for snapshots Anand jain
2012-12-15 11:52 ` [PATCH 2/5] Btrfs-progs: maintain similar case in heading prefix Anand jain
2012-12-15 11:52 ` [PATCH 3/5] Btrfs-progs: Move printing outside of btrfs_list_subvols Anand jain
2012-12-15 11:52 ` Anand jain [this message]
2012-12-15 11:52 ` [PATCH 5/5] Btrfs-progs: Add -x option to btrfs subvol list to display snapshots in tree format Anand jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1355572328-32281-5-git-send-email-Anand.Jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).