diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-11 21:10:54 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-11 21:17:09 -0600 |
commit | 839dfa5d0aeadee9cb0f8581341922138f9595f0 (patch) | |
tree | 42130616613f57f0b9d40a7490a0f576aa94f35a /cmd/btrfs-mount/main.go | |
parent | 0f853e1ead10347be8c5715d6bb797dd5e643e2f (diff) |
Move all of the small-ish tools to be part of btrfs-rec
Diffstat (limited to 'cmd/btrfs-mount/main.go')
-rw-r--r-- | cmd/btrfs-mount/main.go | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/cmd/btrfs-mount/main.go b/cmd/btrfs-mount/main.go deleted file mode 100644 index 7debb3a..0000000 --- a/cmd/btrfs-mount/main.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com> -// -// SPDX-License-Identifier: GPL-2.0-or-later - -package main - -import ( - "context" - "fmt" - "os" - - "github.com/datawire/dlib/dgroup" - "github.com/datawire/dlib/dlog" - "github.com/sirupsen/logrus" - - "git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsinspect" - "git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsutil" -) - -func main() { - ctx := context.Background() - logger := logrus.New() - //logger.SetLevel(logrus.TraceLevel) - ctx = dlog.WithLogger(ctx, dlog.WrapLogrus(logger)) - - grp := dgroup.NewGroup(ctx, dgroup.GroupConfig{ - EnableSignalHandling: true, - }) - grp.Go("main", func(ctx context.Context) error { - return Main(ctx, os.Args[1], os.Args[2:]...) - }) - if err := grp.Wait(); err != nil { - fmt.Fprintf(os.Stderr, "%v: error: %v\n", os.Args[0], err) - os.Exit(1) - } -} - -func Main(ctx context.Context, mountpoint string, imgfilenames ...string) (err error) { - maybeSetErr := func(_err error) { - if _err != nil && err == nil { - err = _err - } - } - - fs, err := btrfsutil.Open(os.O_RDONLY, imgfilenames...) - if err != nil { - return err - } - defer func() { - maybeSetErr(fs.Close()) - }() - - return btrfsinspect.MountRO(ctx, fs, mountpoint) -} |