diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-23 18:20:00 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-23 18:20:00 -0600 |
commit | f0a9faf21dbe508d57da3b18be9121559c70876a (patch) | |
tree | 623581e503f056267091ef94f0c9c7f4d30924ff /cmd/btrfs-rec/inspect | |
parent | 0f96c9ce920875babd4cd23819a2fb2960dc0cc6 (diff) | |
parent | b8185f8e741bd81e0d6f6416e46e11f6f7570995 (diff) |
Merge branch 'lukeshu/tree-api-pt0-prep'
Diffstat (limited to 'cmd/btrfs-rec/inspect')
-rw-r--r-- | cmd/btrfs-rec/inspect/dumptrees/print_tree.go | 15 | ||||
-rw-r--r-- | cmd/btrfs-rec/inspect/rebuildtrees/scan.go | 2 |
2 files changed, 7 insertions, 10 deletions
diff --git a/cmd/btrfs-rec/inspect/dumptrees/print_tree.go b/cmd/btrfs-rec/inspect/dumptrees/print_tree.go index 60303e9..7703078 100644 --- a/cmd/btrfs-rec/inspect/dumptrees/print_tree.go +++ b/cmd/btrfs-rec/inspect/dumptrees/print_tree.go @@ -53,9 +53,9 @@ func DumpTrees(ctx context.Context, out io.Writer, fs *btrfs.FS) { dlog.Error(ctx, err) }, btrfstree.TreeWalkHandler{ - Item: func(_ btrfstree.Path, item btrfstree.Item) error { + Item: func(_ btrfstree.Path, item btrfstree.Item) { if item.Key.ItemType != btrfsitem.ROOT_ITEM_KEY { - return nil + return } treeName, ok := map[btrfsprim.ObjID]string{ btrfsprim.ROOT_TREE_OBJECTID: "root", @@ -82,7 +82,6 @@ func DumpTrees(ctx context.Context, out io.Writer, fs *btrfs.FS) { } textui.Fprintf(out, "%v tree key %v \n", treeName, item.Key.Format(btrfsprim.ROOT_TREE_OBJECTID)) printTree(ctx, out, fs, item.Key.ObjectID) - return nil }, }, ) @@ -99,20 +98,19 @@ var nodeHeaderSize = binstruct.StaticSize(btrfstree.NodeHeader{}) func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfsprim.ObjID) { var itemOffset uint32 handlers := btrfstree.TreeWalkHandler{ - Node: func(path btrfstree.Path, node *btrfstree.Node) error { + Node: func(path btrfstree.Path, node *btrfstree.Node) { printHeaderInfo(out, node) itemOffset = node.Size - uint32(nodeHeaderSize) - return nil }, - PreKeyPointer: func(path btrfstree.Path, item btrfstree.KeyPointer) error { + KeyPointer: func(path btrfstree.Path, item btrfstree.KeyPointer) bool { treeID := path[0].FromTree textui.Fprintf(out, "\tkey %v block %v gen %v\n", item.Key.Format(treeID), item.BlockPtr, item.Generation) - return nil + return true }, - Item: func(path btrfstree.Path, item btrfstree.Item) error { + Item: func(path btrfstree.Path, item btrfstree.Item) { treeID := path[0].FromTree i := path.Node(-1).FromItemSlot bs, _ := binstruct.Marshal(item.Body) @@ -359,7 +357,6 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri default: textui.Fprintf(out, "\t\t(error) unhandled item type: %T\n", body) } - return nil }, } handlers.BadItem = handlers.Item diff --git a/cmd/btrfs-rec/inspect/rebuildtrees/scan.go b/cmd/btrfs-rec/inspect/rebuildtrees/scan.go index ada9f6f..3339270 100644 --- a/cmd/btrfs-rec/inspect/rebuildtrees/scan.go +++ b/cmd/btrfs-rec/inspect/rebuildtrees/scan.go @@ -59,7 +59,7 @@ func ScanDevices(ctx context.Context, fs *btrfs.FS, nodeList []btrfsvol.LogicalA ret := ScanDevicesResult{ Superblock: *sb, - Graph: btrfsutil.NewGraph(*sb), + Graph: btrfsutil.NewGraph(ctx, *sb), Flags: make(map[btrfsutil.ItemPtr]FlagsAndErr), Names: make(map[btrfsutil.ItemPtr][]byte), |