diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-06-06 13:32:44 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-06-06 13:32:52 -0600 |
commit | 9c1afdeecd3412b40c0b4973cb375cb9c71adbb1 (patch) | |
tree | 172cbba1a997f520d8b20aea79df5a4bdff6c371 | |
parent | b35032f7aa821ec48612ccc78bc36f30c589c9b9 (diff) |
more fix, more progress
-rw-r--r-- | cmd/btrfs-dbg/main.go | 2 | ||||
-rw-r--r-- | cmd/btrfs-fsck/main.go | 9 | ||||
-rw-r--r-- | pkg/btrfsmisc/fsck.go | 4 | ||||
-rw-r--r-- | pkg/util/ref.go | 5 |
4 files changed, 10 insertions, 10 deletions
diff --git a/cmd/btrfs-dbg/main.go b/cmd/btrfs-dbg/main.go index 462b333..9033421 100644 --- a/cmd/btrfs-dbg/main.go +++ b/cmd/btrfs-dbg/main.go @@ -70,7 +70,7 @@ func Main(imgfilename string) (err error) { nodeRef.Addr, nodeRef.Data.Head.Addr, nodeRef.Data.Head.Generation, nodeRef.Data.Head.Owner, nodeRef.Data.Head.Level) } - }); err != nil { + }, nil); err != nil { return err } diff --git a/cmd/btrfs-fsck/main.go b/cmd/btrfs-fsck/main.go index bb67556..8086904 100644 --- a/cmd/btrfs-fsck/main.go +++ b/cmd/btrfs-fsck/main.go @@ -112,8 +112,9 @@ 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) + if pct != lastProgress || pos == devSize { + fmt.Printf("Pass 1: ... dev[%q] scanned %v%% (found %d nodes)\n", + dev.Name(), pct, len(foundNodes)) lastProgress = pct } }); err != nil { @@ -265,10 +266,10 @@ func Main(imgfilename string) (err error) { fmt.Printf("Pass 1: ... new node checksum: error: %v\n", err) } if err := reconstructedNode.Write(); err != nil { - fmt.Printf("Pass 1: ... write new node: error:: %v\n", err) + fmt.Printf("Pass 1: ... write new node: error: %v\n", err) } - fmt.Printf("\nPass 2: ?????????????????????????\n") //////////////////////////////////////// + fmt.Printf("\nPass 2: orphaned nodes\n") /////////////////////////////////////////////////// /* fmt.Printf("node@%d: physical_addr=0x%0X logical_addr=0x%0X generation=%d owner=%v level=%d\n", diff --git a/pkg/btrfsmisc/fsck.go b/pkg/btrfsmisc/fsck.go index 81317ce..28b93ba 100644 --- a/pkg/btrfsmisc/fsck.go +++ b/pkg/btrfsmisc/fsck.go @@ -82,5 +82,9 @@ func ScanForNodes(dev *btrfs.Device, sb btrfs.Superblock, fn func(*util.Ref[btrf pos += btrfs.PhysicalAddr(sb.NodeSize) - btrfs.PhysicalAddr(sb.SectorSize) } + if prog != nil { + prog(devSize) + } + return nil } diff --git a/pkg/util/ref.go b/pkg/util/ref.go index 05ef08f..57f2eac 100644 --- a/pkg/util/ref.go +++ b/pkg/util/ref.go @@ -43,15 +43,10 @@ func (r *Ref[A, T]) Read() error { } func (r *Ref[A, T]) Write() error { - size := binstruct.StaticSize(r.Data) buf, err := binstruct.Marshal(r.Data) if err != nil { return err } - if len(buf) != size { - return fmt.Errorf("util.Ref[%T].Write: expected to want to write %d bytes, but got %d bytes to write", - r.Data, size, len(buf)) - } if _, err = r.File.WriteAt(buf, r.Addr); err != nil { return err } |