diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-06-01 10:22:09 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-06-01 10:45:36 -0600 |
commit | 774b5baa5aa5772b29865e8a570025d94ec34d2a (patch) | |
tree | 0ce0704bd1a39b3b7b0b4a000fe9f9206907d3ac /cmd/btrfs-dump-tree | |
parent | 8dde45b09728fb753b072c73ff624dde832c073b (diff) |
better error tolerance
Diffstat (limited to 'cmd/btrfs-dump-tree')
-rw-r--r-- | cmd/btrfs-dump-tree/main.go | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/cmd/btrfs-dump-tree/main.go b/cmd/btrfs-dump-tree/main.go index a1c7a03..b51e999 100644 --- a/cmd/btrfs-dump-tree/main.go +++ b/cmd/btrfs-dump-tree/main.go @@ -75,11 +75,13 @@ func Main(imgfilename string) (err error) { return err } } - if err := fs.WalkTree(superblock.Data.RootTree, func(key btrfs.Key, body btrfsitem.Item) error { - if key.ItemType != btrfsitem.ROOT_ITEM_KEY { - return nil - } - return printTree(fs, body.(btrfsitem.Root).ByteNr) + if err := fs.WalkTree(superblock.Data.RootTree, btrfs.WalkTreeHandler{ + Item: func(key btrfs.Key, body btrfsitem.Item) error { + if key.ItemType != btrfsitem.ROOT_ITEM_KEY { + return nil + } + return printTree(fs, body.(btrfsitem.Root).ByteNr) + }, }); err != nil { return err } @@ -91,7 +93,8 @@ func Main(imgfilename string) (err error) { func printTree(fs *btrfs.FS, root btrfs.LogicalAddr) error { nodeRef, err := fs.ReadNode(root) if err != nil { - return err + fmt.Fprintf(os.Stderr, "error: %v\n", err) + return nil } node := nodeRef.Data printHeaderInfo(node) @@ -209,6 +212,10 @@ func printTree(fs *btrfs.FS, root btrfs.LogicalAddr) error { // // TODO //case btrfsitem.TEMPORARY_ITEM_KEY: // // TODO + case btrfsitem.Error: + fmt.Printf("\t\t(error) error item: %v\n", body.Err) + default: + fmt.Printf("\t\t(error) unhandled item type: %T\n", body) } } } |