summaryrefslogtreecommitdiff
path: root/pkg/btrfs/internal
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-07-01 21:49:11 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-07-01 21:49:11 -0600
commitf1bc48ee12c6873b6b57a2403325765e987ad813 (patch)
treefc5251156819daa9af85f4ca318b0f47012ee038 /pkg/btrfs/internal
parent22c72e497425dd24695f5ee8f883c977c7e38db6 (diff)
implement btree lookup
Diffstat (limited to 'pkg/btrfs/internal')
-rw-r--r--pkg/btrfs/internal/misc.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/btrfs/internal/misc.go b/pkg/btrfs/internal/misc.go
index 2a98464..3dc77d6 100644
--- a/pkg/btrfs/internal/misc.go
+++ b/pkg/btrfs/internal/misc.go
@@ -4,6 +4,7 @@ import (
"time"
"lukeshu.com/btrfs-tools/pkg/binstruct"
+ "lukeshu.com/btrfs-tools/pkg/util"
)
type Generation uint64
@@ -15,6 +16,16 @@ type Key struct {
binstruct.End `bin:"off=0x11"`
}
+func (a Key) Cmp(b Key) int {
+ if d := util.CmpUint(a.ObjectID, b.ObjectID); d != 0 {
+ return d
+ }
+ if d := util.CmpUint(a.ItemType, b.ItemType); d != 0 {
+ return d
+ }
+ return util.CmpUint(a.Offset, b.Offset)
+}
+
type Time struct {
Sec int64 `bin:"off=0x0, siz=0x8"` // Number of seconds since 1970-01-01T00:00:00Z.
NSec uint32 `bin:"off=0x8, siz=0x4"` // Number of nanoseconds since the beginning of the second.