From d4aa2bc07e8d0ed3fb5b87c67ae2f2228178de82 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Mon, 31 Oct 2016 13:56:28 +0100 Subject: btrfs-progs: subvol show: print more details about toplevel subvolume The toplevel subvolume is special and the other listing code leaves it out so we have to add several special cases to handle it. There's no backreference so the path is built artificially. New helper btrfs_get_toplevel_subvol is a reduced version of btrfs_get_subvol. There's some information usually missing for the toplevel subvolume, eg. the uuid or creation info. This has to be fixed on the mkfs side, the other subvolumes are created by kernel. Example: /mnt Name: UUID: - Parent UUID: - Received UUID: - Creation time: - Subvolume ID: 5 Generation: 233 Gen at creation: 0 Parent ID: 0 Top level ID: 0 Flags: - Snapshot(s): subv1 Signed-off-by: David Sterba --- utils.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'utils.c') diff --git a/utils.c b/utils.c index e10d199f..9c2e4eb7 100644 --- a/utils.c +++ b/utils.c @@ -4168,18 +4168,13 @@ int get_subvol_info(const char *fullpath, struct root_info *get_ri) if (mntfd < 0) goto out; - if (sv_id == BTRFS_FS_TREE_OBJECTID) { - ret = 2; - /* - * So that caller may decide if thats an error or just fine. - */ - goto out; - } - memset(get_ri, 0, sizeof(*get_ri)); get_ri->root_id = sv_id; - ret = btrfs_get_subvol(mntfd, get_ri); + if (sv_id == BTRFS_FS_TREE_OBJECTID) + ret = btrfs_get_toplevel_subvol(mntfd, get_ri); + else + ret = btrfs_get_subvol(mntfd, get_ri); if (ret) error("can't find '%s': %d", svpath, ret); -- cgit v1.2.3