summaryrefslogtreecommitdiff
path: root/pkg/btrfs/internal/misc.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-06-01 01:56:16 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-06-01 01:56:16 -0600
commit70fc3adf402eb956e6061fae75e46c46c1ad606d (patch)
tree5611c676dcb91405d7a327e42f664f2496107944 /pkg/btrfs/internal/misc.go
parent3825cf60fd652f22acc438d50028701d27a7402d (diff)
update main, kinda
Diffstat (limited to 'pkg/btrfs/internal/misc.go')
-rw-r--r--pkg/btrfs/internal/misc.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/pkg/btrfs/internal/misc.go b/pkg/btrfs/internal/misc.go
new file mode 100644
index 0000000..e7d9dd6
--- /dev/null
+++ b/pkg/btrfs/internal/misc.go
@@ -0,0 +1,30 @@
+package internal
+
+import (
+ "time"
+
+ "lukeshu.com/btrfs-tools/pkg/binstruct"
+)
+
+type (
+ PhysicalAddr int64
+ LogicalAddr int64
+ Generation uint64
+)
+
+type Key struct {
+ ObjectID ObjID `bin:"off=0, siz=8"` // Each tree has its own set of Object IDs.
+ ItemType ItemType `bin:"off=8, siz=1"`
+ Offset uint64 `bin:"off=9, siz=8"` // The meaning depends on the item type.
+ binstruct.End `bin:"off=11"`
+}
+
+type Time struct {
+ Sec int64 `bin:"off=0, siz=8"` // Number of seconds since 1970-01-01T00:00:00Z.
+ NSec uint32 `bin:"off=8, siz=4"` // Number of nanoseconds since the beginning of the second.
+ binstruct.End `bin:"off=c"`
+}
+
+func (t Time) ToStd() time.Time {
+ return time.Unix(t.Sec, int64(t.NSec))
+}