summaryrefslogtreecommitdiff
path: root/pkg/btrfs/btrfsitem
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-06-26 15:53:49 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-06-26 15:53:49 -0600
commit6a1b5c780b8fbb9ca0285286036096960458d4e6 (patch)
treed25b258039bfcdea66fbdfd698431d2673e520ec /pkg/btrfs/btrfsitem
parentfce6934cf76f4dfb04ea6eef1e2cd55c172beb1b (diff)
Add an AddrDelta type for safer arithmentic
Diffstat (limited to 'pkg/btrfs/btrfsitem')
-rw-r--r--pkg/btrfs/btrfsitem/item_blockgroup.go2
-rw-r--r--pkg/btrfs/btrfsitem/item_chunk.go21
-rw-r--r--pkg/btrfs/btrfsitem/item_devextent.go4
3 files changed, 17 insertions, 10 deletions
diff --git a/pkg/btrfs/btrfsitem/item_blockgroup.go b/pkg/btrfs/btrfsitem/item_blockgroup.go
index a28d4bf..737cfa0 100644
--- a/pkg/btrfs/btrfsitem/item_blockgroup.go
+++ b/pkg/btrfs/btrfsitem/item_blockgroup.go
@@ -6,6 +6,8 @@ import (
"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"`
diff --git a/pkg/btrfs/btrfsitem/item_chunk.go b/pkg/btrfs/btrfsitem/item_chunk.go
index eb3a16d..8f98ba1 100644
--- a/pkg/btrfs/btrfsitem/item_chunk.go
+++ b/pkg/btrfs/btrfsitem/item_chunk.go
@@ -8,21 +8,24 @@ import (
)
// Maps logical address to physical.
+//
+// key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID
+// key.offset = logical_addr
type Chunk struct { // CHUNK_ITEM=228
Head ChunkHeader
Stripes []ChunkStripe
}
type ChunkHeader struct {
- Size uint64 `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 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"` // ???
binstruct.End `bin:"off=0x30"`
}
diff --git a/pkg/btrfs/btrfsitem/item_devextent.go b/pkg/btrfs/btrfsitem/item_devextent.go
index dfa6d03..7f08b5e 100644
--- a/pkg/btrfs/btrfsitem/item_devextent.go
+++ b/pkg/btrfs/btrfsitem/item_devextent.go
@@ -5,11 +5,13 @@ import (
"lukeshu.com/btrfs-tools/pkg/btrfs/internal"
)
+// key.objectid = device_id
+// key.offset = physical_addr
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 uint64 `bin:"off=24, siz=8"`
+ Length internal.AddrDelta `bin:"off=24, siz=8"`
ChunkTreeUUID internal.UUID `bin:"off=32, siz=16"`
binstruct.End `bin:"off=48"`
}