summaryrefslogtreecommitdiff
path: root/lib/btrfs/btrfsitem
diff options
context:
space:
mode:
Diffstat (limited to 'lib/btrfs/btrfsitem')
-rw-r--r--lib/btrfs/btrfsitem/item_uuid.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/btrfs/btrfsitem/item_uuid.go b/lib/btrfs/btrfsitem/item_uuid.go
index 03823ce..451ccae 100644
--- a/lib/btrfs/btrfsitem/item_uuid.go
+++ b/lib/btrfs/btrfsitem/item_uuid.go
@@ -5,6 +5,8 @@
package btrfsitem
import (
+ "encoding/binary"
+
"git.lukeshu.com/btrfs-progs-ng/lib/binstruct"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsprim"
)
@@ -18,3 +20,10 @@ type UUIDMap struct { // UUID_SUBVOL=251 UUID_RECEIVED_SUBVOL=252
ObjID btrfsprim.ObjID `bin:"off=0, siz=8"`
binstruct.End `bin:"off=8"`
}
+
+func KeyToUUID(key btrfsprim.Key) btrfsprim.UUID {
+ var uuid btrfsprim.UUID
+ binary.LittleEndian.PutUint64(uuid[:8], uint64(key.ObjectID))
+ binary.LittleEndian.PutUint64(uuid[8:], uint64(key.Offset))
+ return uuid
+}