diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-10 16:17:36 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-11 00:44:27 -0600 |
commit | d2da99882ea49cc67780c0255bf624698898e7fe (patch) | |
tree | a9ee06b155d21272085eb63ad665810d476e2780 /cmd/btrfs-dbg | |
parent | 78a6a912cff60f03dea4b285a439056089f7c102 (diff) |
rm -rf cmd/btrfs-dbg
Diffstat (limited to 'cmd/btrfs-dbg')
-rw-r--r-- | cmd/btrfs-dbg/main.go | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/cmd/btrfs-dbg/main.go b/cmd/btrfs-dbg/main.go deleted file mode 100644 index 0e1b732..0000000 --- a/cmd/btrfs-dbg/main.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com> -// -// SPDX-License-Identifier: GPL-2.0-or-later - -package main - -import ( - "fmt" - "os" - - "github.com/davecgh/go-spew/spew" - - "git.lukeshu.com/btrfs-progs-ng/lib/btrfs" - "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol" - "git.lukeshu.com/btrfs-progs-ng/lib/btrfsmisc" - "git.lukeshu.com/btrfs-progs-ng/lib/util" -) - -func main() { - if err := Main(os.Args[1]); err != nil { - fmt.Fprintf(os.Stderr, "%v: error: %v\n", os.Args[0], err) - os.Exit(1) - } -} - -func Main(imgfilename string) (err error) { - maybeSetErr := func(_err error) { - if _err != nil && err == nil { - err = _err - } - } - - fs, err := btrfsmisc.Open(os.O_RDONLY, imgfilename) - if err != nil { - return err - } - defer func() { - maybeSetErr(fs.Close()) - }() - - superblocks, err := fs.Superblocks() - if err != nil { - return err - } - - spew := spew.NewDefaultConfig() - spew.DisablePointerAddresses = true - - sum, err := superblocks[0].Data.CalculateChecksum() - if err != nil { - return err - } - fmt.Printf("superblock checksum: %v\n", sum) - spew.Dump(superblocks[0].Data) - - syschunks, err := superblocks[0].Data.ParseSysChunkArray() - if err != nil { - return err - } - spew.Dump(syschunks) - - for _, dev := range fs.LV.PhysicalVolumes() { - if err := btrfsmisc.ScanForNodes(dev, superblocks[0].Data, func(nodeRef *util.Ref[btrfsvol.PhysicalAddr, btrfs.Node], err error) { - if err != nil { - fmt.Println(err) - } else { - fmt.Printf("node@%v: physical_addr=%v logical_addr=%v generation=%v owner=%v level=%v\n", - nodeRef.Addr, - nodeRef.Addr, nodeRef.Data.Head.Addr, - nodeRef.Data.Head.Generation, nodeRef.Data.Head.Owner, nodeRef.Data.Head.Level) - } - }, nil); err != nil { - return err - } - } - - return nil -} |