summaryrefslogtreecommitdiff
path: root/pkg/btrfs/internal/addr.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/btrfs/internal/addr.go')
-rw-r--r--pkg/btrfs/internal/addr.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/btrfs/internal/addr.go b/pkg/btrfs/internal/addr.go
new file mode 100644
index 0000000..7067982
--- /dev/null
+++ b/pkg/btrfs/internal/addr.go
@@ -0,0 +1,25 @@
+package internal
+
+import (
+ "fmt"
+
+ "lukeshu.com/btrfs-tools/pkg/util"
+)
+
+type (
+ PhysicalAddr int64
+ LogicalAddr int64
+)
+
+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)
+ default:
+ fmt.Fprintf(f, util.FmtStateString(f, verb), addr)
+ }
+}
+
+func (a PhysicalAddr) Format(f fmt.State, verb rune) { formatAddr(int64(a), f, verb) }
+func (a LogicalAddr) Format(f fmt.State, verb rune) { formatAddr(int64(a), f, verb) }