From 361e24ef2f568fe286f7fcc642e1cc8e626f4a88 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 7 Jul 2022 04:02:22 -0600 Subject: clear-bad-nodes: support root nodes --- pkg/btrfs/btrfsitem/item_uuid.go | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) (limited to 'pkg/btrfs/btrfsitem') 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"` } -- cgit v1.2.3-2-g168b