diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2012-09-20 19:04:22 +0800 |
---|---|---|
committer | root <root@localhost.localdomain> | 2012-10-04 16:26:33 -0400 |
commit | 0f53cf81f66f4b62f68661f0d5a1a919b1db2686 (patch) | |
tree | b83753d2071dac2fb311c3598c9dcea733123a1f /cmds-subvolume.c | |
parent | 60d11eca6649700c1e39c19c36c903cad747e775 (diff) |
Btrfs-progs: introduce '-t' option into subvolume list command
This patch introduces '-t' option into subvolume list command. By this
option, we can output the result as a table.
Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Diffstat (limited to 'cmds-subvolume.c')
-rw-r--r-- | cmds-subvolume.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/cmds-subvolume.c b/cmds-subvolume.c index f5da022f..8399e72e 100644 --- a/cmds-subvolume.c +++ b/cmds-subvolume.c @@ -260,12 +260,13 @@ static int cmd_subvol_delete(int argc, char **argv) } static const char * const cmd_subvol_list_usage[] = { - "btrfs subvolume list [-pur] [-s 0|1] [-g [+|-]value] [-c [+|-]value] " + "btrfs subvolume list [-purt] [-s 0|1] [-g [+|-]value] [-c [+|-]value] " "[--sort=gen,ogen,rootid,path] <path>", "List subvolumes (and snapshots)", "", "-p print parent ID", "-u print the uuid of subvolumes (and snapshots)", + "-t print the result as a table", "-s value list snapshots with generation in ascending/descending order", " (1: ascending, 0: descending)", "-r list readonly subvolumes (including snapshots)", @@ -292,6 +293,7 @@ static int cmd_subvol_list(int argc, char **argv) int order; int c; char *subvol; + int is_tab_result = 0; struct option long_options[] = { {"sort", 1, NULL, 'S'}, {0, 0, 0, 0} @@ -303,7 +305,7 @@ static int cmd_subvol_list(int argc, char **argv) optind = 1; while(1) { c = getopt_long(argc, argv, - "ps:urg:c:", long_options, NULL); + "ps:urg:c:t", long_options, NULL); if (c < 0) break; @@ -311,6 +313,9 @@ static int cmd_subvol_list(int argc, char **argv) case 'p': btrfs_list_setup_print_column(BTRFS_LIST_PARENT); break; + case 't': + is_tab_result = 1; + break; case 's': order = atoi(optarg); btrfs_list_setup_filter(&filter_set, @@ -382,7 +387,8 @@ static int cmd_subvol_list(int argc, char **argv) return 12; } - ret = btrfs_list_subvols(fd, filter_set, comparer_set); + ret = btrfs_list_subvols(fd, filter_set, comparer_set, + is_tab_result); if (ret) return 19; return 0; @@ -588,7 +594,7 @@ static int cmd_subvol_get_default(int argc, char **argv) btrfs_list_setup_filter(&filter_set, BTRFS_LIST_FILTER_ROOTID, default_id); - ret = btrfs_list_subvols(fd, filter_set, NULL); + ret = btrfs_list_subvols(fd, filter_set, NULL, 0); if (ret) return 19; return 0; |