summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-03-09 16:43:39 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-03-17 22:30:37 -0400
commit33de7f09d31063ef2a4380bb2f2692653a6de06c (patch)
tree69b97df946b1c06ab88fa9b35eea25b7bd5a866a /cmd
parent8b17537fc562ef422aee7976cf4a44dd040900aa (diff)
containers: Add OptionalValue and OptionalNil
Diffstat (limited to 'cmd')
-rw-r--r--cmd/btrfs-rec/inspect/rebuildmappings/process.go5
-rw-r--r--cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_exact.go5
-rw-r--r--cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go5
-rw-r--r--cmd/btrfs-rec/inspect/rebuildtrees/scan.go2
-rw-r--r--cmd/btrfs-rec/inspect_lstrees.go2
5 files changed, 5 insertions, 14 deletions
diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/process.go b/cmd/btrfs-rec/inspect/rebuildmappings/process.go
index e42acf9..7a49cc6 100644
--- a/cmd/btrfs-rec/inspect/rebuildmappings/process.go
+++ b/cmd/btrfs-rec/inspect/rebuildmappings/process.go
@@ -137,10 +137,7 @@ func RebuildMappings(ctx context.Context, fs *btrfs.FS, scanResults ScanDevicesR
PAddr: otherPAddr.Add(-offsetWithinChunk),
Size: bg.Size,
SizeLocked: true,
- Flags: containers.Optional[btrfsvol.BlockGroupFlags]{
- OK: true,
- Val: bg.Flags,
- },
+ Flags: containers.OptionalValue(bg.Flags),
}
if err := fs.LV.AddMapping(mapping); err != nil {
dlog.Errorf(ctx, "error: adding flags from blockgroup: %v", err)
diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_exact.go b/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_exact.go
index ef9d9aa..5148e5c 100644
--- a/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_exact.go
+++ b/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_exact.go
@@ -63,10 +63,7 @@ func matchBlockGroupSumsExact(ctx context.Context,
PAddr: matches[0],
Size: blockgroup.Size,
SizeLocked: true,
- Flags: containers.Optional[btrfsvol.BlockGroupFlags]{
- OK: true,
- Val: blockgroup.Flags,
- },
+ Flags: containers.OptionalValue(blockgroup.Flags),
}
if err := fs.LV.AddMapping(mapping); err != nil {
dlog.Errorf(ctx, "error: %v", err)
diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go b/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go
index 905211c..f3557cd 100644
--- a/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go
+++ b/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go
@@ -123,10 +123,7 @@ func matchBlockGroupSumsFuzzy(ctx context.Context,
PAddr: best.Dat[0].PAddr,
Size: blockgroup.Size,
SizeLocked: true,
- Flags: containers.Optional[btrfsvol.BlockGroupFlags]{
- OK: true,
- Val: blockgroup.Flags,
- },
+ Flags: containers.OptionalValue(blockgroup.Flags),
}
if err := fs.LV.AddMapping(mapping); err != nil {
dlog.Errorf(ctx, "error: %v", err)
diff --git a/cmd/btrfs-rec/inspect/rebuildtrees/scan.go b/cmd/btrfs-rec/inspect/rebuildtrees/scan.go
index 961ff8d..ada9f6f 100644
--- a/cmd/btrfs-rec/inspect/rebuildtrees/scan.go
+++ b/cmd/btrfs-rec/inspect/rebuildtrees/scan.go
@@ -72,7 +72,7 @@ func ScanDevices(ctx context.Context, fs *btrfs.FS, nodeList []btrfsvol.LogicalA
return ScanDevicesResult{}, err
}
node, err := btrfstree.ReadNode[btrfsvol.LogicalAddr](fs, *sb, laddr, btrfstree.NodeExpectations{
- LAddr: containers.Optional[btrfsvol.LogicalAddr]{OK: true, Val: laddr},
+ LAddr: containers.OptionalValue(laddr),
})
if err != nil {
node.Free()
diff --git a/cmd/btrfs-rec/inspect_lstrees.go b/cmd/btrfs-rec/inspect_lstrees.go
index 1541012..cad1a37 100644
--- a/cmd/btrfs-rec/inspect_lstrees.go
+++ b/cmd/btrfs-rec/inspect_lstrees.go
@@ -106,7 +106,7 @@ func init() {
}
visitedNodes.Insert(laddr)
node, err := btrfstree.ReadNode[btrfsvol.LogicalAddr](fs, *sb, laddr, btrfstree.NodeExpectations{
- LAddr: containers.Optional[btrfsvol.LogicalAddr]{OK: true, Val: laddr},
+ LAddr: containers.OptionalValue(laddr),
})
if err != nil {
treeErrCnt++