diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-06-26 20:25:27 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-06-26 20:27:11 -0600 |
commit | 8db7bed06505569c1b41a338b5131cfd5c9d1f28 (patch) | |
tree | a33404699ab627cc71c40bdbe7062ef837c9d7d3 /pkg/btrfs/btrfsitem | |
parent | 09e3317a433add776d6539abcd7cf4f00ca984e5 (diff) |
tidy up which package things are in
Diffstat (limited to 'pkg/btrfs/btrfsitem')
-rw-r--r-- | pkg/btrfs/btrfsitem/item_blockgroup.go | 54 | ||||
-rw-r--r-- | pkg/btrfs/btrfsitem/item_chunk.go | 24 | ||||
-rw-r--r-- | pkg/btrfs/btrfsitem/item_dev.go | 5 | ||||
-rw-r--r-- | pkg/btrfs/btrfsitem/item_devextent.go | 8 | ||||
-rw-r--r-- | pkg/btrfs/btrfsitem/item_root.go | 9 |
5 files changed, 30 insertions, 70 deletions
diff --git a/pkg/btrfs/btrfsitem/item_blockgroup.go b/pkg/btrfs/btrfsitem/item_blockgroup.go index 737cfa0..8f7847d 100644 --- a/pkg/btrfs/btrfsitem/item_blockgroup.go +++ b/pkg/btrfs/btrfsitem/item_blockgroup.go @@ -2,61 +2,15 @@ package btrfsitem import ( "lukeshu.com/btrfs-tools/pkg/binstruct" + "lukeshu.com/btrfs-tools/pkg/btrfs/btrfsvol" "lukeshu.com/btrfs-tools/pkg/btrfs/internal" - "lukeshu.com/btrfs-tools/pkg/util" ) // key.objectid = logical_addr // key.offset = size of chunk 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"` + Used int64 `bin:"off=0, siz=8"` + ChunkObjectID internal.ObjID `bin:"off=8, siz=8"` + Flags btrfsvol.BlockGroupFlags `bin:"off=16, siz=8"` binstruct.End `bin:"off=24"` } - -type BlockGroupFlags uint64 - -const ( - BLOCK_GROUP_DATA = BlockGroupFlags(1 << iota) - BLOCK_GROUP_SYSTEM - BLOCK_GROUP_METADATA - BLOCK_GROUP_RAID0 - BLOCK_GROUP_RAID1 - BLOCK_GROUP_DUP - BLOCK_GROUP_RAID10 - BLOCK_GROUP_RAID5 - BLOCK_GROUP_RAID6 - BLOCK_GROUP_RAID1C3 - BLOCK_GROUP_RAID1C4 - - BLOCK_GROUP_RAID_MASK = (BLOCK_GROUP_RAID1 | BLOCK_GROUP_DUP | BLOCK_GROUP_RAID10 | BLOCK_GROUP_RAID5 | BLOCK_GROUP_RAID6 | BLOCK_GROUP_RAID1C3 | BLOCK_GROUP_RAID1C4) -) - -var blockGroupFlagNames = []string{ - "DATA", - "SYSTEM", - "METADATA", - - "RAID0", - "RAID1", - "DUP", - "RAID10", - "RAID5", - "RAID6", - "RAID1C3", - "RAID1C4", -} - -func (f BlockGroupFlags) Has(req BlockGroupFlags) bool { return f&req == req } -func (f BlockGroupFlags) String() string { - ret := util.BitfieldString(f, blockGroupFlagNames, util.HexNone) - if f&BLOCK_GROUP_RAID_MASK == 0 { - if ret == "" { - ret = "single" - } else { - ret += "|single" - } - } - return ret -} diff --git a/pkg/btrfs/btrfsitem/item_chunk.go b/pkg/btrfs/btrfsitem/item_chunk.go index 8f98ba1..a77ae33 100644 --- a/pkg/btrfs/btrfsitem/item_chunk.go +++ b/pkg/btrfs/btrfsitem/item_chunk.go @@ -4,7 +4,9 @@ import ( "fmt" "lukeshu.com/btrfs-tools/pkg/binstruct" + "lukeshu.com/btrfs-tools/pkg/btrfs/btrfsvol" "lukeshu.com/btrfs-tools/pkg/btrfs/internal" + "lukeshu.com/btrfs-tools/pkg/util" ) // Maps logical address to physical. @@ -17,22 +19,22 @@ type Chunk struct { // CHUNK_ITEM=228 } type ChunkHeader struct { - Size internal.AddrDelta `bin:"off=0x0, siz=0x8"` - Owner internal.ObjID `bin:"off=0x8, siz=0x8"` // root referencing this chunk (always EXTENT_TREE_OBJECTID=2) - StripeLen uint64 `bin:"off=0x10, siz=0x8"` // ??? - Type BlockGroupFlags `bin:"off=0x18, siz=0x8"` - IOOptimalAlign uint32 `bin:"off=0x20, siz=0x4"` - IOOptimalWidth uint32 `bin:"off=0x24, siz=0x4"` - IOMinSize uint32 `bin:"off=0x28, siz=0x4"` // sector size - NumStripes uint16 `bin:"off=0x2c, siz=0x2"` // [ignored-when-writing] - SubStripes uint16 `bin:"off=0x2e, siz=0x2"` // ??? + Size btrfsvol.AddrDelta `bin:"off=0x0, siz=0x8"` + Owner internal.ObjID `bin:"off=0x8, siz=0x8"` // root referencing this chunk (always EXTENT_TREE_OBJECTID=2) + StripeLen uint64 `bin:"off=0x10, siz=0x8"` // ??? + Type btrfsvol.BlockGroupFlags `bin:"off=0x18, siz=0x8"` + IOOptimalAlign uint32 `bin:"off=0x20, siz=0x4"` + IOOptimalWidth uint32 `bin:"off=0x24, siz=0x4"` + IOMinSize uint32 `bin:"off=0x28, siz=0x4"` // sector size + NumStripes uint16 `bin:"off=0x2c, siz=0x2"` // [ignored-when-writing] + SubStripes uint16 `bin:"off=0x2e, siz=0x2"` // ??? binstruct.End `bin:"off=0x30"` } type ChunkStripe struct { DeviceID internal.ObjID `bin:"off=0x0, siz=0x8"` - Offset internal.PhysicalAddr `bin:"off=0x8, siz=0x8"` - DeviceUUID internal.UUID `bin:"off=0x10, siz=0x10"` + Offset btrfsvol.PhysicalAddr `bin:"off=0x8, siz=0x8"` + DeviceUUID util.UUID `bin:"off=0x10, siz=0x10"` binstruct.End `bin:"off=0x20"` } diff --git a/pkg/btrfs/btrfsitem/item_dev.go b/pkg/btrfs/btrfsitem/item_dev.go index 9851002..848f338 100644 --- a/pkg/btrfs/btrfsitem/item_dev.go +++ b/pkg/btrfs/btrfsitem/item_dev.go @@ -3,6 +3,7 @@ package btrfsitem import ( "lukeshu.com/btrfs-tools/pkg/binstruct" "lukeshu.com/btrfs-tools/pkg/btrfs/internal" + "lukeshu.com/btrfs-tools/pkg/util" ) type Dev struct { // DEV_ITEM=216 @@ -22,8 +23,8 @@ type Dev struct { // DEV_ITEM=216 SeekSpeed uint8 `bin:"off=0x40, siz=0x1"` Bandwidth uint8 `bin:"off=0x41, siz=0x1"` - DevUUID internal.UUID `bin:"off=0x42, siz=0x10"` - FSUUID internal.UUID `bin:"off=0x52, siz=0x10"` + DevUUID util.UUID `bin:"off=0x42, siz=0x10"` + FSUUID util.UUID `bin:"off=0x52, siz=0x10"` binstruct.End `bin:"off=0x62"` } diff --git a/pkg/btrfs/btrfsitem/item_devextent.go b/pkg/btrfs/btrfsitem/item_devextent.go index 7f08b5e..03d696a 100644 --- a/pkg/btrfs/btrfsitem/item_devextent.go +++ b/pkg/btrfs/btrfsitem/item_devextent.go @@ -2,7 +2,9 @@ package btrfsitem import ( "lukeshu.com/btrfs-tools/pkg/binstruct" + "lukeshu.com/btrfs-tools/pkg/btrfs/btrfsvol" "lukeshu.com/btrfs-tools/pkg/btrfs/internal" + "lukeshu.com/btrfs-tools/pkg/util" ) // key.objectid = device_id @@ -10,8 +12,8 @@ import ( type DevExtent struct { // DEV_EXTENT=204 ChunkTree int64 `bin:"off=0, siz=8"` ChunkObjectID internal.ObjID `bin:"off=8, siz=8"` - ChunkOffset internal.LogicalAddr `bin:"off=16, siz=8"` - Length internal.AddrDelta `bin:"off=24, siz=8"` - ChunkTreeUUID internal.UUID `bin:"off=32, siz=16"` + ChunkOffset btrfsvol.LogicalAddr `bin:"off=16, siz=8"` + Length btrfsvol.AddrDelta `bin:"off=24, siz=8"` + ChunkTreeUUID util.UUID `bin:"off=32, siz=16"` binstruct.End `bin:"off=48"` } diff --git a/pkg/btrfs/btrfsitem/item_root.go b/pkg/btrfs/btrfsitem/item_root.go index f0a961b..bdf1b7b 100644 --- a/pkg/btrfs/btrfsitem/item_root.go +++ b/pkg/btrfs/btrfsitem/item_root.go @@ -2,6 +2,7 @@ package btrfsitem import ( "lukeshu.com/btrfs-tools/pkg/binstruct" + "lukeshu.com/btrfs-tools/pkg/btrfs/btrfsvol" "lukeshu.com/btrfs-tools/pkg/btrfs/internal" "lukeshu.com/btrfs-tools/pkg/util" ) @@ -10,7 +11,7 @@ type Root struct { // ROOT_ITEM=132 Inode Inode `bin:"off=0x0, siz=0xa0"` Generation internal.Generation `bin:"off=0xa0, siz=0x8"` RootDirID int64 `bin:"off=0xa8, siz=0x8"` - ByteNr internal.LogicalAddr `bin:"off=0xb0, siz=0x8"` + ByteNr btrfsvol.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"` @@ -20,9 +21,9 @@ type Root struct { // ROOT_ITEM=132 DropLevel uint8 `bin:"off=0xed, siz=0x1"` Level uint8 `bin:"off=0xee, siz=0x1"` GenerationV2 internal.Generation `bin:"off=0xef, siz=0x8"` - UUID internal.UUID `bin:"off=0xF7, siz=0x10"` - ParentUUID internal.UUID `bin:"off=0x107, siz=0x10"` - ReceivedUUID internal.UUID `bin:"off=0x117, siz=0x10"` + UUID util.UUID `bin:"off=0xF7, siz=0x10"` + ParentUUID util.UUID `bin:"off=0x107, siz=0x10"` + ReceivedUUID util.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"` |