diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-02 16:02:42 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-30 10:06:00 -0600 |
commit | 72b20c1d798551bfa2bb46f5521553144b45c09f (patch) | |
tree | b317447fe966f42ab1480cd755506d35b98e0516 /lib/btrfs/io3_btree.go | |
parent | e62b128e088346e891b8b2a5e6458cf77abc9d02 (diff) |
btrfstree: Rethink the API, but leave the old API in place
Diffstat (limited to 'lib/btrfs/io3_btree.go')
-rw-r--r-- | lib/btrfs/io3_btree.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/btrfs/io3_btree.go b/lib/btrfs/io3_btree.go index 030ea41..59e4c1d 100644 --- a/lib/btrfs/io3_btree.go +++ b/lib/btrfs/io3_btree.go @@ -12,6 +12,7 @@ import ( "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfstree" "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol" "git.lukeshu.com/btrfs-progs-ng/lib/containers" + "git.lukeshu.com/btrfs-progs-ng/lib/diskio" "git.lukeshu.com/btrfs-progs-ng/lib/textui" ) @@ -73,6 +74,21 @@ func (fs *FS) readNode(_ context.Context, addr btrfsvol.LogicalAddr, nodeEntry * var _ btrfstree.NodeSource = (*FS)(nil) +// btrfstree.Forrest /////////////////////////////////////////////////////////// + +// RawTree is a variant of ForrestLookup that returns a concrete type +// instead of an interface. +func (fs *FS) RawTree(ctx context.Context, treeID btrfsprim.ObjID) (*btrfstree.RawTree, error) { + return btrfstree.RawForrest{NodeSource: fs}.RawTree(ctx, treeID) +} + +// ForrestLookup implements btree.Forrest. +func (fs *FS) ForrestLookup(ctx context.Context, treeID btrfsprim.ObjID) (btrfstree.Tree, error) { + return btrfstree.RawForrest{NodeSource: fs}.ForrestLookup(ctx, treeID) +} + +var _ btrfstree.Forrest = (*FS)(nil) + // btrfstree.TreeOperator ////////////////////////////////////////////////////// // TreeWalk implements btrfstree.TreeOperator. @@ -96,3 +112,18 @@ func (fs *FS) TreeSearchAll(treeID btrfsprim.ObjID, searcher btrfstree.TreeSearc } var _ btrfstree.TreeOperator = (*FS)(nil) + +// ReadableFS ////////////////////////////////////////////////////////////////// + +type ReadableFS interface { + btrfstree.Forrest + + Superblock() (*btrfstree.Superblock, error) + + Name() string + + // For reading file contents. + diskio.ReaderAt[btrfsvol.LogicalAddr] +} + +var _ ReadableFS = (*FS)(nil) |