diff options
Diffstat (limited to 'cmd/btrfs-fsck')
-rw-r--r-- | cmd/btrfs-fsck/main.go | 10 | ||||
-rw-r--r-- | cmd/btrfs-fsck/pass1.go | 4 |
2 files changed, 6 insertions, 8 deletions
diff --git a/cmd/btrfs-fsck/main.go b/cmd/btrfs-fsck/main.go index c4bfc75..0083bd9 100644 --- a/cmd/btrfs-fsck/main.go +++ b/cmd/btrfs-fsck/main.go @@ -28,12 +28,10 @@ func Main(imgfilename string) (err error) { defer func() { maybeSetErr(fh.Close()) }() - fs := &btrfs.FS{ - Devices: []*btrfs.Device{ - { - File: fh, - }, - }, + + fs := new(btrfs.FS) + if err := fs.AddDevice(&btrfs.Device{File: fh}); err != nil { + return err } superblock, err := pass0(fs) diff --git a/cmd/btrfs-fsck/pass1.go b/cmd/btrfs-fsck/pass1.go index 4507313..734ee40 100644 --- a/cmd/btrfs-fsck/pass1.go +++ b/cmd/btrfs-fsck/pass1.go @@ -44,7 +44,7 @@ func pass1(fs *btrfs.FS, superblock *util.Ref[btrfs.PhysicalAddr, btrfs.Superblo Size btrfs.AddrDelta Stripes []btrfsitem.ChunkStripe }) - for _, dev := range fs.Devices { + for _, dev := range fs.Devices() { fmt.Printf("Pass 1: ... dev[%q] scanning for nodes...\n", dev.Name()) devResult, err := pass1ScanOneDev(dev, superblock.Data) if err != nil { @@ -505,7 +505,7 @@ func pass1WriteReconstructedChunks( }, } - for _, dev := range fs.Devices { + for _, dev := range fs.Devices() { superblock, _ := dev.Superblock() reconstructedNode.Data.BodyLeaf = append(reconstructedNode.Data.BodyLeaf, btrfs.Item{ Head: btrfs.ItemHeader{ |