diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-10 17:24:51 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-11 00:44:30 -0600 |
commit | bde202f286461ab575dc7e3d83f996d9a5f4a6ec (patch) | |
tree | 64782c354c15f64a164996125a06c1bca30c9aa7 /cmd/btrfs-mount/main.go | |
parent | d2da99882ea49cc67780c0255bf624698898e7fe (diff) |
Have a go at rearranging things in to a lib/btrfsprogs
Diffstat (limited to 'cmd/btrfs-mount/main.go')
-rw-r--r-- | cmd/btrfs-mount/main.go | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/cmd/btrfs-mount/main.go b/cmd/btrfs-mount/main.go index 0183c02..7debb3a 100644 --- a/cmd/btrfs-mount/main.go +++ b/cmd/btrfs-mount/main.go @@ -8,14 +8,13 @@ import ( "context" "fmt" "os" - "path/filepath" "github.com/datawire/dlib/dgroup" "github.com/datawire/dlib/dlog" "github.com/sirupsen/logrus" - "git.lukeshu.com/btrfs-progs-ng/lib/btrfs" - "git.lukeshu.com/btrfs-progs-ng/lib/btrfsmisc" + "git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsinspect" + "git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsutil" ) func main() { @@ -36,14 +35,6 @@ func main() { } } -func tryAbs(rel string) string { - abs, err := filepath.Abs(rel) - if err != nil { - return rel - } - return abs -} - func Main(ctx context.Context, mountpoint string, imgfilenames ...string) (err error) { maybeSetErr := func(_err error) { if _err != nil && err == nil { @@ -51,7 +42,7 @@ func Main(ctx context.Context, mountpoint string, imgfilenames ...string) (err e } } - fs, err := btrfsmisc.Open(os.O_RDONLY, imgfilenames...) + fs, err := btrfsutil.Open(os.O_RDONLY, imgfilenames...) if err != nil { return err } @@ -59,13 +50,5 @@ func Main(ctx context.Context, mountpoint string, imgfilenames ...string) (err e maybeSetErr(fs.Close()) }() - rootSubvol := &Subvolume{ - Subvolume: btrfs.Subvolume{ - FS: fs, - TreeID: btrfs.FS_TREE_OBJECTID, - }, - DeviceName: tryAbs(imgfilenames[0]), - Mountpoint: mountpoint, - } - return rootSubvol.Run(ctx) + return btrfsinspect.MountRO(ctx, fs, mountpoint) } |