diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-12 11:30:13 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-12 11:43:25 -0600 |
commit | 68555944f694e941b9cac3f8349364ec965db2fb (patch) | |
tree | 3b966ca9c633a1cf9740c8ca17904cf31121eda3 /cmd | |
parent | a0daaacdd61f196fbc0ca90ed996e7eeb4d4fcdd (diff) |
Don't let TreeWalk bail early, add TreeID in to TreePath
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/btrfs-fsck/pass1.go | 14 | ||||
-rw-r--r-- | cmd/btrfs-fsck/pass2.go | 4 | ||||
-rw-r--r-- | cmd/btrfs-rec/inspect_dumptrees.go | 5 | ||||
-rw-r--r-- | cmd/btrfs-rec/inspect_lstrees.go | 2 | ||||
-rw-r--r-- | cmd/btrfs-rec/repair_clearbadnodes.go | 6 |
5 files changed, 12 insertions, 19 deletions
diff --git a/cmd/btrfs-fsck/pass1.go b/cmd/btrfs-fsck/pass1.go index 0899cfc..c75e066 100644 --- a/cmd/btrfs-fsck/pass1.go +++ b/cmd/btrfs-fsck/pass1.go @@ -24,18 +24,12 @@ func pass1(ctx context.Context, fs *btrfs.FS, superblock *util.Ref[btrfsvol.Phys visitedNodes := make(map[btrfsvol.LogicalAddr]struct{}) btrfsutil.WalkAllTrees(fs, btrfsutil.WalkAllTreesHandler{ TreeWalkHandler: btrfs.TreeWalkHandler{ - Node: func(path btrfs.TreePath, node *util.Ref[btrfsvol.LogicalAddr, btrfs.Node], err error) error { - if err != nil { - err = fmt.Errorf("%v: %w", path, err) - fmt.Printf("Pass 1: ... walk fs: error: %v\n", err) - } - if node != nil { - visitedNodes[node.Addr] = struct{}{} - } - return err + Node: func(path btrfs.TreePath, node *util.Ref[btrfsvol.LogicalAddr, btrfs.Node]) error { + visitedNodes[node.Addr] = struct{}{} + return nil }, }, - Err: func(err error) { + Err: func(err *btrfsutil.WalkError) { fmt.Printf("Pass 1: ... walk fs: error: %v\n", err) }, }) diff --git a/cmd/btrfs-fsck/pass2.go b/cmd/btrfs-fsck/pass2.go index 9256220..78bd2e5 100644 --- a/cmd/btrfs-fsck/pass2.go +++ b/cmd/btrfs-fsck/pass2.go @@ -19,12 +19,12 @@ func pass2(fs *btrfs.FS, foundNodes map[btrfsvol.LogicalAddr]struct{}) { visitedNodes := make(map[btrfsvol.LogicalAddr]struct{}) btrfsutil.WalkAllTrees(fs, btrfsutil.WalkAllTreesHandler{ TreeWalkHandler: btrfs.TreeWalkHandler{ - Node: func(path btrfs.TreePath, node *util.Ref[btrfsvol.LogicalAddr, btrfs.Node], err error) error { + Node: func(path btrfs.TreePath, node *util.Ref[btrfsvol.LogicalAddr, btrfs.Node]) error { visitedNodes[node.Addr] = struct{}{} return nil }, }, - Err: func(err error) { + Err: func(err *btrfsutil.WalkError) { fmt.Printf("Pass 2: walk FS: error: %v\n", err) }, }) diff --git a/cmd/btrfs-rec/inspect_dumptrees.go b/cmd/btrfs-rec/inspect_dumptrees.go index 5ddff60..4abeaba 100644 --- a/cmd/btrfs-rec/inspect_dumptrees.go +++ b/cmd/btrfs-rec/inspect_dumptrees.go @@ -22,10 +22,11 @@ func init() { Short: "A clone of `btrfs inspect-internal dump-tree`", Args: cliutil.WrapPositionalArgs(cobra.NoArgs), }, - RunE: func(fs *btrfs.FS, _ *cobra.Command, _ []string) error { + RunE: func(fs *btrfs.FS, cmd *cobra.Command, _ []string) error { const version = "5.18.1" fmt.Printf("btrfs-progs v%v\n", version) - return btrfsinspect.DumpTrees(os.Stdout, os.Stderr, fs) + btrfsinspect.DumpTrees(cmd.Context(), os.Stdout, fs) + return nil }, }) } diff --git a/cmd/btrfs-rec/inspect_lstrees.go b/cmd/btrfs-rec/inspect_lstrees.go index 976514f..e308b20 100644 --- a/cmd/btrfs-rec/inspect_lstrees.go +++ b/cmd/btrfs-rec/inspect_lstrees.go @@ -35,7 +35,7 @@ func init() { treeItemCnt = make(map[btrfsitem.Type]int) fmt.Printf("tree id=%v name=%q\n", treeID, name) }, - Err: func(_ error) { + Err: func(_ *btrfsutil.WalkError) { treeErrCnt++ }, TreeWalkHandler: btrfs.TreeWalkHandler{ diff --git a/cmd/btrfs-rec/repair_clearbadnodes.go b/cmd/btrfs-rec/repair_clearbadnodes.go index 58b8bd6..3ae0810 100644 --- a/cmd/btrfs-rec/repair_clearbadnodes.go +++ b/cmd/btrfs-rec/repair_clearbadnodes.go @@ -5,8 +5,6 @@ package main import ( - "os" - "github.com/datawire/ocibuild/pkg/cliutil" "github.com/spf13/cobra" @@ -21,8 +19,8 @@ func init() { Short: "Overwrite corrupt nodes with empty nodes", Args: cliutil.WrapPositionalArgs(cobra.NoArgs), }, - RunE: func(fs *btrfs.FS, _ *cobra.Command, _ []string) error { - return btrfsrepair.ClearBadNodes(os.Stdout, os.Stderr, fs) + RunE: func(fs *btrfs.FS, cmd *cobra.Command, _ []string) error { + return btrfsrepair.ClearBadNodes(cmd.Context(), fs) }, }) } |