@@ -719,7 +719,7 @@ static int __list_subvol_fill_paths(int fd, struct root_lookup *root_lookup)
return 0;
}
-int list_subvols(int fd, int print_parent, int get_default)
+int list_subvols(int fd, int print_parent, int get_default, char *mntp)
{
struct root_lookup root_lookup;
struct rb_node *n;
@@ -779,14 +779,14 @@ int list_subvols(int fd, int print_parent, int get_default)
resolve_root(&root_lookup, entry, &parent_id, &level, &path);
if (print_parent) {
- printf("ID %llu parent %llu top level %llu path %s\n",
+ printf("ID %llu parent %llu top level %llu path %s/%s\n",
(unsigned long long)entry->root_id,
(unsigned long long)parent_id,
- (unsigned long long)level, path);
+ (unsigned long long)level, mntp, path);
} else {
- printf("ID %llu top level %llu path %s\n",
+ printf("ID %llu top level %llu path %s/%s\n",
(unsigned long long)entry->root_id,
- (unsigned long long)level, path);
+ (unsigned long long)level, mntp, path);
}
free(path);
@@ -31,7 +31,7 @@
#include "commands.h"
/* btrfs-list.c */
-int list_subvols(int fd, int print_parent, int get_default);
+int list_subvols(int fd, int print_parent, int get_default, char *mntp);
int find_updated_files(int fd, u64 root_id, u64 oldest_gen);
static const char * const subvolume_cmd_group_usage[] = {
@@ -274,6 +274,7 @@ static int cmd_subvol_list(int argc, char **argv)
int ret;
int print_parent = 0;
char *subvol;
+ char *mntp = NULL;
optind = 1;
while(1) {
@@ -310,7 +311,9 @@ static int cmd_subvol_list(int argc, char **argv)
fprintf(stderr, "ERROR: can't access '%s'\n", subvol);
return 12;
}
- ret = list_subvols(fd, print_parent, 0);
+ find_mount_root(subvol, &mntp);
+ ret = list_subvols(fd, print_parent, 0, mntp);
+ free(mntp);
if (ret)
return 19;
return 0;
@@ -470,6 +473,7 @@ static int cmd_subvol_get_default(int argc, char **argv)
int fd;
int ret;
char *subvol;
+ char *mntp = NULL;
if (check_argc_exact(argc, 2))
usage(cmd_subvol_get_default_usage);
@@ -491,7 +495,9 @@ static int cmd_subvol_get_default(int argc, char **argv)
fprintf(stderr, "ERROR: can't access '%s'\n", subvol);
return 12;
}
- ret = list_subvols(fd, 0, 1);
+ find_mount_root(subvol, &mntp);
+ ret = list_subvols(fd, 0, 1, mntp);
+ free(mntp);
if (ret)
return 19;
return 0;