diff options
-rw-r--r-- | cmd/btrfs-dump-tree/main.go | 5 | ||||
-rw-r--r-- | pkg/btrfs/btrfsitem/item_blockgroup.go | 9 | ||||
-rw-r--r-- | pkg/btrfs/btrfsitem/items.txt | 1 | ||||
-rw-r--r-- | pkg/btrfs/btrfsitem/items_gen.go | 3 | ||||
-rw-r--r-- | pkg/btrfs/internal/itemtype.go | 2 |
5 files changed, 18 insertions, 2 deletions
diff --git a/cmd/btrfs-dump-tree/main.go b/cmd/btrfs-dump-tree/main.go index 6a8a7e6..52ee441 100644 --- a/cmd/btrfs-dump-tree/main.go +++ b/cmd/btrfs-dump-tree/main.go @@ -227,8 +227,9 @@ func printTree(fs *btrfs.FS, root btrfs.LogicalAddr) error { // // TODO //case btrfsitem.EXTENT_DATA_KEY: // // TODO - //case btrfsitem.BLOCK_GROUP_ITEM_KEY: - // // TODO + case btrfsitem.BlockGroup: + fmt.Printf("\t\tblock group used %d chunk_objectid %d flags %v\n", + body.Used, body.ChunkObjectID, body.Flags) //case btrfsitem.FREE_SPACE_INFO_KEY: // // TODO //case btrfsitem.FREE_SPACE_EXTENT_KEY: diff --git a/pkg/btrfs/btrfsitem/item_blockgroup.go b/pkg/btrfs/btrfsitem/item_blockgroup.go index 162adb1..565aae8 100644 --- a/pkg/btrfs/btrfsitem/item_blockgroup.go +++ b/pkg/btrfs/btrfsitem/item_blockgroup.go @@ -1,9 +1,18 @@ package btrfsitem import ( + "lukeshu.com/btrfs-tools/pkg/binstruct" + "lukeshu.com/btrfs-tools/pkg/btrfs/internal" "lukeshu.com/btrfs-tools/pkg/util" ) +type BlockGroup struct { // BLOCK_GROUP_ITEM=192 + Used int64 `bin:"off=0, siz=8"` + ChunkObjectID internal.ObjID `bin:"off=8, siz=8"` + Flags BlockGroupFlags `bin:"off=16, siz=8"` + binstruct.End `bin:"off=24"` +} + type BlockGroupFlags uint64 const ( diff --git a/pkg/btrfs/btrfsitem/items.txt b/pkg/btrfs/btrfsitem/items.txt index 0cca6df..5e9a17d 100644 --- a/pkg/btrfs/btrfsitem/items.txt +++ b/pkg/btrfs/btrfsitem/items.txt @@ -1,3 +1,4 @@ +BLOCK_GROUP_ITEM=192 BlockGroup CHUNK_ITEM=228 Chunk DEV_ITEM=216 Dev DEV_EXTENT=204 DevExtent diff --git a/pkg/btrfs/btrfsitem/items_gen.go b/pkg/btrfs/btrfsitem/items_gen.go index fc894d1..8c51875 100644 --- a/pkg/btrfs/btrfsitem/items_gen.go +++ b/pkg/btrfs/btrfsitem/items_gen.go @@ -9,6 +9,7 @@ import ( ) const ( + BLOCK_GROUP_ITEM_KEY = internal.BLOCK_GROUP_ITEM_KEY CHUNK_ITEM_KEY = internal.CHUNK_ITEM_KEY DEV_ITEM_KEY = internal.DEV_ITEM_KEY DEV_EXTENT_KEY = internal.DEV_EXTENT_KEY @@ -33,6 +34,7 @@ const ( ) var keytype2gotype = map[Type]reflect.Type{ + BLOCK_GROUP_ITEM_KEY: reflect.TypeOf(BlockGroup{}), CHUNK_ITEM_KEY: reflect.TypeOf(Chunk{}), DEV_ITEM_KEY: reflect.TypeOf(Dev{}), DEV_EXTENT_KEY: reflect.TypeOf(DevExtent{}), @@ -56,6 +58,7 @@ var keytype2gotype = map[Type]reflect.Type{ UUID_RECEIVED_SUBVOL_KEY: reflect.TypeOf(UUIDMap{}), } +func (BlockGroup) isItem() {} func (Chunk) isItem() {} func (Dev) isItem() {} func (DevExtent) isItem() {} diff --git a/pkg/btrfs/internal/itemtype.go b/pkg/btrfs/internal/itemtype.go index 5a8c10f..7f16889 100644 --- a/pkg/btrfs/internal/itemtype.go +++ b/pkg/btrfs/internal/itemtype.go @@ -7,6 +7,7 @@ import "fmt" type ItemType uint8 const ( + BLOCK_GROUP_ITEM_KEY = ItemType(192) CHUNK_ITEM_KEY = ItemType(228) DEV_ITEM_KEY = ItemType(216) DEV_EXTENT_KEY = ItemType(204) @@ -32,6 +33,7 @@ const ( func (t ItemType) String() string { names := map[ItemType]string{ + BLOCK_GROUP_ITEM_KEY: "BLOCK_GROUP_ITEM", CHUNK_ITEM_KEY: "CHUNK_ITEM", DEV_ITEM_KEY: "DEV_ITEM", DEV_EXTENT_KEY: "DEV_EXTENT", |