diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2012-09-18 17:14:37 +0800 |
---|---|---|
committer | root <root@localhost.localdomain> | 2012-10-04 16:26:33 -0400 |
commit | 3defb823843ac6071e38dbd89603344885e7a8aa (patch) | |
tree | 2ac9ece7912fc942c76cc25333a21aec78f66f21 /cmds-subvolume.c | |
parent | 162df1e30c7c0492ae9fb551d74452e643f5fea2 (diff) |
Btrfs-progs: enhance btrfs subvol list only to show read-only snapshots
We want 'btrfs subvolume list' only to list readonly subvolumes, this patch set
introduces a new option 'r' to implement it.
You can use the command like that:
btrfs subvolume list -r <path>
Original-Signed-off-by: Zhou Bo <zhoub-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 | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/cmds-subvolume.c b/cmds-subvolume.c index 59f4dfdd..f385816f 100644 --- a/cmds-subvolume.c +++ b/cmds-subvolume.c @@ -259,13 +259,14 @@ static int cmd_subvol_delete(int argc, char **argv) } static const char * const cmd_subvol_list_usage[] = { - "btrfs subvolume list [-pu] [-s 0|1] <path>", + "btrfs subvolume list [-pur] [-s 0|1] <path>", "List subvolumes (and snapshots)", "", "-p print parent ID", "-u print the uuid of subvolumes (and snapshots)", "-s value list snapshots with generation in ascending/descending order", " (1: ascending, 0: descending)", + "-r list readonly subvolumes (including snapshots)", NULL }; @@ -273,6 +274,7 @@ static int cmd_subvol_list(int argc, char **argv) { struct btrfs_list_filter_set *filter_set; struct btrfs_list_comparer_set *comparer_set; + u64 flags = 0; int fd; int ret; int order; @@ -283,7 +285,7 @@ static int cmd_subvol_list(int argc, char **argv) optind = 1; while(1) { - int c = getopt(argc, argv, "ps:u"); + int c = getopt(argc, argv, "ps:ur"); if (c < 0) break; @@ -305,11 +307,18 @@ static int cmd_subvol_list(int argc, char **argv) case 'u': btrfs_list_setup_print_column(BTRFS_LIST_UUID); break; + case 'r': + flags |= BTRFS_ROOT_SUBVOL_RDONLY; + break; default: usage(cmd_subvol_list_usage); } } + if (flags) + btrfs_list_setup_filter(&filter_set, BTRFS_LIST_FILTER_FLAGS, + flags); + if (check_argc_exact(argc - optind, 1)) usage(cmd_subvol_list_usage); |