Skip to content
Permalink
Browse files

btrfs-progs: add -P option to only list parent subvolumes

  • Loading branch information
hhoffstaette committed Sep 9, 2016
1 parent bde6873 commit f0a065e02bc472d293cbb38c4f9bf2f0981f3042
Showing with 14 additions and 1 deletion.
  1. +6 −0 btrfs-list.c
  2. +1 −0 btrfs-list.h
  3. +7 −1 cmds-subvolume.c
@@ -1175,6 +1175,11 @@ static int filter_deleted(struct root_info *ri, u64 data)
return ri->deleted;
}

static int filter_parent_subvol_only(struct root_info *ri, u64 data)
{
return uuid_is_null(ri->puuid);
}

static btrfs_list_filter_func all_filter_funcs[] = {
[BTRFS_LIST_FILTER_ROOTID] = filter_by_rootid,
[BTRFS_LIST_FILTER_SNAPSHOT_ONLY] = filter_snapshot,
@@ -1189,6 +1194,7 @@ static btrfs_list_filter_func all_filter_funcs[] = {
[BTRFS_LIST_FILTER_FULL_PATH] = filter_full_path,
[BTRFS_LIST_FILTER_BY_PARENT] = filter_by_parent,
[BTRFS_LIST_FILTER_DELETED] = filter_deleted,
[BTRFS_LIST_FILTER_PARENT_SUBVOL_ONLY] = filter_parent_subvol_only,
};

struct btrfs_list_filter_set *btrfs_list_alloc_filter_set(void)
@@ -142,6 +142,7 @@ enum btrfs_list_filter_enum {
BTRFS_LIST_FILTER_FULL_PATH,
BTRFS_LIST_FILTER_BY_PARENT,
BTRFS_LIST_FILTER_DELETED,
BTRFS_LIST_FILTER_PARENT_SUBVOL_ONLY,
BTRFS_LIST_FILTER_MAX,
};

@@ -404,6 +404,7 @@ static const char * const cmd_subvol_list_usage[] = {
"-q print the parent uuid of the snapshots",
"-R print the uuid of the received snapshots",
"-t print the result as a table",
"-P list parent subvolumes only",
"-s list snapshots only in the filesystem",
"-r list readonly subvolumes (including snapshots)",
"-d list deleted subvolumes that are not yet cleaned",
@@ -445,7 +446,7 @@ static int cmd_subvol_list(int argc, char **argv)
};

c = getopt_long(argc, argv,
"acdgopqsurRG:C:t", long_options, NULL);
"acdgopPqsurRG:C:t", long_options, NULL);
if (c < 0)
break;

@@ -473,6 +474,11 @@ static int cmd_subvol_list(int argc, char **argv)
case 't':
is_tab_result = 1;
break;
case 'P':
btrfs_list_setup_filter(&filter_set,
BTRFS_LIST_FILTER_PARENT_SUBVOL_ONLY,
0);
break;
case 's':
btrfs_list_setup_filter(&filter_set,
BTRFS_LIST_FILTER_SNAPSHOT_ONLY,

0 comments on commit f0a065e

Please sign in to comment.
You can’t perform that action at this time.