diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-06-26 21:27:55 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-06-26 22:19:41 -0600 |
commit | 64c04fc690ec5a276e11500691173962bbe4d99e (patch) | |
tree | f01996f95da88c38ee4bc1aa3691dc650eebf2e7 /cmd/btrfs-fsck/main.go | |
parent | bfb830d024fd6309d81e20a7d21a2433c4ec9c93 (diff) |
fuss with exposing .LV and how init happens
Diffstat (limited to 'cmd/btrfs-fsck/main.go')
-rw-r--r-- | cmd/btrfs-fsck/main.go | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/cmd/btrfs-fsck/main.go b/cmd/btrfs-fsck/main.go index 0083bd9..e51aae9 100644 --- a/cmd/btrfs-fsck/main.go +++ b/cmd/btrfs-fsck/main.go @@ -3,43 +3,40 @@ package main import ( "fmt" "os" - - "lukeshu.com/btrfs-tools/pkg/btrfs" ) func main() { - if err := Main(os.Args[1]); err != nil { + 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) { +func Main(imgfilenames ...string) (err error) { maybeSetErr := func(_err error) { if _err != nil && err == nil { err = _err } } - fh, err := os.OpenFile(imgfilename, os.O_RDWR, 0) - if err != nil { - return err - } - defer func() { - maybeSetErr(fh.Close()) - }() - - fs := new(btrfs.FS) - if err := fs.AddDevice(&btrfs.Device{File: fh}); err != nil { - return err + var imgfiles []*os.File + for _, imgfilename := range imgfilenames { + fh, err := os.OpenFile(imgfilename, os.O_RDWR, 0) + if err != nil { + return err + } + defer func() { + maybeSetErr(fh.Close()) + }() + imgfiles = append(imgfiles, fh) } - superblock, err := pass0(fs) + fs, sb, err := pass0(imgfiles...) if err != nil { return err } - foundNodes, err := pass1(fs, superblock) + foundNodes, err := pass1(fs, sb) if err != nil { return err } |