From 3825cf60fd652f22acc438d50028701d27a7402d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 1 Jun 2022 01:27:19 -0600 Subject: wow --- pkg/btrfs/btrfsitem/item_chunk.go | 62 +++++++++++ pkg/btrfs/btrfsitem/item_dev.go | 29 +++++ pkg/btrfs/btrfsitem/item_devextent.go | 15 +++ pkg/btrfs/btrfsitem/item_empty.go | 9 ++ pkg/btrfs/btrfsitem/item_inode.go | 27 +++++ pkg/btrfs/btrfsitem/item_inoderef.go | 12 ++ pkg/btrfs/btrfsitem/item_orphan.go | 9 ++ pkg/btrfs/btrfsitem/item_persistent.go | 19 ++++ pkg/btrfs/btrfsitem/item_root.go | 50 +++++++++ pkg/btrfs/btrfsitem/item_uuid.go | 39 +++++++ pkg/btrfs/btrfsitem/items.go | 20 ++++ pkg/btrfs/btrfsitem/items.go.bak | 193 +++++++++++++++++++++++++++++++++ pkg/btrfs/btrfsitem/items.txt | 12 ++ 13 files changed, 496 insertions(+) create mode 100644 pkg/btrfs/btrfsitem/item_chunk.go create mode 100644 pkg/btrfs/btrfsitem/item_dev.go create mode 100644 pkg/btrfs/btrfsitem/item_devextent.go create mode 100644 pkg/btrfs/btrfsitem/item_empty.go create mode 100644 pkg/btrfs/btrfsitem/item_inode.go create mode 100644 pkg/btrfs/btrfsitem/item_inoderef.go create mode 100644 pkg/btrfs/btrfsitem/item_orphan.go create mode 100644 pkg/btrfs/btrfsitem/item_persistent.go create mode 100644 pkg/btrfs/btrfsitem/item_root.go create mode 100644 pkg/btrfs/btrfsitem/item_uuid.go create mode 100644 pkg/btrfs/btrfsitem/items.go create mode 100644 pkg/btrfs/btrfsitem/items.go.bak create mode 100644 pkg/btrfs/btrfsitem/items.txt (limited to 'pkg/btrfs/btrfsitem') diff --git a/pkg/btrfs/btrfsitem/item_chunk.go b/pkg/btrfs/btrfsitem/item_chunk.go new file mode 100644 index 0000000..41706c3 --- /dev/null +++ b/pkg/btrfs/btrfsitem/item_chunk.go @@ -0,0 +1,62 @@ +package btrfsitem + +import ( + "lukeshu.com/btrfs-tools/pkg/binstruct" + "lukeshu.com/btrfs-tools/pkg/btrfs/btrfstyp" +) + +type Chunk struct { // CHUNK_ITEM=228 + // Maps logical address to physical. + Size uint64 `bin:"off=0x0, siz=0x8"` // size of chunk (bytes) + Owner btrfstyp.ObjID `bin:"off=0x8, siz=0x8"` // root referencing this chunk (2) + StripeLen uint64 `bin:"off=0x10, siz=0x8"` // stripe length + Type uint64 `bin:"off=0x18, siz=0x8"` // type (same as flags for block group?) + IOOptimalAlign uint32 `bin:"off=0x20, siz=0x4"` // optimal io alignment + IOOptimalWidth uint32 `bin:"off=0x24, siz=0x4"` // optimal io width + IoMinSize uint32 `bin:"off=0x28, siz=0x4"` // minimal io size (sector size) + NumStripes uint16 `bin:"off=0x2c, siz=0x2"` // number of stripes + SubStripes uint16 `bin:"off=0x2e, siz=0x2"` // sub stripes + binstruct.End `bin:"off=0x30"` + Stripes []ChunkStripe `bin:"-"` +} + +type ChunkStripe struct { + // Stripes follow (for each number of stripes): + DeviceID btrfstyp.ObjID `bin:"off=0, siz=8"` // device ID + Offset uint64 `bin:"off=8, siz=8"` // offset + DeviceUUID btrfstyp.UUID `bin:"off=10, siz=10"` // device UUID + binstruct.End `bin:"off=20"` +} + +func (chunk *Chunk) UnmarshalBinary(dat []byte) (int, error) { + n, err := binstruct.UnmarshalWithoutInterface(dat, chunk) + if err != nil { + return n, err + } + for i := 0; i < int(chunk.NumStripes); i++ { + var stripe ChunkStripe + _n, err := binstruct.Unmarshal(dat[n:], &stripe) + n += _n + if err != nil { + return n, err + } + chunk.Stripes = append(chunk.Stripes, stripe) + } + return n, nil +} + +func (chunk Chunk) MarshalBinary() ([]byte, error) { + chunk.NumStripes = uint16(len(chunk.Stripes)) + ret, err := binstruct.MarshalWithoutInterface(chunk) + if err != nil { + return ret, err + } + for _, stripe := range chunk.Stripes { + _ret, err := binstruct.Marshal(stripe) + ret = append(ret, _ret...) + if err != nil { + return ret, err + } + } + return ret, nil +} diff --git a/pkg/btrfs/btrfsitem/item_dev.go b/pkg/btrfs/btrfsitem/item_dev.go new file mode 100644 index 0000000..f474156 --- /dev/null +++ b/pkg/btrfs/btrfsitem/item_dev.go @@ -0,0 +1,29 @@ +package btrfsitem + +import ( + "lukeshu.com/btrfs-tools/pkg/binstruct" + "lukeshu.com/btrfs-tools/pkg/btrfs/btrfstyp" +) + +type Dev struct { // DEV_ITEM=216 + DeviceID btrfstyp.ObjID `bin:"off=0x0, siz=0x8"` // device ID + + NumBytes uint64 `bin:"off=0x8, siz=0x8"` // number of bytes + NumBytesUsed uint64 `bin:"off=0x10, siz=0x8"` // number of bytes used + + IOOptimalAlign uint32 `bin:"off=0x18, siz=0x4"` // optimal I/O align + IOOptimalWidth uint32 `bin:"off=0x1c, siz=0x4"` // optimal I/O width + IOMinSize uint32 `bin:"off=0x20, siz=0x4"` // minimal I/O size (sector size) + + Type uint64 `bin:"off=0x24, siz=0x8"` // type + Generation btrfstyp.Generation `bin:"off=0x2c, siz=0x8"` // generation + StartOffset uint64 `bin:"off=0x34, siz=0x8"` // start offset + DevGroup uint32 `bin:"off=0x3c, siz=0x4"` // dev group + SeekSpeed uint8 `bin:"off=0x40, siz=0x1"` // seek speed + Bandwidth uint8 `bin:"off=0x41, siz=0x1"` // bandwidth + + DevUUID btrfstyp.UUID `bin:"off=0x42, siz=0x10"` // device UUID + FSUUID btrfstyp.UUID `bin:"off=0x52, siz=0x10"` // FS UUID + + binstruct.End `bin:"off=0x62"` +} diff --git a/pkg/btrfs/btrfsitem/item_devextent.go b/pkg/btrfs/btrfsitem/item_devextent.go new file mode 100644 index 0000000..4bdd1c3 --- /dev/null +++ b/pkg/btrfs/btrfsitem/item_devextent.go @@ -0,0 +1,15 @@ +package btrfsitem + +import ( + "lukeshu.com/btrfs-tools/pkg/binstruct" + "lukeshu.com/btrfs-tools/pkg/btrfs/btrfstyp" +) + +type DevExtent struct { // DEV_EXTENT=204 + ChunkTree int64 `bin:"off=0, siz=8"` + ChunkObjectID btrfstyp.ObjID `bin:"off=8, siz=8"` + ChunkOffset int64 `bin:"off=16, siz=8"` + Length int64 `bin:"off=24, siz=8"` + ChunkTreeUUID btrfstyp.UUID `bin:"off=32, siz=16"` + binstruct.End `bin:"off=48"` +} diff --git a/pkg/btrfs/btrfsitem/item_empty.go b/pkg/btrfs/btrfsitem/item_empty.go new file mode 100644 index 0000000..ed0f66f --- /dev/null +++ b/pkg/btrfs/btrfsitem/item_empty.go @@ -0,0 +1,9 @@ +package btrfsitem + +import ( + "lukeshu.com/btrfs-tools/pkg/binstruct" +) + +type Empty struct { // UNTYPED=0, QGROUP_RELATION=246 + binstruct.End `bin:"off=48"` +} diff --git a/pkg/btrfs/btrfsitem/item_inode.go b/pkg/btrfs/btrfsitem/item_inode.go new file mode 100644 index 0000000..0c7600e --- /dev/null +++ b/pkg/btrfs/btrfsitem/item_inode.go @@ -0,0 +1,27 @@ +package btrfsitem + +import ( + "lukeshu.com/btrfs-tools/pkg/binstruct" + "lukeshu.com/btrfs-tools/pkg/btrfs/btrfstyp" +) + +type Inode struct { // INODE_ITEM=1 + Generation int64 `bin:"off=0x0, siz=0x8"` + TransID int64 `bin:"off=0x8, siz=0x8"` + Size int64 `bin:"off=0x10, siz=0x8"` + NumBytes int64 `bin:"off=0x18, siz=0x8"` + BlockGroup int64 `bin:"off=0x20, siz=0x8"` + NLink int32 `bin:"off=0x28, siz=0x4"` + UID int32 `bin:"off=0x2C, siz=0x4"` + GID int32 `bin:"off=0x30, siz=0x4"` + Mode int32 `bin:"off=0x34, siz=0x4"` + RDev int64 `bin:"off=0x38, siz=0x8"` + Flags uint64 `bin:"off=0x40, siz=0x8"` + Sequence int64 `bin:"off=0x48, siz=0x8"` + Reserved [4]int64 `bin:"off=0x50, siz=0x20"` + ATime btrfstyp.Time `bin:"off=0x70, siz=0xc"` + CTime btrfstyp.Time `bin:"off=0x7c, siz=0xc"` + MTime btrfstyp.Time `bin:"off=0x88, siz=0xc"` + OTime btrfstyp.Time `bin:"off=0x94, siz=0xc"` + binstruct.End `bin:"off=0xa0"` +} diff --git a/pkg/btrfs/btrfsitem/item_inoderef.go b/pkg/btrfs/btrfsitem/item_inoderef.go new file mode 100644 index 0000000..5a271ae --- /dev/null +++ b/pkg/btrfs/btrfsitem/item_inoderef.go @@ -0,0 +1,12 @@ +package btrfsitem + +import ( + "lukeshu.com/btrfs-tools/pkg/binstruct" +) + +type InodeRef struct { // INODE_REF=12 + Index int64 `bin:"off=0x0, siz=0x8"` + NameLen int16 `bin:"off=0x8, siz=0x2"` + binstruct.End `bin:"off=0xa"` + Name []byte `bin:"-"` +} diff --git a/pkg/btrfs/btrfsitem/item_orphan.go b/pkg/btrfs/btrfsitem/item_orphan.go new file mode 100644 index 0000000..6cf29b0 --- /dev/null +++ b/pkg/btrfs/btrfsitem/item_orphan.go @@ -0,0 +1,9 @@ +package btrfsitem + +import ( + "lukeshu.com/btrfs-tools/pkg/binstruct" +) + +type Orphan struct { // ORPHAN_ITEM=48 + binstruct.End `bin:"off=0"` +} diff --git a/pkg/btrfs/btrfsitem/item_persistent.go b/pkg/btrfs/btrfsitem/item_persistent.go new file mode 100644 index 0000000..3221800 --- /dev/null +++ b/pkg/btrfs/btrfsitem/item_persistent.go @@ -0,0 +1,19 @@ +package btrfsitem + +import ( + "lukeshu.com/btrfs-tools/pkg/binstruct" +) + +const ( + DEV_STAT_WRITE_ERRS = iota + DEV_STAT_READ_ERRS + DEV_STAT_FLUSH_ERRS + DEV_STAT_CORRUPTION_ERRS + DEV_STAT_GENERATION_ERRS + DEV_STAT_VALUES_MAX +) + +type DevStats struct { // PERSISTENT_ITEM=249 + Values [DEV_STAT_VALUES_MAX]int64 `bin:"off=0, siz=40"` + binstruct.End `bin:"off=40"` +} diff --git a/pkg/btrfs/btrfsitem/item_root.go b/pkg/btrfs/btrfsitem/item_root.go new file mode 100644 index 0000000..c87a49b --- /dev/null +++ b/pkg/btrfs/btrfsitem/item_root.go @@ -0,0 +1,50 @@ +package btrfsitem + +import ( + "lukeshu.com/btrfs-tools/pkg/binstruct" + "lukeshu.com/btrfs-tools/pkg/btrfs/btrfstyp" + "lukeshu.com/btrfs-tools/pkg/util" +) + +type Root struct { // ROOT_ITEM=132 + Inode Inode `bin:"off=0x0, siz=0xa0"` + Generation int64 `bin:"off=0xa0, siz=0x8"` + RootDirID int64 `bin:"off=0xa8, siz=0x8"` + ByteNr btrfstyp.LogicalAddr `bin:"off=0xb0, siz=0x8"` + ByteLimit int64 `bin:"off=0xb8, siz=0x8"` + BytesUsed int64 `bin:"off=0xc0, siz=0x8"` + LastSnapshot int64 `bin:"off=0xc8, siz=0x8"` + Flags RootFlags `bin:"off=0xd0, siz=0x8"` + Refs int32 `bin:"off=0xd8, siz=0x4"` + DropProgress btrfstyp.Key `bin:"off=0xdc, siz=0x11"` + DropLevel uint8 `bin:"off=0xed, siz=0x1"` + Level uint8 `bin:"off=0xee, siz=0x1"` + GenerationV2 int64 `bin:"off=0xef, siz=0x8"` + UUID btrfstyp.UUID `bin:"off=0xF7, siz=0x10"` + ParentUUID btrfstyp.UUID `bin:"off=0x107, siz=0x10"` + ReceivedUUID btrfstyp.UUID `bin:"off=0x117, siz=0x10"` + CTransID int64 `bin:"off=0x127, siz=0x8"` + OTransID int64 `bin:"off=0x12f, siz=0x8"` + STransID int64 `bin:"off=0x137, siz=0x8"` + RTransID int64 `bin:"off=0x13f, siz=0x8"` + CTime btrfstyp.Time `bin:"off=0x147, siz=0xc"` + OTime btrfstyp.Time `bin:"off=0x153, siz=0xc"` + STime btrfstyp.Time `bin:"off=0x15F, siz=0xc"` + RTime btrfstyp.Time `bin:"off=0x16b, siz=0xc"` + GlobalTreeID btrfstyp.ObjID `bin:"off=0x177, siz=0x8"` + Reserved [7]int64 `bin:"off=0x17f, siz=0x38"` + binstruct.End `bin:"off=0x1b7"` +} + +type RootFlags uint64 + +const ( + BTRFS_ROOT_SUBVOL_RDONLY = RootFlags(1 << iota) +) + +var rootItemFlagNames = []string{ + "SUBVOL_RDONLY", +} + +func (f RootFlags) Has(req RootFlags) bool { return f&req == req } +func (f RootFlags) String() string { return util.BitfieldString(f, rootItemFlagNames) } diff --git a/pkg/btrfs/btrfsitem/item_uuid.go b/pkg/btrfs/btrfsitem/item_uuid.go new file mode 100644 index 0000000..315dd70 --- /dev/null +++ b/pkg/btrfs/btrfsitem/item_uuid.go @@ -0,0 +1,39 @@ +package btrfsitem + +import ( + "lukeshu.com/btrfs-tools/pkg/binstruct" + "lukeshu.com/btrfs-tools/pkg/btrfs/btrfstyp" +) + +// The Key for this item is a UUID, and the item is a list of +// subvolume IDs (ObjectIDs) that that UUID maps to. +type UUIDMap struct { // UUID_SUBVOL=251 UUID_RECEIVED_SUBVOL=252 + SubvolIDs []btrfstyp.ObjID +} + +func (o *UUIDMap) UnmarshalBinary(dat []byte) (int, error) { + o.SubvolIDs = nil + var n int + for len(dat) > n { + var subvolID btrfstyp.ObjID + _n, err := binstruct.Unmarshal(dat[n:], &subvolID) + n += _n + if err != nil { + return n, err + } + o.SubvolIDs = append(o.SubvolIDs, subvolID) + } + return n, nil +} + +func (o UUIDMap) MarshalBinary() ([]byte, error) { + var ret []byte + for _, subvolID := range o.SubvolIDs { + bs, err := binstruct.Marshal(subvolID) + ret = append(ret, bs...) + if err != nil { + return ret, err + } + } + return ret, nil +} diff --git a/pkg/btrfs/btrfsitem/items.go b/pkg/btrfs/btrfsitem/items.go new file mode 100644 index 0000000..e9e03b8 --- /dev/null +++ b/pkg/btrfs/btrfsitem/items.go @@ -0,0 +1,20 @@ +package btrfsitem + +import "lukeshu.com/btrfs-tools/pkg/btrfs/internal" + +type Type = internal.ItemType + +const ( + CHUNK_ITEM_KEY = internal.CHUNK_ITEM_KEY + DEV_ITEM_KEY = internal.DEV_ITEM_KEY + DEV_EXTENT_KEY = internal.DEV_EXTENT_KEY + UNTYPED_KEY = internal.UNTYPED_KEY + QGROUP_RELATION_KEY = internal.QGROUP_RELATION_KEY + INODE_ITEM_KEY = internal.INODE_ITEM_KEY + INODE_REF_KEY = internal.INODE_REF_KEY + ORPHAN_ITEM_KEY = internal.ORPHAN_ITEM_KEY + PERSISTENT_ITEM_KEY = internal.PERSISTENT_ITEM_KEY + ROOT_ITEM_KEY = internal.ROOT_ITEM_KEY + UUID_SUBVOL_KEY = internal.UUID_SUBVOL_KEY + UUID_RECEIVED_SUBVOL_KEY = internal.UUID_RECEIVED_SUBVOL_KEY +) diff --git a/pkg/btrfs/btrfsitem/items.go.bak b/pkg/btrfs/btrfsitem/items.go.bak new file mode 100644 index 0000000..9a91d97 --- /dev/null +++ b/pkg/btrfs/btrfsitem/items.go.bak @@ -0,0 +1,193 @@ +package btrfsitem + +import ( + "lukeshu.com/btrfs-tools/pkg/btrfs/btrfstyp" +) + +type Type = btrfstyp.ItemType + +const ( + BTRFS_UNTYPED_KEY = btrfstyp.ItemType(0) + + // inode items have the data typically returned from stat and store other + // info about object characteristics. There is one for every file and dir in + // the FS + BTRFS_INODE_ITEM_KEY = btrfstyp.ItemType(1) + BTRFS_INODE_REF_KEY = btrfstyp.ItemType(12) + BTRFS_INODE_EXTREF_KEY = btrfstyp.ItemType(13) + BTRFS_XATTR_ITEM_KEY = btrfstyp.ItemType(24) + + BTRFS_VERITY_DESC_ITEM_KEY = btrfstyp.ItemType(36) // new + BTRFS_VERITY_MERKLE_ITEM_KEY = btrfstyp.ItemType(37) // new + + BTRFS_ORPHAN_ITEM_KEY = btrfstyp.ItemType(48) + + BTRFS_DIR_LOG_ITEM_KEY = btrfstyp.ItemType(60) + BTRFS_DIR_LOG_INDEX_KEY = btrfstyp.ItemType(72) + // dir items are the name -> inode pointers in a directory. There is one + // for every name in a directory. + BTRFS_DIR_ITEM_KEY = btrfstyp.ItemType(84) + BTRFS_DIR_INDEX_KEY = btrfstyp.ItemType(96) + + // extent data is for file data + BTRFS_EXTENT_DATA_KEY = btrfstyp.ItemType(108) + + // csum items have the checksums for data in the extents + BTRFS_CSUM_ITEM_KEY = btrfstyp.ItemType(120) // new + // extent csums are stored in a separate tree and hold csums for + // an entire extent on disk. + BTRFS_EXTENT_CSUM_KEY = btrfstyp.ItemType(128) + + // root items point to tree roots. There are typically in the root + // tree used by the super block to find all the other trees + BTRFS_ROOT_ITEM_KEY = btrfstyp.ItemType(132) + + // root backrefs tie subvols and snapshots to the directory entries that + // reference them + BTRFS_ROOT_BACKREF_KEY = btrfstyp.ItemType(144) + + // root refs make a fast index for listing all of the snapshots and + // subvolumes referenced by a given root. They point directly to the + // directory item in the root that references the subvol + BTRFS_ROOT_REF_KEY = btrfstyp.ItemType(156) + + // extent items are in the extent map tree. These record which blocks + // are used, and how many references there are to each block + BTRFS_EXTENT_ITEM_KEY = btrfstyp.ItemType(168) + + // The same as the BTRFS_EXTENT_ITEM_KEY, except it's metadata we already know + // the length, so we save the level in key->offset instead of the length. + BTRFS_METADATA_ITEM_KEY = btrfstyp.ItemType(169) // new + + BTRFS_TREE_BLOCK_REF_KEY = btrfstyp.ItemType(176) + + BTRFS_EXTENT_DATA_REF_KEY = btrfstyp.ItemType(178) + + // old style extent backrefs + BTRFS_EXTENT_REF_V0_KEY = btrfstyp.ItemType(180) + + BTRFS_SHARED_BLOCK_REF_KEY = btrfstyp.ItemType(182) + + BTRFS_SHARED_DATA_REF_KEY = btrfstyp.ItemType(184) + + // block groups give us hints into the extent allocation trees. Which + // blocks are free etc etc + BTRFS_BLOCK_GROUP_ITEM_KEY = btrfstyp.ItemType(192) + + // Every block group is represented in the free space tree by a free space info + // item, which stores some accounting information. It is keyed on + // (block_group_start, FREE_SPACE_INFO, block_group_length). + BTRFS_FREE_SPACE_INFO_KEY = btrfstyp.ItemType(198) // new + + // A free space extent tracks an extent of space that is free in a block group. + // It is keyed on (start, FREE_SPACE_EXTENT, length). + BTRFS_FREE_SPACE_EXTENT_KEY = btrfstyp.ItemType(199) // new + + // When a block group becomes very fragmented, we convert it to use bitmaps + // instead of extents. A free space bitmap is keyed on + // (start, FREE_SPACE_BITMAP, length); the corresponding item is a bitmap with + // (length / sectorsize) bits. + BTRFS_FREE_SPACE_BITMAP_KEY = btrfstyp.ItemType(200) // new + + BTRFS_DEV_EXTENT_KEY = btrfstyp.ItemType(204) + BTRFS_DEV_ITEM_KEY = btrfstyp.ItemType(216) + BTRFS_CHUNK_ITEM_KEY = btrfstyp.ItemType(228) + + // quota groups + BTRFS_QGROUP_STATUS_KEY = btrfstyp.ItemType(240) // new + BTRFS_QGROUP_INFO_KEY = btrfstyp.ItemType(242) // new + BTRFS_QGROUP_LIMIT_KEY = btrfstyp.ItemType(244) // new + BTRFS_QGROUP_RELATION_KEY = btrfstyp.ItemType(246) // new + + // The key type for tree items that are stored persistently, but do not need to + // exist for extended period of time. The items can exist in any tree. + // + // [subtype, BTRFS_TEMPORARY_ITEM_KEY, data] + // + // Existing items: + // + // - balance status item + // (BTRFS_BALANCE_OBJECTID, BTRFS_TEMPORARY_ITEM_KEY, 0) + BTRFS_TEMPORARY_ITEM_KEY = btrfstyp.ItemType(248) // new + + // The key type for tree items that are stored persistently and usually exist + // for a long period, eg. filesystem lifetime. The item kinds can be status + // information, stats or preference values. The item can exist in any tree. + // + // [subtype, BTRFS_PERSISTENT_ITEM_KEY, data] + // + // Existing items: + // + // - device statistics, store IO stats in the device tree, one key for all + // stats + // (BTRFS_DEV_STATS_OBJECTID, BTRFS_DEV_STATS_KEY, 0) + BTRFS_PERSISTENT_ITEM_KEY = btrfstyp.ItemType(249) // new + + // Persistently stores the device replace state in the device tree. + // The key is built like this: (0, BTRFS_DEV_REPLACE_KEY, 0). + BTRFS_DEV_REPLACE_KEY = btrfstyp.ItemType(250) + + // Stores items that allow to quickly map UUIDs to something else. + // These items are part of the filesystem UUID tree. + // The key is built like this: + // (UUID_upper_64_bits, BTRFS_UUID_KEY*, UUID_lower_64_bits). + BTRFS_UUID_KEY_SUBVOL = btrfstyp.ItemType(251) // for UUIDs assigned to subvols // new + BTRFS_UUID_KEY_RECEIVED_SUBVOL = btrfstyp.ItemType(252) // for UUIDs assigned to received subvols // new + + // string items are for debugging. They just store a short string of + // data in the FS + BTRFS_STRING_ITEM_KEY = btrfstyp.ItemType(253) +) + +/* +func (t btrfstyp.ItemType) String() string { + names := map[btrfstyp.ItemType]string{ + BTRFS_UNTYPED_KEY: "UNTYPED", + BTRFS_INODE_ITEM_KEY: "INODE_ITEM", + BTRFS_INODE_REF_KEY: "INODE_REF", + BTRFS_INODE_EXTREF_KEY: "INODE_EXTREF", + BTRFS_XATTR_ITEM_KEY: "XATTR_ITEM", + BTRFS_VERITY_DESC_ITEM_KEY: "VERITY_DESC_ITEM", + BTRFS_VERITY_MERKLE_ITEM_KEY: "VERITY_MERKLE_ITEM", + BTRFS_ORPHAN_ITEM_KEY: "ORPHAN_ITEM", + BTRFS_DIR_LOG_ITEM_KEY: "DIR_LOG_ITEM", + BTRFS_DIR_LOG_INDEX_KEY: "DIR_LOG_INDEX", + BTRFS_DIR_ITEM_KEY: "DIR_ITEM", + BTRFS_DIR_INDEX_KEY: "DIR_INDEX", + BTRFS_EXTENT_DATA_KEY: "EXTENT_DATA", + BTRFS_CSUM_ITEM_KEY: "CSUM_ITEM", + BTRFS_EXTENT_CSUM_KEY: "EXTENT_CSUM", + BTRFS_ROOT_ITEM_KEY: "ROOT_ITEM", + BTRFS_ROOT_BACKREF_KEY: "ROOT_BACKREF", + BTRFS_ROOT_REF_KEY: "ROOT_REF", + BTRFS_EXTENT_ITEM_KEY: "EXTENT_ITEM", + BTRFS_METADATA_ITEM_KEY: "METADATA_ITEM", + BTRFS_TREE_BLOCK_REF_KEY: "TREE_BLOCK_REF", + BTRFS_EXTENT_DATA_REF_KEY: "EXTENT_DATA_REF", + BTRFS_EXTENT_REF_V0_KEY: "EXTENT_REF_V0", + BTRFS_SHARED_BLOCK_REF_KEY: "SHARED_BLOCK_REF", + BTRFS_SHARED_DATA_REF_KEY: "SHARED_DATA_REF", + BTRFS_BLOCK_GROUP_ITEM_KEY: "BLOCK_GROUP_ITEM", + BTRFS_FREE_SPACE_INFO_KEY: "FREE_SPACE_INFO", + BTRFS_FREE_SPACE_EXTENT_KEY: "FREE_SPACE_EXTENT", + BTRFS_FREE_SPACE_BITMAP_KEY: "FREE_SPACE_BITMAP", + BTRFS_DEV_EXTENT_KEY: "DEV_EXTENT", + BTRFS_DEV_ITEM_KEY: "DEV_ITEM", + BTRFS_CHUNK_ITEM_KEY: "CHUNK_ITEM", + BTRFS_QGROUP_STATUS_KEY: "QGROUP_STATUS", + BTRFS_QGROUP_INFO_KEY: "QGROUP_INFO", + BTRFS_QGROUP_LIMIT_KEY: "QGROUP_LIMIT", + BTRFS_QGROUP_RELATION_KEY: "QGROUP_RELATION", + BTRFS_TEMPORARY_ITEM_KEY: "TEMPORARY_ITEM", + BTRFS_PERSISTENT_ITEM_KEY: "PERSISTENT_ITEM", + BTRFS_DEV_REPLACE_KEY: "DEV_REPLACE", + BTRFS_UUID_KEY_SUBVOL: "UUID_KEY_SUBVOL", + BTRFS_UUID_KEY_RECEIVED_SUBVOL: "UUID_KEY_RECEIVED_SUBVOL", + BTRFS_STRING_ITEM_KEY: "STRING_ITEM", + } + if name, ok := names[t]; ok { + return name + } + return fmt.Sprintf("%d", t) +} +*/ diff --git a/pkg/btrfs/btrfsitem/items.txt b/pkg/btrfs/btrfsitem/items.txt new file mode 100644 index 0000000..02c1d24 --- /dev/null +++ b/pkg/btrfs/btrfsitem/items.txt @@ -0,0 +1,12 @@ +CHUNK_ITEM=228 Chunk +DEV_ITEM=216 Dev +DEV_EXTENT=204 DevExtent +UNTYPED=0, Empty +QGROUP_RELATION=246 Empty +INODE_ITEM=1 Inode +INODE_REF=12 InodeRef +ORPHAN_ITEM=48 Orphan +PERSISTENT_ITEM=249 DevStats +ROOT_ITEM=132 Root +UUID_SUBVOL=251 UUIDMap +UUID_RECEIVED_SUBVOL=252 UUIDMap -- cgit v1.2.3-2-g168b