summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-07-05 12:26:45 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-07-08 00:15:09 -0600
commitb392ad64a8fd04d20b35ad21d2d4ea3ff2778e3f (patch)
treefea515cb26435c767320ecb7b07fe1fec01ce388 /pkg
parent08a2266c346edc20ad7bfdda62dc8f685f0be27d (diff)
wip file io
Diffstat (limited to 'pkg')
-rw-r--r--pkg/btrfs/btrfsitem/item_fileextent.go29
-rw-r--r--pkg/btrfsmisc/print_tree.go4
2 files changed, 19 insertions, 14 deletions
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:"-"`
}
diff --git a/pkg/btrfsmisc/print_tree.go b/pkg/btrfsmisc/print_tree.go
index f78f653..6b4ff96 100644
--- a/pkg/btrfsmisc/print_tree.go
+++ b/pkg/btrfsmisc/print_tree.go
@@ -162,10 +162,10 @@ func PrintTree(fs *btrfs.FS, root btrfsvol.LogicalAddr) error {
body.BodyPrealloc.Offset,
body.BodyPrealloc.NumBytes)
case btrfsitem.FILE_EXTENT_REG:
- fmt.Printf("\t\textent data disk byte %v nr %v\n",
+ fmt.Printf("\t\textent data disk byte %d nr %d\n",
body.BodyReg.DiskByteNr,
body.BodyReg.DiskNumBytes)
- fmt.Printf("\t\textent data offset %v nr %v ram %v\n",
+ fmt.Printf("\t\textent data offset %d nr %d ram %v\n",
body.BodyReg.Offset,
body.BodyReg.NumBytes,
body.RAMBytes)