summaryrefslogtreecommitdiff
path: root/lib/btrfs/btrfstree/btree.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-03-15 15:17:11 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2023-03-15 20:42:51 -0600
commitd7e086766e0f4396f29987d3798cefc1bb675d1c (patch)
treee45cc733519e5fc540a3b28ef36ebd354ed001cc /lib/btrfs/btrfstree/btree.go
parent56e44b0630448d44f7aa7f85b2098007ddbae06f (diff)
btrfstree: Have errors include context of what was being searched for
Diffstat (limited to 'lib/btrfs/btrfstree/btree.go')
-rw-r--r--lib/btrfs/btrfstree/btree.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/btrfs/btrfstree/btree.go b/lib/btrfs/btrfstree/btree.go
index 7b3721b..4c10ffa 100644
--- a/lib/btrfs/btrfstree/btree.go
+++ b/lib/btrfs/btrfstree/btree.go
@@ -13,6 +13,15 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/diskio"
)
+type TreeSearcher interface {
+ // How the search should be described in the event of an
+ // error.
+ fmt.Stringer
+
+ // size is math.MaxUint32 for key-pointers
+ Search(key btrfsprim.Key, size uint32) int
+}
+
// TreeOperator is an interface for performing basic btree operations.
type TreeOperator interface {
// TreeWalk walks a tree, triggering callbacks for every node,
@@ -40,7 +49,7 @@ type TreeOperator interface {
TreeWalk(ctx context.Context, treeID btrfsprim.ObjID, errHandle func(*TreeError), cbs TreeWalkHandler)
TreeLookup(treeID btrfsprim.ObjID, key btrfsprim.Key) (Item, error)
- TreeSearch(treeID btrfsprim.ObjID, fn func(key btrfsprim.Key, size uint32) int) (Item, error) // size is math.MaxUint32 for key-pointers
+ TreeSearch(treeID btrfsprim.ObjID, search TreeSearcher) (Item, error)
// If some items are able to be read, but there is an error reading the
// full set, then it might return *both* a list of items and an error.
@@ -50,7 +59,7 @@ type TreeOperator interface {
//
// If no such item is found, an error that is ErrNoItem is
// returned.
- TreeSearchAll(treeID btrfsprim.ObjID, fn func(key btrfsprim.Key, size uint32) int) ([]Item, error) // size is math.MaxUint32 for key-pointers
+ TreeSearchAll(treeID btrfsprim.ObjID, search TreeSearcher) ([]Item, error)
}
type TreeWalkHandler struct {