summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-03-15 21:38:56 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2023-03-15 21:41:00 -0600
commit0cc16b8d1da61c0bfb8743c8b68888b0ba73d4bb (patch)
tree8a210fcb602af13fc4175338fc0bda2101838e92
parentc42e8ea5d77a39d096d97600359bd91657da2f05 (diff)
btrfsprim: Add "max" constants for ObjID, ItemType, and offset
-rw-r--r--lib/btrfs/Makefile7
-rw-r--r--lib/btrfs/btrfsprim/itemtype.go7
-rw-r--r--lib/btrfs/btrfsprim/key.go2
-rw-r--r--lib/btrfs/btrfsprim/objid.go3
4 files changed, 17 insertions, 2 deletions
diff --git a/lib/btrfs/Makefile b/lib/btrfs/Makefile
index b98a1b7..2c70363 100644
--- a/lib/btrfs/Makefile
+++ b/lib/btrfs/Makefile
@@ -74,10 +74,15 @@ btrfsprim/itemtype.go: btrfsitem/items.txt $(MAKEFILE_LIST)
echo '// Code generated by Make. DO NOT EDIT.'; \
echo; \
echo 'package $(@D)'; \
- echo 'import "fmt"'; \
+ echo 'import ('; \
+ echo ' "fmt"'; \
+ echo ' "math"'; \
+ echo ')'; \
echo 'type ItemType uint8'; \
echo 'const ('; \
sed -E 's,(.*)=([^:]*)(:.*)? (trivial|complex) (.*),\1_KEY ItemType=\2,' $< | uniq; \
+ echo; \
+ echo 'MAX_KEY ItemType = math.MaxUint8'; \
echo ')'; \
echo 'func (t ItemType) String() string {'; \
echo ' switch t {'; \
diff --git a/lib/btrfs/btrfsprim/itemtype.go b/lib/btrfs/btrfsprim/itemtype.go
index f33179a..682fecd 100644
--- a/lib/btrfs/btrfsprim/itemtype.go
+++ b/lib/btrfs/btrfsprim/itemtype.go
@@ -2,7 +2,10 @@
package btrfsprim
-import "fmt"
+import (
+ "fmt"
+ "math"
+)
type ItemType uint8
@@ -39,6 +42,8 @@ const (
UUID_RECEIVED_SUBVOL_KEY ItemType = 252
UUID_SUBVOL_KEY ItemType = 251
XATTR_ITEM_KEY ItemType = 24
+
+ MAX_KEY ItemType = math.MaxUint8
)
func (t ItemType) String() string {
diff --git a/lib/btrfs/btrfsprim/key.go b/lib/btrfs/btrfsprim/key.go
index 55f7c05..7a3cc5c 100644
--- a/lib/btrfs/btrfsprim/key.go
+++ b/lib/btrfs/btrfsprim/key.go
@@ -19,6 +19,8 @@ type Key struct {
binstruct.End `bin:"off=0x11"`
}
+const MaxOffset uint64 = math.MaxUint64
+
// mimics print-tree.c:btrfs_print_key()
func (key Key) Format(tree ObjID) string {
switch tree {
diff --git a/lib/btrfs/btrfsprim/objid.go b/lib/btrfs/btrfsprim/objid.go
index 1aea030..f364957 100644
--- a/lib/btrfs/btrfsprim/objid.go
+++ b/lib/btrfs/btrfsprim/objid.go
@@ -6,6 +6,7 @@ package btrfsprim
import (
"fmt"
+ "math"
)
type ObjID uint64
@@ -52,6 +53,8 @@ const (
// ???
EMPTY_SUBVOL_DIR_OBJECTID ObjID = 2
+
+ MAX_OBJECTID ObjID = math.MaxUint64
)
var (