summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-07-13 21:10:10 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-07-13 21:51:12 -0600
commit166e51d3a6f81834cc89aec36015f05f350be31e (patch)
tree122745341f3431b2220448d7d71965cd3e84aa97 /lib
parent296e9fc0f8812ce0c5684ff99f84e80eef07cd4c (diff)
Fix package names/imports
Diffstat (limited to 'lib')
-rw-r--r--lib/btrfs/aliases.go3
-rw-r--r--lib/btrfs/btrfsitem/item_chunk.go3
-rw-r--r--lib/btrfs/btrfsitem/item_dev.go5
-rw-r--r--lib/btrfs/btrfsitem/item_devextent.go3
-rw-r--r--lib/btrfs/btrfsitem/item_extent.go6
-rw-r--r--lib/btrfs/btrfsitem/item_inode.go9
-rw-r--r--lib/btrfs/btrfsitem/item_root.go10
-rw-r--r--lib/btrfs/btrfsitem/statmode.go2
-rw-r--r--lib/btrfs/btrfssum/csum.go4
-rw-r--r--lib/btrfs/btrfsvol/addr.go6
-rw-r--r--lib/btrfs/btrfsvol/blockgroupflags.go4
-rw-r--r--lib/btrfs/btrfsvol/lvm.go6
-rw-r--r--lib/btrfs/internal/uuid.go6
-rw-r--r--lib/btrfs/internal/uuid_test.go16
-rw-r--r--lib/btrfs/io1_pv.go12
-rw-r--r--lib/btrfs/io2_lv.go10
-rw-r--r--lib/btrfs/io3_btree.go14
-rw-r--r--lib/btrfs/io4_fs.go9
-rw-r--r--lib/btrfs/types_node.go13
-rw-r--r--lib/btrfs/types_superblock.go4
-rw-r--r--lib/btrfsprogs/btrfsinspect/mount.go3
-rw-r--r--lib/btrfsprogs/btrfsinspect/print_tree.go3
-rw-r--r--lib/btrfsprogs/btrfsinspect/recoverchunks.go4
-rw-r--r--lib/btrfsprogs/btrfsrepair/clearnodes.go6
-rw-r--r--lib/btrfsprogs/btrfsutil/broken_btree.go6
-rw-r--r--lib/btrfsprogs/btrfsutil/scan.go4
-rw-r--r--lib/containers/lru.go2
-rw-r--r--lib/diskio/ref.go2
-rw-r--r--lib/fmtutil/bitfield.go2
-rw-r--r--lib/fmtutil/fmt.go2
-rw-r--r--lib/fmtutil/fmt_test.go8
31 files changed, 94 insertions, 93 deletions
diff --git a/lib/btrfs/aliases.go b/lib/btrfs/aliases.go
index 5115654..6fe5661 100644
--- a/lib/btrfs/aliases.go
+++ b/lib/btrfs/aliases.go
@@ -6,7 +6,6 @@ package btrfs
import (
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/internal"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
)
type (
@@ -19,5 +18,5 @@ type (
Key = internal.Key
Time = internal.Time
- UUID = util.UUID
+ UUID = internal.UUID
)
diff --git a/lib/btrfs/btrfsitem/item_chunk.go b/lib/btrfs/btrfsitem/item_chunk.go
index 2ccc860..754d650 100644
--- a/lib/btrfs/btrfsitem/item_chunk.go
+++ b/lib/btrfs/btrfsitem/item_chunk.go
@@ -8,7 +8,6 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/binstruct"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/internal"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
)
// Maps logical address to physical.
@@ -36,7 +35,7 @@ type ChunkHeader struct {
type ChunkStripe struct {
DeviceID btrfsvol.DeviceID `bin:"off=0x0, siz=0x8"`
Offset btrfsvol.PhysicalAddr `bin:"off=0x8, siz=0x8"`
- DeviceUUID util.UUID `bin:"off=0x10, siz=0x10"`
+ DeviceUUID internal.UUID `bin:"off=0x10, siz=0x10"`
binstruct.End `bin:"off=0x20"`
}
diff --git a/lib/btrfs/btrfsitem/item_dev.go b/lib/btrfs/btrfsitem/item_dev.go
index 9c3781d..020f2ca 100644
--- a/lib/btrfs/btrfsitem/item_dev.go
+++ b/lib/btrfs/btrfsitem/item_dev.go
@@ -8,7 +8,6 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/binstruct"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/internal"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
)
// key.objectid = BTRFS_DEV_ITEMS_OBJECTID
@@ -30,8 +29,8 @@ type Dev struct { // DEV_ITEM=216
SeekSpeed uint8 `bin:"off=0x40, siz=0x1"`
Bandwidth uint8 `bin:"off=0x41, siz=0x1"`
- DevUUID util.UUID `bin:"off=0x42, siz=0x10"`
- FSUUID util.UUID `bin:"off=0x52, siz=0x10"`
+ DevUUID internal.UUID `bin:"off=0x42, siz=0x10"`
+ FSUUID internal.UUID `bin:"off=0x52, siz=0x10"`
binstruct.End `bin:"off=0x62"`
}
diff --git a/lib/btrfs/btrfsitem/item_devextent.go b/lib/btrfs/btrfsitem/item_devextent.go
index 3185bb0..8eca935 100644
--- a/lib/btrfs/btrfsitem/item_devextent.go
+++ b/lib/btrfs/btrfsitem/item_devextent.go
@@ -8,7 +8,6 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/binstruct"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/internal"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
)
// key.objectid = device_id
@@ -18,7 +17,7 @@ type DevExtent struct { // DEV_EXTENT=204
ChunkObjectID internal.ObjID `bin:"off=8, siz=8"`
ChunkOffset btrfsvol.LogicalAddr `bin:"off=16, siz=8"`
Length btrfsvol.AddrDelta `bin:"off=24, siz=8"`
- ChunkTreeUUID util.UUID `bin:"off=32, siz=16"`
+ ChunkTreeUUID internal.UUID `bin:"off=32, siz=16"`
binstruct.End `bin:"off=48"`
}
diff --git a/lib/btrfs/btrfsitem/item_extent.go b/lib/btrfs/btrfsitem/item_extent.go
index d49243d..e8cd9b9 100644
--- a/lib/btrfs/btrfsitem/item_extent.go
+++ b/lib/btrfs/btrfsitem/item_extent.go
@@ -9,7 +9,7 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/binstruct"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/internal"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
+ "git.lukeshu.com/btrfs-progs-ng/lib/fmtutil"
)
type Extent struct { // EXTENT_ITEM=168
@@ -91,7 +91,9 @@ var extentFlagNames = []string{
}
func (f ExtentFlags) Has(req ExtentFlags) bool { return f&req == req }
-func (f ExtentFlags) String() string { return util.BitfieldString(f, extentFlagNames, util.HexNone) }
+func (f ExtentFlags) String() string {
+ return fmtutil.BitfieldString(f, extentFlagNames, fmtutil.HexNone)
+}
type ExtentInlineRef struct {
Type Type // only 4 valid values: {TREE,SHARED}_BLOCK_REF_KEY, {EXTENT,SHARED}_DATA_REF_KEY
diff --git a/lib/btrfs/btrfsitem/item_inode.go b/lib/btrfs/btrfsitem/item_inode.go
index 0fb637e..27204f6 100644
--- a/lib/btrfs/btrfsitem/item_inode.go
+++ b/lib/btrfs/btrfsitem/item_inode.go
@@ -7,8 +7,7 @@ package btrfsitem
import (
"git.lukeshu.com/btrfs-progs-ng/lib/binstruct"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/internal"
- "git.lukeshu.com/btrfs-progs-ng/lib/linux"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
+ "git.lukeshu.com/btrfs-progs-ng/lib/fmtutil"
)
type Inode struct { // INODE_ITEM=1
@@ -20,7 +19,7 @@ type Inode struct { // INODE_ITEM=1
NLink int32 `bin:"off=0x28, siz=0x04"` // stat
UID int32 `bin:"off=0x2C, siz=0x04"` // stat
GID int32 `bin:"off=0x30, siz=0x04"` // stat
- Mode linux.StatMode `bin:"off=0x34, siz=0x04"` // stat
+ Mode StatMode `bin:"off=0x34, siz=0x04"` // stat
RDev int64 `bin:"off=0x38, siz=0x08"` // stat
Flags InodeFlags `bin:"off=0x40, siz=0x08"` // statx.stx_attributes, sorta
Sequence int64 `bin:"off=0x48, siz=0x08"` // NFS
@@ -65,4 +64,6 @@ var inodeFlagNames = []string{
}
func (f InodeFlags) Has(req InodeFlags) bool { return f&req == req }
-func (f InodeFlags) String() string { return util.BitfieldString(f, inodeFlagNames, util.HexLower) }
+func (f InodeFlags) String() string {
+ return fmtutil.BitfieldString(f, inodeFlagNames, fmtutil.HexLower)
+}
diff --git a/lib/btrfs/btrfsitem/item_root.go b/lib/btrfs/btrfsitem/item_root.go
index d1781ec..7725363 100644
--- a/lib/btrfs/btrfsitem/item_root.go
+++ b/lib/btrfs/btrfsitem/item_root.go
@@ -8,7 +8,7 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/binstruct"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/internal"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
+ "git.lukeshu.com/btrfs-progs-ng/lib/fmtutil"
)
type Root struct { // ROOT_ITEM=132
@@ -25,9 +25,9 @@ type Root struct { // ROOT_ITEM=132
DropLevel uint8 `bin:"off=0x0ed, siz=0x01"`
Level uint8 `bin:"off=0x0ee, siz=0x01"`
GenerationV2 internal.Generation `bin:"off=0x0ef, siz=0x08"`
- UUID util.UUID `bin:"off=0x0f7, siz=0x10"`
- ParentUUID util.UUID `bin:"off=0x107, siz=0x10"`
- ReceivedUUID util.UUID `bin:"off=0x117, siz=0x10"`
+ UUID internal.UUID `bin:"off=0x0f7, siz=0x10"`
+ ParentUUID internal.UUID `bin:"off=0x107, siz=0x10"`
+ ReceivedUUID internal.UUID `bin:"off=0x117, siz=0x10"`
CTransID int64 `bin:"off=0x127, siz=0x08"`
OTransID int64 `bin:"off=0x12f, siz=0x08"`
STransID int64 `bin:"off=0x137, siz=0x08"`
@@ -52,4 +52,4 @@ var rootFlagNames = []string{
}
func (f RootFlags) Has(req RootFlags) bool { return f&req == req }
-func (f RootFlags) String() string { return util.BitfieldString(f, rootFlagNames, util.HexLower) }
+func (f RootFlags) String() string { return fmtutil.BitfieldString(f, rootFlagNames, fmtutil.HexLower) }
diff --git a/lib/btrfs/btrfsitem/statmode.go b/lib/btrfs/btrfsitem/statmode.go
index 2cca56d..a1302ee 100644
--- a/lib/btrfs/btrfsitem/statmode.go
+++ b/lib/btrfs/btrfsitem/statmode.go
@@ -5,7 +5,7 @@
//
// Based on https://github.com/datawire/ocibuild/blob/master/pkg/python/stat.go
-package linux
+package btrfsitem
type StatMode uint32
diff --git a/lib/btrfs/btrfssum/csum.go b/lib/btrfs/btrfssum/csum.go
index 231393b..8f9ac1a 100644
--- a/lib/btrfs/btrfssum/csum.go
+++ b/lib/btrfs/btrfssum/csum.go
@@ -10,7 +10,7 @@ import (
"fmt"
"hash/crc32"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
+ "git.lukeshu.com/btrfs-progs-ng/lib/fmtutil"
)
type CSum [0x20]byte
@@ -24,7 +24,7 @@ func (csum CSum) Fmt(typ CSumType) string {
}
func (csum CSum) Format(f fmt.State, verb rune) {
- util.FormatByteArrayStringer(csum, csum[:], f, verb)
+ fmtutil.FormatByteArrayStringer(csum, csum[:], f, verb)
}
type CSumType uint16
diff --git a/lib/btrfs/btrfsvol/addr.go b/lib/btrfs/btrfsvol/addr.go
index 9df95ce..640a3e8 100644
--- a/lib/btrfs/btrfsvol/addr.go
+++ b/lib/btrfs/btrfsvol/addr.go
@@ -7,7 +7,7 @@ package btrfsvol
import (
"fmt"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
+ "git.lukeshu.com/btrfs-progs-ng/lib/fmtutil"
)
type (
@@ -20,9 +20,9 @@ func formatAddr(addr int64, f fmt.State, verb rune) {
switch verb {
case 'v', 's', 'q':
str := fmt.Sprintf("%#016x", addr)
- fmt.Fprintf(f, util.FmtStateString(f, verb), str)
+ fmt.Fprintf(f, fmtutil.FmtStateString(f, verb), str)
default:
- fmt.Fprintf(f, util.FmtStateString(f, verb), addr)
+ fmt.Fprintf(f, fmtutil.FmtStateString(f, verb), addr)
}
}
diff --git a/lib/btrfs/btrfsvol/blockgroupflags.go b/lib/btrfs/btrfsvol/blockgroupflags.go
index 4aed12c..4ca5544 100644
--- a/lib/btrfs/btrfsvol/blockgroupflags.go
+++ b/lib/btrfs/btrfsvol/blockgroupflags.go
@@ -5,7 +5,7 @@
package btrfsvol
import (
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
+ "git.lukeshu.com/btrfs-progs-ng/lib/fmtutil"
)
type BlockGroupFlags uint64
@@ -43,7 +43,7 @@ var blockGroupFlagNames = []string{
func (f BlockGroupFlags) Has(req BlockGroupFlags) bool { return f&req == req }
func (f BlockGroupFlags) String() string {
- ret := util.BitfieldString(f, blockGroupFlagNames, util.HexNone)
+ ret := fmtutil.BitfieldString(f, blockGroupFlagNames, fmtutil.HexNone)
if f&BLOCK_GROUP_RAID_MASK == 0 {
if ret == "" {
ret = "single"
diff --git a/lib/btrfs/btrfsvol/lvm.go b/lib/btrfs/btrfsvol/lvm.go
index 62ca6d7..4d40ccd 100644
--- a/lib/btrfs/btrfsvol/lvm.go
+++ b/lib/btrfs/btrfsvol/lvm.go
@@ -11,10 +11,10 @@ import (
"reflect"
"git.lukeshu.com/btrfs-progs-ng/lib/containers"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
+ "git.lukeshu.com/btrfs-progs-ng/lib/diskio"
)
-type LogicalVolume[PhysicalVolume util.File[PhysicalAddr]] struct {
+type LogicalVolume[PhysicalVolume diskio.File[PhysicalAddr]] struct {
name string
id2pv map[DeviceID]PhysicalVolume
@@ -23,7 +23,7 @@ type LogicalVolume[PhysicalVolume util.File[PhysicalAddr]] struct {
physical2logical map[DeviceID]*containers.RBTree[containers.NativeOrdered[PhysicalAddr], devextMapping]
}
-var _ util.File[LogicalAddr] = (*LogicalVolume[util.File[PhysicalAddr]])(nil)
+var _ diskio.File[LogicalAddr] = (*LogicalVolume[diskio.File[PhysicalAddr]])(nil)
func (lv *LogicalVolume[PhysicalVolume]) init() {
if lv.id2pv == nil {
diff --git a/lib/btrfs/internal/uuid.go b/lib/btrfs/internal/uuid.go
index a16d10f..3749b1a 100644
--- a/lib/btrfs/internal/uuid.go
+++ b/lib/btrfs/internal/uuid.go
@@ -2,12 +2,14 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later
-package util
+package internal
import (
"encoding/hex"
"fmt"
"strings"
+
+ "git.lukeshu.com/btrfs-progs-ng/lib/fmtutil"
)
type UUID [16]byte
@@ -33,7 +35,7 @@ func (a UUID) Cmp(b UUID) int {
}
func (uuid UUID) Format(f fmt.State, verb rune) {
- FormatByteArrayStringer(uuid, uuid[:], f, verb)
+ fmtutil.FormatByteArrayStringer(uuid, uuid[:], f, verb)
}
func ParseUUID(str string) (UUID, error) {
diff --git a/lib/btrfs/internal/uuid_test.go b/lib/btrfs/internal/uuid_test.go
index 747ff6b..dfc3688 100644
--- a/lib/btrfs/internal/uuid_test.go
+++ b/lib/btrfs/internal/uuid_test.go
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later
-package util_test
+package internal_test
import (
"fmt"
@@ -10,18 +10,18 @@ import (
"github.com/stretchr/testify/assert"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
+ "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/internal"
)
func TestParseUUID(t *testing.T) {
t.Parallel()
type TestCase struct {
Input string
- OutputVal util.UUID
+ OutputVal internal.UUID
OutputErr string
}
testcases := map[string]TestCase{
- "basic": {Input: "a0dd94ed-e60c-42e8-8632-64e8d4765a43", OutputVal: util.UUID{0xa0, 0xdd, 0x94, 0xed, 0xe6, 0x0c, 0x42, 0xe8, 0x86, 0x32, 0x64, 0xe8, 0xd4, 0x76, 0x5a, 0x43}},
+ "basic": {Input: "a0dd94ed-e60c-42e8-8632-64e8d4765a43", OutputVal: internal.UUID{0xa0, 0xdd, 0x94, 0xed, 0xe6, 0x0c, 0x42, 0xe8, 0x86, 0x32, 0x64, 0xe8, 0xd4, 0x76, 0x5a, 0x43}},
"too-long": {Input: "a0dd94ed-e60c-42e8-8632-64e8d4765a43a", OutputErr: `too long to be a UUID: "a0dd94ed-e60c-42e8-8632-64e8d4765a43"|"a"`},
"bad char": {Input: "a0dd94ej-e60c-42e8-8632-64e8d4765a43a", OutputErr: `illegal byte in UUID: "a0dd94e"|"j"|"-e60c-42e8-8632-64e8d4765a43a"`},
}
@@ -29,7 +29,7 @@ func TestParseUUID(t *testing.T) {
tc := tc
t.Run(tcName, func(t *testing.T) {
t.Parallel()
- val, err := util.ParseUUID(tc.Input)
+ val, err := internal.ParseUUID(tc.Input)
assert.Equal(t, tc.OutputVal, val)
if tc.OutputErr == "" {
assert.NoError(t, err)
@@ -43,18 +43,18 @@ func TestParseUUID(t *testing.T) {
func TestUUIDFormat(t *testing.T) {
t.Parallel()
type TestCase struct {
- InputUUID util.UUID
+ InputUUID internal.UUID
InputFmt string
Output string
}
- uuid := util.MustParseUUID("a0dd94ed-e60c-42e8-8632-64e8d4765a43")
+ uuid := internal.MustParseUUID("a0dd94ed-e60c-42e8-8632-64e8d4765a43")
testcases := map[string]TestCase{
"s": {InputUUID: uuid, InputFmt: "%s", Output: "a0dd94ed-e60c-42e8-8632-64e8d4765a43"},
"x": {InputUUID: uuid, InputFmt: "%x", Output: "a0dd94ede60c42e8863264e8d4765a43"},
"X": {InputUUID: uuid, InputFmt: "%X", Output: "A0DD94EDE60C42E8863264E8D4765A43"},
"v": {InputUUID: uuid, InputFmt: "%v", Output: "a0dd94ed-e60c-42e8-8632-64e8d4765a43"},
"40s": {InputUUID: uuid, InputFmt: "|% 40s", Output: "| a0dd94ed-e60c-42e8-8632-64e8d4765a43"},
- "#115v": {InputUUID: uuid, InputFmt: "|%#115v", Output: "| util.UUID{0xa0, 0xdd, 0x94, 0xed, 0xe6, 0xc, 0x42, 0xe8, 0x86, 0x32, 0x64, 0xe8, 0xd4, 0x76, 0x5a, 0x43}"},
+ "#115v": {InputUUID: uuid, InputFmt: "|%#115v", Output: "| internal.UUID{0xa0, 0xdd, 0x94, 0xed, 0xe6, 0xc, 0x42, 0xe8, 0x86, 0x32, 0x64, 0xe8, 0xd4, 0x76, 0x5a, 0x43}"},
}
for tcName, tc := range testcases {
tc := tc
diff --git a/lib/btrfs/io1_pv.go b/lib/btrfs/io1_pv.go
index 44a8d76..10b6e32 100644
--- a/lib/btrfs/io1_pv.go
+++ b/lib/btrfs/io1_pv.go
@@ -10,17 +10,17 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/binstruct"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
+ "git.lukeshu.com/btrfs-progs-ng/lib/diskio"
)
type Device struct {
*os.File
- cacheSuperblocks []*util.Ref[btrfsvol.PhysicalAddr, Superblock]
+ cacheSuperblocks []*diskio.Ref[btrfsvol.PhysicalAddr, Superblock]
cacheSuperblock *Superblock
}
-var _ util.File[btrfsvol.PhysicalAddr] = (*Device)(nil)
+var _ diskio.File[btrfsvol.PhysicalAddr] = (*Device)(nil)
func (dev Device) Size() (btrfsvol.PhysicalAddr, error) {
fi, err := dev.Stat()
@@ -44,7 +44,7 @@ var SuperblockAddrs = []btrfsvol.PhysicalAddr{
0x40_0000_0000, // 256GiB
}
-func (dev *Device) Superblocks() ([]*util.Ref[btrfsvol.PhysicalAddr, Superblock], error) {
+func (dev *Device) Superblocks() ([]*diskio.Ref[btrfsvol.PhysicalAddr, Superblock], error) {
if dev.cacheSuperblocks != nil {
return dev.cacheSuperblocks, nil
}
@@ -55,10 +55,10 @@ func (dev *Device) Superblocks() ([]*util.Ref[btrfsvol.PhysicalAddr, Superblock]
return nil, err
}
- var ret []*util.Ref[btrfsvol.PhysicalAddr, Superblock]
+ var ret []*diskio.Ref[btrfsvol.PhysicalAddr, Superblock]
for i, addr := range SuperblockAddrs {
if addr+superblockSize <= sz {
- superblock := &util.Ref[btrfsvol.PhysicalAddr, Superblock]{
+ superblock := &diskio.Ref[btrfsvol.PhysicalAddr, Superblock]{
File: dev,
Addr: addr,
}
diff --git a/lib/btrfs/io2_lv.go b/lib/btrfs/io2_lv.go
index b3f9276..47ab474 100644
--- a/lib/btrfs/io2_lv.go
+++ b/lib/btrfs/io2_lv.go
@@ -14,7 +14,7 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsitem"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
+ "git.lukeshu.com/btrfs-progs-ng/lib/diskio"
)
type FS struct {
@@ -22,11 +22,11 @@ type FS struct {
// implementing special things like fsck.
LV btrfsvol.LogicalVolume[*Device]
- cacheSuperblocks []*util.Ref[btrfsvol.PhysicalAddr, Superblock]
+ cacheSuperblocks []*diskio.Ref[btrfsvol.PhysicalAddr, Superblock]
cacheSuperblock *Superblock
}
-var _ util.File[btrfsvol.LogicalAddr] = (*FS)(nil)
+var _ diskio.File[btrfsvol.LogicalAddr] = (*FS)(nil)
func (fs *FS) AddDevice(ctx context.Context, dev *Device) error {
sb, err := dev.Superblock()
@@ -72,11 +72,11 @@ func (fs *FS) Resolve(laddr btrfsvol.LogicalAddr) (paddrs map[btrfsvol.Qualified
return fs.LV.Resolve(laddr)
}
-func (fs *FS) Superblocks() ([]*util.Ref[btrfsvol.PhysicalAddr, Superblock], error) {
+func (fs *FS) Superblocks() ([]*diskio.Ref[btrfsvol.PhysicalAddr, Superblock], error) {
if fs.cacheSuperblocks != nil {
return fs.cacheSuperblocks, nil
}
- var ret []*util.Ref[btrfsvol.PhysicalAddr, Superblock]
+ var ret []*diskio.Ref[btrfsvol.PhysicalAddr, Superblock]
devs := fs.LV.PhysicalVolumes()
if len(devs) == 0 {
return nil, fmt.Errorf("no devices")
diff --git a/lib/btrfs/io3_btree.go b/lib/btrfs/io3_btree.go
index f476dae..553bf41 100644
--- a/lib/btrfs/io3_btree.go
+++ b/lib/btrfs/io3_btree.go
@@ -15,8 +15,8 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsitem"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol"
+ "git.lukeshu.com/btrfs-progs-ng/lib/diskio"
"git.lukeshu.com/btrfs-progs-ng/lib/slices"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
)
type Trees interface {
@@ -260,9 +260,9 @@ func LookupTreeRoot(fs Trees, treeID ObjID) (*TreeRoot, error) {
type TreeWalkHandler struct {
// Callbacks for entire nodes
PreNode func(TreePath) error
- Node func(TreePath, *util.Ref[btrfsvol.LogicalAddr, Node]) error
- BadNode func(TreePath, *util.Ref[btrfsvol.LogicalAddr, Node], error) error
- PostNode func(TreePath, *util.Ref[btrfsvol.LogicalAddr, Node]) error
+ Node func(TreePath, *diskio.Ref[btrfsvol.LogicalAddr, Node]) error
+ BadNode func(TreePath, *diskio.Ref[btrfsvol.LogicalAddr, Node], error) error
+ PostNode func(TreePath, *diskio.Ref[btrfsvol.LogicalAddr, Node]) error
// Callbacks for items on internal nodes
PreKeyPointer func(TreePath, KeyPointer) error
PostKeyPointer func(TreePath, KeyPointer) error
@@ -402,7 +402,7 @@ func (fs *FS) treeWalk(ctx context.Context, path TreePath, errHandle func(*TreeE
}
}
-func (fs *FS) treeSearch(treeRoot TreeRoot, fn func(Key) int) (TreePath, *util.Ref[btrfsvol.LogicalAddr, Node], error) {
+func (fs *FS) treeSearch(treeRoot TreeRoot, fn func(Key) int) (TreePath, *diskio.Ref[btrfsvol.LogicalAddr, Node], error) {
path := TreePath{
TreeID: treeRoot.TreeID,
Nodes: []TreePathElem{
@@ -487,7 +487,7 @@ func (fs *FS) treeSearch(treeRoot TreeRoot, fn func(Key) int) (TreePath, *util.R
}
}
-func (fs *FS) prev(path TreePath, node *util.Ref[btrfsvol.LogicalAddr, Node]) (TreePath, *util.Ref[btrfsvol.LogicalAddr, Node], error) {
+func (fs *FS) prev(path TreePath, node *diskio.Ref[btrfsvol.LogicalAddr, Node]) (TreePath, *diskio.Ref[btrfsvol.LogicalAddr, Node], error) {
var err error
path = path.DeepCopy()
@@ -539,7 +539,7 @@ func (fs *FS) prev(path TreePath, node *util.Ref[btrfsvol.LogicalAddr, Node]) (T
return path, node, nil
}
-func (fs *FS) next(path TreePath, node *util.Ref[btrfsvol.LogicalAddr, Node]) (TreePath, *util.Ref[btrfsvol.LogicalAddr, Node], error) {
+func (fs *FS) next(path TreePath, node *diskio.Ref[btrfsvol.LogicalAddr, Node]) (TreePath, *diskio.Ref[btrfsvol.LogicalAddr, Node], error) {
var err error
path = path.DeepCopy()
diff --git a/lib/btrfs/io4_fs.go b/lib/btrfs/io4_fs.go
index cae2771..701230e 100644
--- a/lib/btrfs/io4_fs.go
+++ b/lib/btrfs/io4_fs.go
@@ -19,7 +19,6 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/containers"
"git.lukeshu.com/btrfs-progs-ng/lib/maps"
"git.lukeshu.com/btrfs-progs-ng/lib/slices"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
)
type BareInode struct {
@@ -65,10 +64,10 @@ type Subvolume struct {
rootVal btrfsitem.Root
rootErr error
- bareInodeCache util.LRUCache[ObjID, *BareInode]
- fullInodeCache util.LRUCache[ObjID, *FullInode]
- dirCache util.LRUCache[ObjID, *Dir]
- fileCache util.LRUCache[ObjID, *File]
+ bareInodeCache containers.LRUCache[ObjID, *BareInode]
+ fullInodeCache containers.LRUCache[ObjID, *FullInode]
+ dirCache containers.LRUCache[ObjID, *Dir]
+ fileCache containers.LRUCache[ObjID, *File]
}
func (sv *Subvolume) init() {
diff --git a/lib/btrfs/types_node.go b/lib/btrfs/types_node.go
index fc12a00..781b2fa 100644
--- a/lib/btrfs/types_node.go
+++ b/lib/btrfs/types_node.go
@@ -13,7 +13,8 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsitem"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfssum"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
+ "git.lukeshu.com/btrfs-progs-ng/lib/diskio"
+ "git.lukeshu.com/btrfs-progs-ng/lib/fmtutil"
)
type NodeFlags uint64
@@ -50,7 +51,7 @@ var nodeFlagNames = []string{
}
func (f NodeFlags) Has(req NodeFlags) bool { return f&req == req }
-func (f NodeFlags) String() string { return util.BitfieldString(f, nodeFlagNames, util.HexLower) }
+func (f NodeFlags) String() string { return fmtutil.BitfieldString(f, nodeFlagNames, fmtutil.HexLower) }
type BackrefRev uint8
@@ -347,7 +348,7 @@ func (node *Node) LeafFreeSpace() uint32 {
var ErrNotANode = errors.New("does not look like a node")
-func ReadNode[Addr ~int64](fs util.File[Addr], sb Superblock, addr Addr, laddrCB func(btrfsvol.LogicalAddr) error) (*util.Ref[Addr, Node], error) {
+func ReadNode[Addr ~int64](fs diskio.File[Addr], sb Superblock, addr Addr, laddrCB func(btrfsvol.LogicalAddr) error) (*diskio.Ref[Addr, Node], error) {
nodeBuf := make([]byte, sb.NodeSize)
if _, err := fs.ReadAt(nodeBuf, addr); err != nil {
return nil, err
@@ -355,7 +356,7 @@ func ReadNode[Addr ~int64](fs util.File[Addr], sb Superblock, addr Addr, laddrCB
// parse (early)
- nodeRef := &util.Ref[Addr, Node]{
+ nodeRef := &diskio.Ref[Addr, Node]{
File: fs,
Addr: addr,
Data: Node{
@@ -400,7 +401,7 @@ func ReadNode[Addr ~int64](fs util.File[Addr], sb Superblock, addr Addr, laddrCB
return nodeRef, nil
}
-func (fs *FS) ReadNode(addr btrfsvol.LogicalAddr) (*util.Ref[btrfsvol.LogicalAddr, Node], error) {
+func (fs *FS) ReadNode(addr btrfsvol.LogicalAddr) (*diskio.Ref[btrfsvol.LogicalAddr, Node], error) {
sb, err := fs.Superblock()
if err != nil {
return nil, fmt.Errorf("btrfs.FS.ReadNode: %w", err)
@@ -415,7 +416,7 @@ func (fs *FS) ReadNode(addr btrfsvol.LogicalAddr) (*util.Ref[btrfsvol.LogicalAdd
})
}
-func (fs *FS) readNodeAtLevel(addr btrfsvol.LogicalAddr, expLevel uint8) (*util.Ref[btrfsvol.LogicalAddr, Node], error) {
+func (fs *FS) readNodeAtLevel(addr btrfsvol.LogicalAddr, expLevel uint8) (*diskio.Ref[btrfsvol.LogicalAddr, Node], error) {
node, err := fs.ReadNode(addr)
if err != nil {
return node, err
diff --git a/lib/btrfs/types_superblock.go b/lib/btrfs/types_superblock.go
index 30adb86..68c5d56 100644
--- a/lib/btrfs/types_superblock.go
+++ b/lib/btrfs/types_superblock.go
@@ -12,7 +12,7 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsitem"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfssum"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
+ "git.lukeshu.com/btrfs-progs-ng/lib/fmtutil"
)
type Superblock struct {
@@ -233,5 +233,5 @@ var incompatFlagNames = []string{
func (f IncompatFlags) Has(req IncompatFlags) bool { return f&req == req }
func (f IncompatFlags) String() string {
- return util.BitfieldString(f, incompatFlagNames, util.HexLower)
+ return fmtutil.BitfieldString(f, incompatFlagNames, fmtutil.HexLower)
}
diff --git a/lib/btrfsprogs/btrfsinspect/mount.go b/lib/btrfsprogs/btrfsinspect/mount.go
index c882c65..05f3b9b 100644
--- a/lib/btrfsprogs/btrfsinspect/mount.go
+++ b/lib/btrfsprogs/btrfsinspect/mount.go
@@ -25,7 +25,6 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsitem"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsutil"
"git.lukeshu.com/btrfs-progs-ng/lib/containers"
- "git.lukeshu.com/btrfs-progs-ng/lib/linux"
"git.lukeshu.com/btrfs-progs-ng/lib/maps"
"git.lukeshu.com/btrfs-progs-ng/lib/slices"
)
@@ -258,7 +257,7 @@ func (sv *subvolume) LookUpInode(_ context.Context, op *fuseops.LookUpInodeOp) e
Child: 2, // an inode number that a real file will never have
Attributes: fuseops.InodeAttributes{
Nlink: 1,
- Mode: uint32(linux.ModeFmtDir | 0700),
+ Mode: uint32(btrfsitem.ModeFmtDir | 0700),
},
}
return nil
diff --git a/lib/btrfsprogs/btrfsinspect/print_tree.go b/lib/btrfsprogs/btrfsinspect/print_tree.go
index 8aef98a..960dcce 100644
--- a/lib/btrfsprogs/btrfsinspect/print_tree.go
+++ b/lib/btrfsprogs/btrfsinspect/print_tree.go
@@ -17,6 +17,7 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsitem"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfssum"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol"
+ "git.lukeshu.com/btrfs-progs-ng/lib/diskio"
"git.lukeshu.com/btrfs-progs-ng/lib/slices"
"git.lukeshu.com/btrfs-progs-ng/lib/util"
)
@@ -95,7 +96,7 @@ func DumpTrees(ctx context.Context, out io.Writer, fs *btrfs.FS) {
func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfs.ObjID) {
var itemOffset uint32
handlers := btrfs.TreeWalkHandler{
- Node: func(path btrfs.TreePath, nodeRef *util.Ref[btrfsvol.LogicalAddr, btrfs.Node]) error {
+ Node: func(path btrfs.TreePath, nodeRef *diskio.Ref[btrfsvol.LogicalAddr, btrfs.Node]) error {
printHeaderInfo(out, nodeRef.Data)
itemOffset = nodeRef.Data.Size - uint32(binstruct.StaticSize(btrfs.NodeHeader{}))
return nil
diff --git a/lib/btrfsprogs/btrfsinspect/recoverchunks.go b/lib/btrfsprogs/btrfsinspect/recoverchunks.go
index 4f01d0a..27ac85b 100644
--- a/lib/btrfsprogs/btrfsinspect/recoverchunks.go
+++ b/lib/btrfsprogs/btrfsinspect/recoverchunks.go
@@ -14,8 +14,8 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsitem"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsutil"
+ "git.lukeshu.com/btrfs-progs-ng/lib/diskio"
"git.lukeshu.com/btrfs-progs-ng/lib/maps"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
)
type ScanOneDevResult struct {
@@ -158,7 +158,7 @@ func ScanOneDev(ctx context.Context, dev *btrfs.Device, superblock btrfs.Superbl
devSize, _ := dev.Size()
lastProgress := -1
- err := btrfsutil.ScanForNodes(ctx, dev, superblock, func(nodeRef *util.Ref[btrfsvol.PhysicalAddr, btrfs.Node], err error) {
+ err := btrfsutil.ScanForNodes(ctx, dev, superblock, func(nodeRef *diskio.Ref[btrfsvol.PhysicalAddr, btrfs.Node], err error) {
if err != nil {
dlog.Infof(ctx, "... dev[%q] error: %v", dev.Name(), err)
return
diff --git a/lib/btrfsprogs/btrfsrepair/clearnodes.go b/lib/btrfsprogs/btrfsrepair/clearnodes.go
index 9fa5a6a..9f1e42c 100644
--- a/lib/btrfsprogs/btrfsrepair/clearnodes.go
+++ b/lib/btrfsprogs/btrfsrepair/clearnodes.go
@@ -14,7 +14,7 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsutil"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
+ "git.lukeshu.com/btrfs-progs-ng/lib/diskio"
)
func ClearBadNodes(ctx context.Context, fs *btrfs.FS) error {
@@ -26,7 +26,7 @@ func ClearBadNodes(ctx context.Context, fs *btrfs.FS) error {
dlog.Error(ctx, err)
},
TreeWalkHandler: btrfs.TreeWalkHandler{
- Node: func(path btrfs.TreePath, node *util.Ref[btrfsvol.LogicalAddr, btrfs.Node]) error {
+ Node: func(path btrfs.TreePath, node *diskio.Ref[btrfsvol.LogicalAddr, btrfs.Node]) error {
if !uuidsInited {
metadataUUID = node.Data.Head.MetadataUUID
chunkTreeUUID = node.Data.Head.ChunkTreeUUID
@@ -34,7 +34,7 @@ func ClearBadNodes(ctx context.Context, fs *btrfs.FS) error {
}
return nil
},
- BadNode: func(path btrfs.TreePath, node *util.Ref[btrfsvol.LogicalAddr, btrfs.Node], err error) error {
+ BadNode: func(path btrfs.TreePath, node *diskio.Ref[btrfsvol.LogicalAddr, btrfs.Node], err error) error {
if !errors.Is(err, btrfs.ErrNotANode) {
return err
}
diff --git a/lib/btrfsprogs/btrfsutil/broken_btree.go b/lib/btrfsprogs/btrfsutil/broken_btree.go
index d2dc81c..6c97fcb 100644
--- a/lib/btrfsprogs/btrfsutil/broken_btree.go
+++ b/lib/btrfsprogs/btrfsutil/broken_btree.go
@@ -15,7 +15,7 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol"
"git.lukeshu.com/btrfs-progs-ng/lib/containers"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
+ "git.lukeshu.com/btrfs-progs-ng/lib/diskio"
)
type indexItem struct {
@@ -170,7 +170,7 @@ func (bt *brokenTrees) TreeSearchAll(treeID btrfs.ObjID, fn func(btrfs.Key) int)
}
ret := make([]btrfs.Item, len(indexItems))
- var node *util.Ref[btrfsvol.LogicalAddr, btrfs.Node]
+ var node *diskio.Ref[btrfsvol.LogicalAddr, btrfs.Node]
for i := range indexItems {
if node == nil || node.Addr != indexItems[i].Path.Node(-2).NodeAddr {
var err error
@@ -195,7 +195,7 @@ func (bt *brokenTrees) TreeWalk(ctx context.Context, treeID btrfs.ObjID, errHand
})
return
}
- var node *util.Ref[btrfsvol.LogicalAddr, btrfs.Node]
+ var node *diskio.Ref[btrfsvol.LogicalAddr, btrfs.Node]
_ = index.Walk(func(indexItem *containers.RBNode[indexItem]) error {
if ctx.Err() != nil {
return ctx.Err()
diff --git a/lib/btrfsprogs/btrfsutil/scan.go b/lib/btrfsprogs/btrfsutil/scan.go
index 7189e99..dd77747 100644
--- a/lib/btrfsprogs/btrfsutil/scan.go
+++ b/lib/btrfsprogs/btrfsutil/scan.go
@@ -11,15 +11,15 @@ import (
"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/slices"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
)
// ScanForNodes mimics btrfs-progs
// cmds/rescue-chunk-recover.c:scan_one_device(), except rather than
// doing something itself when it finds a node, it simply calls a
// callback function.
-func ScanForNodes(ctx context.Context, dev *btrfs.Device, sb btrfs.Superblock, fn func(*util.Ref[btrfsvol.PhysicalAddr, btrfs.Node], error), prog func(btrfsvol.PhysicalAddr)) error {
+func ScanForNodes(ctx context.Context, dev *btrfs.Device, sb btrfs.Superblock, fn func(*diskio.Ref[btrfsvol.PhysicalAddr, btrfs.Node], error), prog func(btrfsvol.PhysicalAddr)) error {
devSize, err := dev.Size()
if err != nil {
return err
diff --git a/lib/containers/lru.go b/lib/containers/lru.go
index 80f5ff5..8b8eb0e 100644
--- a/lib/containers/lru.go
+++ b/lib/containers/lru.go
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later
-package util
+package containers
import (
"sync"
diff --git a/lib/diskio/ref.go b/lib/diskio/ref.go
index fe284d7..9782743 100644
--- a/lib/diskio/ref.go
+++ b/lib/diskio/ref.go
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later
-package util
+package diskio
import (
"fmt"
diff --git a/lib/fmtutil/bitfield.go b/lib/fmtutil/bitfield.go
index b3dbe0a..d46fee5 100644
--- a/lib/fmtutil/bitfield.go
+++ b/lib/fmtutil/bitfield.go
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later
-package util
+package fmtutil
import (
"fmt"
diff --git a/lib/fmtutil/fmt.go b/lib/fmtutil/fmt.go
index c36ba2a..a45ac58 100644
--- a/lib/fmtutil/fmt.go
+++ b/lib/fmtutil/fmt.go
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later
-package util
+package fmtutil
import (
"fmt"
diff --git a/lib/fmtutil/fmt_test.go b/lib/fmtutil/fmt_test.go
index 0aaebb5..2c63c2e 100644
--- a/lib/fmtutil/fmt_test.go
+++ b/lib/fmtutil/fmt_test.go
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later
-package util_test
+package fmtutil_test
import (
"fmt"
@@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/assert"
- "git.lukeshu.com/btrfs-progs-ng/lib/util"
+ "git.lukeshu.com/btrfs-progs-ng/lib/fmtutil"
)
type FmtState struct {
@@ -94,10 +94,10 @@ func FuzzFmtStateString(f *testing.F) {
}
verb := rune(verbs[int(verbIdx)%len(verbs)])
- t.Logf("(%#v, %c) => %q", input, verb, util.FmtStateString(input, verb))
+ t.Logf("(%#v, %c) => %q", input, verb, fmtutil.FmtStateString(input, verb))
var output FmtState
- assert.Equal(t, "", fmt.Sprintf(util.FmtStateString(input, verb), &output))
+ assert.Equal(t, "", fmt.Sprintf(fmtutil.FmtStateString(input, verb), &output))
assert.Equal(t, input, output)
})
}