@@ -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;
@@ -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;