summaryrefslogtreecommitdiff
path: root/pkg/btrfs/io1_device.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-06-05 16:46:34 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-06-05 16:46:34 -0600
commit74b109b0a75ae6648f9381252d8beb5ce6025df3 (patch)
tree64b8b2250c67f749566761bab56676bed9c33846 /pkg/btrfs/io1_device.go
parente134a9fbd0d8ae43e2d24c5aabad8bf6a16190ed (diff)
factor out a btrfsmisc pacage
Diffstat (limited to 'pkg/btrfs/io1_device.go')
-rw-r--r--pkg/btrfs/io1_device.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/pkg/btrfs/io1_device.go b/pkg/btrfs/io1_device.go
index efd8cb9..55b7525 100644
--- a/pkg/btrfs/io1_device.go
+++ b/pkg/btrfs/io1_device.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ "lukeshu.com/btrfs-tools/pkg/binstruct"
"lukeshu.com/btrfs-tools/pkg/util"
)
@@ -19,7 +20,7 @@ func (dev Device) Size() (PhysicalAddr, error) {
return PhysicalAddr(fi.Size()), nil
}
-var superblockAddrs = []PhysicalAddr{
+var SuperblockAddrs = []PhysicalAddr{
0x00_0001_0000, // 64KiB
0x00_0400_0000, // 64MiB
0x40_0000_0000, // 256GiB
@@ -30,7 +31,7 @@ func (dev *Device) ReadAt(dat []byte, paddr PhysicalAddr) (int, error) {
}
func (dev *Device) Superblocks() ([]util.Ref[PhysicalAddr, Superblock], error) {
- const superblockSize = 0x1000
+ superblockSize := PhysicalAddr(binstruct.StaticSize(Superblock{}))
sz, err := dev.Size()
if err != nil {
@@ -38,7 +39,7 @@ func (dev *Device) Superblocks() ([]util.Ref[PhysicalAddr, Superblock], error) {
}
var ret []util.Ref[PhysicalAddr, Superblock]
- for i, addr := range superblockAddrs {
+ for i, addr := range SuperblockAddrs {
if addr+superblockSize <= sz {
superblock := util.Ref[PhysicalAddr, Superblock]{
File: dev,