summaryrefslogtreecommitdiff
path: root/lib/btrfsprogs/btrfsutil/open.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-03-14 21:31:30 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2023-03-14 21:31:30 -0600
commit9e9b4e8ac67052d667f6e7fae0a6620b6dbc50c7 (patch)
tree1aed8e061590b90a3158511a6e9a098851344516 /lib/btrfsprogs/btrfsutil/open.go
parent34bf167ef33c57b4d6767273f1d265971a4693b9 (diff)
parente92796fed05143239733d3feec0231a69af2f617 (diff)
Merge branch 'lukeshu/reorg'
Diffstat (limited to 'lib/btrfsprogs/btrfsutil/open.go')
-rw-r--r--lib/btrfsprogs/btrfsutil/open.go46
1 files changed, 0 insertions, 46 deletions
diff --git a/lib/btrfsprogs/btrfsutil/open.go b/lib/btrfsprogs/btrfsutil/open.go
deleted file mode 100644
index c5ee314..0000000
--- a/lib/btrfsprogs/btrfsutil/open.go
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com>
-//
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-package btrfsutil
-
-import (
- "context"
- "fmt"
- "os"
-
- "github.com/datawire/dlib/dlog"
-
- "git.lukeshu.com/btrfs-progs-ng/lib/btrfs"
- "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol"
- "git.lukeshu.com/btrfs-progs-ng/lib/diskio"
- "git.lukeshu.com/btrfs-progs-ng/lib/textui"
-)
-
-func Open(ctx context.Context, flag int, filenames ...string) (*btrfs.FS, error) {
- fs := new(btrfs.FS)
- for i, filename := range filenames {
- dlog.Debugf(ctx, "Adding device file %d/%d %q...", i, len(filenames), filename)
- osFile, err := os.OpenFile(filename, flag, 0)
- if err != nil {
- _ = fs.Close()
- return nil, fmt.Errorf("device file %q: %w", filename, err)
- }
- typedFile := &diskio.OSFile[btrfsvol.PhysicalAddr]{
- File: osFile,
- }
- bufFile := diskio.NewBufferedFile[btrfsvol.PhysicalAddr](
- typedFile,
- //nolint:gomnd // False positive: gomnd.ignored-functions=[textui.Tunable] doesn't support type params.
- textui.Tunable[btrfsvol.PhysicalAddr](16*1024), // block size: 16KiB
- textui.Tunable(1024), // number of blocks to buffer; total of 16MiB
- )
- devFile := &btrfs.Device{
- File: bufFile,
- }
- if err := fs.AddDevice(ctx, devFile); err != nil {
- return nil, fmt.Errorf("device file %q: %w", filename, err)
- }
- }
- return fs, nil
-}