summaryrefslogtreecommitdiff
path: root/cmds-subvolume.c
diff options
context:
space:
mode:
authorWang Shilong <wangsl-fnst@cn.fujistu.com>2012-09-28 01:25:00 +0800
committerroot <root@localhost.localdomain>2012-10-04 16:26:33 -0400
commit8e8e019e910f20947fea7eff5da40753639d8870 (patch)
tree622bb812570502c863ad7f8fc2183d174c9f6f8d /cmds-subvolume.c
parenta1e89891eb6af5381539d9875b85c196150171b6 (diff)
Btrfs-progs: introduces '-a' option into subvolume list command
We list the subvolumes under current directory according to the input subvolume. However, if we still want to list all the subvolumes in the tree, we can use '-a' option to help us. There may be two kinds of path: absolute path , relative path . The absolute path is beginning with "<FS_TREE>" The relative path is under current path that you input. Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Diffstat (limited to 'cmds-subvolume.c')
-rw-r--r--cmds-subvolume.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index b96af3eb..3b4edb63 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -260,11 +260,12 @@ static int cmd_subvol_delete(int argc, char **argv)
}
static const char * const cmd_subvol_list_usage[] = {
- "btrfs subvolume list [-purt] [-s 0|1] [-g [+|-]value] [-c [+|-]value] "
+ "btrfs subvolume list [-apurt] [-s 0|1] [-g [+|-]value] [-c [+|-]value] "
"[--sort=gen,ogen,rootid,path] <path>",
"List subvolumes (and snapshots)",
"",
"-p print parent ID",
+ "-a print all the subvolumes in the filesystem.",
"-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",
@@ -295,6 +296,7 @@ static int cmd_subvol_list(int argc, char **argv)
int c;
char *subvol;
int is_tab_result = 0;
+ int is_list_all = 0;
struct option long_options[] = {
{"sort", 1, NULL, 'S'},
{0, 0, 0, 0}
@@ -306,7 +308,7 @@ static int cmd_subvol_list(int argc, char **argv)
optind = 1;
while(1) {
c = getopt_long(argc, argv,
- "ps:urg:c:t", long_options, NULL);
+ "aps:urg:c:t", long_options, NULL);
if (c < 0)
break;
@@ -314,6 +316,9 @@ static int cmd_subvol_list(int argc, char **argv)
case 'p':
btrfs_list_setup_print_column(BTRFS_LIST_PARENT);
break;
+ case 'a':
+ is_list_all = 1;
+ break;
case 't':
is_tab_result = 1;
break;
@@ -389,9 +394,10 @@ static int cmd_subvol_list(int argc, char **argv)
}
top_id = btrfs_list_get_path_rootid(fd);
- btrfs_list_setup_filter(&filter_set,
- BTRFS_LIST_FILTER_TOPID_EQUAL,
- top_id);
+ if (!is_list_all)
+ btrfs_list_setup_filter(&filter_set,
+ BTRFS_LIST_FILTER_TOPID_EQUAL,
+ top_id);
ret = btrfs_list_subvols(fd, filter_set, comparer_set,
is_tab_result);