diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-06-06 12:35:02 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-06-06 12:35:02 -0600 |
commit | b35032f7aa821ec48612ccc78bc36f30c589c9b9 (patch) | |
tree | a13f18b441115746ca846d019515a70899dff7f3 /cmd/btrfs-fsck | |
parent | 7a464fd038977ba1d57d730e7f15a4df5c8ca91a (diff) |
show progress
Diffstat (limited to 'cmd/btrfs-fsck')
-rw-r--r-- | cmd/btrfs-fsck/main.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cmd/btrfs-fsck/main.go b/cmd/btrfs-fsck/main.go index be9f313..bb67556 100644 --- a/cmd/btrfs-fsck/main.go +++ b/cmd/btrfs-fsck/main.go @@ -78,10 +78,12 @@ func Main(imgfilename string) (err error) { } reconstructedChunks := make(map[btrfs.LogicalAddr][]reconstructedStripe) for _, dev := range fs.Devices { - fmt.Printf("Pass 1: ... dev[%q] scanning for nodes\n", dev.Name()) + fmt.Printf("Pass 1: ... dev[%q] scanning for nodes...\n", dev.Name()) superblock, _ := dev.Superblock() foundNodes := make(map[btrfs.LogicalAddr][]btrfs.PhysicalAddr) var lostAndFoundChunks []btrfs.SysChunk + devSize, _ := dev.Size() + lastProgress := -1 if err := btrfsmisc.ScanForNodes(dev, superblock.Data, func(nodeRef *util.Ref[btrfs.PhysicalAddr, btrfs.Node], err error) { if err != nil { fmt.Printf("Pass 1: ... dev[%q] error: %v\n", dev.Name(), err) @@ -108,6 +110,12 @@ func Main(imgfilename string) (err error) { }) } } + }, func(pos btrfs.PhysicalAddr) { + pct := int(100 * float64(pos) / float64(devSize)) + if pct != lastProgress { + fmt.Printf("Pass 1: ... dev[%q] scanned %v%%\n", dev.Name(), pct) + lastProgress = pct + } }); err != nil { return err } |