diff options
Diffstat (limited to 'pkg/btrfs/btrfsitem')
-rw-r--r-- | pkg/btrfs/btrfsitem/item_uuid.go | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/pkg/btrfs/btrfsitem/item_uuid.go b/pkg/btrfs/btrfsitem/item_uuid.go index 6b47547..45543b3 100644 --- a/pkg/btrfs/btrfsitem/item_uuid.go +++ b/pkg/btrfs/btrfsitem/item_uuid.go @@ -5,36 +5,12 @@ import ( "lukeshu.com/btrfs-tools/pkg/btrfs/internal" ) -// The Key for this item is a UUID, and the item is a list of -// subvolume IDs (ObjectIDs) that that UUID maps to. +// The Key for this item is a UUID, and the item is a subvolume IDs +// that that UUID maps to. // // key.objectid = first half of UUID // key.offset = second half of UUID -type UUIDMap []internal.ObjID // UUID_SUBVOL=251 UUID_RECEIVED_SUBVOL=252 - -func (o *UUIDMap) UnmarshalBinary(dat []byte) (int, error) { - *o = nil - var n int - for len(dat) > n { - var subvolID internal.ObjID - _n, err := binstruct.Unmarshal(dat[n:], &subvolID) - n += _n - if err != nil { - return n, err - } - *o = append(*o, subvolID) - } - return n, nil -} - -func (o UUIDMap) MarshalBinary() ([]byte, error) { - var ret []byte - for _, subvolID := range o { - bs, err := binstruct.Marshal(subvolID) - ret = append(ret, bs...) - if err != nil { - return ret, err - } - } - return ret, nil +type UUIDMap struct { // UUID_SUBVOL=251 UUID_RECEIVED_SUBVOL=252 + ObjID internal.ObjID `bin:"off=0, siz=8"` + binstruct.End `bin:"off=8"` } |