From 79cb12dde9352331c15724b7d0892fd4ce5ea342 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 12 Feb 2023 13:14:43 -0700 Subject: btrfsitem, btrfsinspect/print_tree: Implement the QGroup types --- lib/btrfsprogs/btrfsinspect/print_tree.go | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'lib/btrfsprogs') diff --git a/lib/btrfsprogs/btrfsinspect/print_tree.go b/lib/btrfsprogs/btrfsinspect/print_tree.go index 62d1d7b..3fc3a3f 100644 --- a/lib/btrfsprogs/btrfsinspect/print_tree.go +++ b/lib/btrfsprogs/btrfsinspect/print_tree.go @@ -291,12 +291,26 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri "\t\tchunk_tree_uuid %v\n", body.ChunkTree, body.ChunkObjectID, body.ChunkOffset, body.Length, body.ChunkTreeUUID) - // case btrfsitem.QGROUP_STATUS_KEY: - // // TODO - // case btrfsitem.QGROUP_INFO_KEY: - // // TODO - // case btrfsitem.QGROUP_LIMIT_KEY: - // // TODO + case btrfsitem.QGroupStatus: + textui.Fprintf(out, ""+ + "\t\tversion %v generation %v flags %v scan %d\n", + body.Version, body.Generation, body.Flags, body.RescanProgress) + case btrfsitem.QGroupInfo: + textui.Fprintf(out, ""+ + "\t\tgeneration %v\n"+ + "\t\treferenced %d referenced_compressed %d\n"+ + "\t\texclusive %d exclusive_compressed %d\n", + body.Generation, + body.ReferencedBytes, body.ReferencedBytesCompressed, + body.ExclusiveBytes, body.ExclusiveBytesCompressed) + case btrfsitem.QGroupLimit: + textui.Fprintf(out, ""+ + "\t\tflags %x\n"+ + "\t\tmax_referenced %d max_exclusive %d\n"+ + "\t\trsv_referenced %d rsv_exclusive %d\n", + uint64(body.Flags), + body.MaxReferenced, body.MaxExclusive, + body.RsvReferenced, body.RsvExclusive) case btrfsitem.UUIDMap: textui.Fprintf(out, "\t\tsubvol_id %d\n", body.ObjID) // case btrfsitem.STRING_ITEM_KEY: @@ -426,8 +440,8 @@ func fmtKey(key btrfsprim.Key) string { var out strings.Builder textui.Fprintf(&out, "key (%v %v", key.ObjectID.Format(key.ItemType), key.ItemType) switch key.ItemType { - case btrfsitem.QGROUP_RELATION_KEY: // TODO, btrfsitem.QGROUP_INFO_KEY, btrfsitem.QGROUP_LIMIT_KEY: - panic("TODO: printing qgroup items not yet implemented") + case btrfsitem.QGROUP_RELATION_KEY, btrfsitem.QGROUP_INFO_KEY, btrfsitem.QGROUP_LIMIT_KEY: + textui.Fprintf(&out, " %v)", btrfsprim.ObjID(key.Offset).Format(btrfsprim.QGROUP_RELATION_KEY)) case btrfsitem.UUID_SUBVOL_KEY, btrfsitem.UUID_RECEIVED_SUBVOL_KEY: textui.Fprintf(&out, " %#08x)", key.Offset) case btrfsitem.ROOT_ITEM_KEY: -- cgit v1.2.3-2-g168b