From b392ad64a8fd04d20b35ad21d2d4ea3ff2778e3f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 5 Jul 2022 12:26:45 -0600 Subject: wip file io --- pkg/btrfs/btrfsitem/item_fileextent.go | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'pkg/btrfs/btrfsitem') diff --git a/pkg/btrfs/btrfsitem/item_fileextent.go b/pkg/btrfs/btrfsitem/item_fileextent.go index 5e87021..f3cbffe 100644 --- a/pkg/btrfs/btrfsitem/item_fileextent.go +++ b/pkg/btrfs/btrfsitem/item_fileextent.go @@ -4,9 +4,12 @@ import ( "fmt" "lukeshu.com/btrfs-tools/pkg/binstruct" + "lukeshu.com/btrfs-tools/pkg/btrfs/btrfsvol" "lukeshu.com/btrfs-tools/pkg/btrfs/internal" ) +// key.objectid = inode +// key.offset = offset within file type FileExtent struct { // EXTENT_DATA=108 Generation internal.Generation `bin:"off=0x0, siz=0x8"` // transaction ID that created this extent RAMBytes int64 `bin:"off=0x8, siz=0x8"` // upper bound of what compressed data will decompress to @@ -23,23 +26,25 @@ type FileExtent struct { // EXTENT_DATA=108 // only one of these, depending on .Type BodyInline []byte `bin:"-"` BodyReg struct { - // Position within the device - DiskByteNr int64 `bin:"off=0x0, siz=0x8"` - DiskNumBytes int64 `bin:"off=0x8, siz=0x8"` + // Position of extent within the device + DiskByteNr btrfsvol.LogicalAddr `bin:"off=0x0, siz=0x8"` + DiskNumBytes btrfsvol.AddrDelta `bin:"off=0x8, siz=0x8"` + + // Position of data within the extent + Offset btrfsvol.AddrDelta `bin:"off=0x10, siz=0x8"` + NumBytes btrfsvol.AddrDelta `bin:"off=0x18, siz=0x8"` - // Position within the file - Offset int64 `bin:"off=0x10, siz=0x8"` - NumBytes int64 `bin:"off=0x18, siz=0x8"` binstruct.End `bin:"off=0x20"` } `bin:"-"` BodyPrealloc struct { - // Position within the device - DiskByteNr int64 `bin:"off=0x0, siz=0x8"` - DiskNumBytes int64 `bin:"off=0x8, siz=0x8"` + // Position of extent within the device + DiskByteNr btrfsvol.LogicalAddr `bin:"off=0x0, siz=0x8"` + DiskNumBytes btrfsvol.AddrDelta `bin:"off=0x8, siz=0x8"` + + // Position of data within the extent + Offset btrfsvol.AddrDelta `bin:"off=0x10, siz=0x8"` + NumBytes btrfsvol.AddrDelta `bin:"off=0x18, siz=0x8"` - // Position within the file - Offset int64 `bin:"off=0x10, siz=0x8"` - NumBytes int64 `bin:"off=0x18, siz=0x8"` binstruct.End `bin:"off=0x20"` } `bin:"-"` } -- cgit v1.2.3-2-g168b