@@ -307,6 +307,7 @@ static int cmd_subvol_list(int argc, char **argv)
int ret;
int c;
char *subvol, *mnt = NULL;
+ struct root_info ri;
int is_tab_result = 0;
int is_list_all = 0;
struct option long_options[] = {
@@ -314,6 +315,7 @@ static int cmd_subvol_list(int argc, char **argv)
{0, 0, 0, 0}
};
+ memset(&ri,'\0',sizeof(ri));
filter_set = btrfs_list_alloc_filter_set();
comparer_set = btrfs_list_alloc_comparer_set();
@@ -419,10 +421,32 @@ static int cmd_subvol_list(int argc, char **argv)
BTRFS_LIST_FILTER_TOPID_EQUAL,
top_id);
+ if (strcmp(subvol, mnt) != 0) {
+ if (btrfs_list_is_filter_set(filter_set, BTRFS_LIST_FILTER_SNAPSHOT_ONLY) >= 0) {
+ ri.full_path = subvol+strlen(mnt)+1;
+ if (btrfs_get_a_subvol(fd, &ri)) {
+ fprintf(stderr, "ERROR: can't find '%s'\n",
+ ri.full_path);
+ close(fd);
+ free(mnt);
+ return 13;
+ }
+ btrfs_list_setup_filter(&filter_set,
+ BTRFS_LIST_FILTER_BY_PARENT, (u64)&ri.uuid);
+ }
+ }
+
ret = btrfs_list_subvols(fd, filter_set, comparer_set,
is_tab_result);
free(mnt);
+ if (ri.path)
+ free(ri.path);
+ if (ri.name)
+ free(ri.name);
+ if (ri.full_path)
+ free(ri.full_path);
+
if (ret)
return 19;
return 0;