diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-06 12:11:41 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-08 00:16:01 -0600 |
commit | 2878002388509b30d36ff90283b5349ff2096b7b (patch) | |
tree | f5e916a4ca65f6fbae6b5f9953908dbe69399ceb /cmd/btrfs-mount/main.go | |
parent | 12d10ff2e3317c280e5f6ebfd913c73a6a1d896b (diff) |
Get subvolume mounting/unmounting working way better
Diffstat (limited to 'cmd/btrfs-mount/main.go')
-rw-r--r-- | cmd/btrfs-mount/main.go | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/cmd/btrfs-mount/main.go b/cmd/btrfs-mount/main.go index 4451e7a..ed22d7d 100644 --- a/cmd/btrfs-mount/main.go +++ b/cmd/btrfs-mount/main.go @@ -5,11 +5,9 @@ import ( "fmt" "os" "path/filepath" - "sync/atomic" "github.com/datawire/dlib/dgroup" "github.com/datawire/dlib/dlog" - "github.com/jacobsa/fuse" "github.com/sirupsen/logrus" "lukeshu.com/btrfs-tools/pkg/btrfs" @@ -57,28 +55,13 @@ func Main(ctx context.Context, mountpoint string, imgfilenames ...string) (err e maybeSetErr(fs.Close()) }() - mounted := uint32(1) - grp := dgroup.NewGroup(ctx, dgroup.GroupConfig{ - ShutdownOnNonError: true, - }) - grp.Go("shutdown", func(ctx context.Context) error { - <-ctx.Done() - if atomic.LoadUint32(&mounted) == 0 { - return nil - } - return fuse.Unmount(os.Args[1]) - }) - grp.Go("mount", func(ctx context.Context) error { - defer atomic.StoreUint32(&mounted, 0) - rootSubvol := &Subvolume{ - Subvolume: btrfs.Subvolume{ - FS: fs, - TreeID: btrfs.FS_TREE_OBJECTID, - }, - DeviceName: tryAbs(imgfilenames[0]), - Mountpoint: mountpoint, - } - return rootSubvol.Run(ctx, false) - }) - return grp.Wait() + rootSubvol := &Subvolume{ + Subvolume: btrfs.Subvolume{ + FS: fs, + TreeID: btrfs.FS_TREE_OBJECTID, + }, + DeviceName: tryAbs(imgfilenames[0]), + Mountpoint: mountpoint, + } + return rootSubvol.Run(ctx) } |