summaryrefslogtreecommitdiff
path: root/pkg/btrfs
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-07-07 04:02:22 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-07-08 00:16:02 -0600
commit361e24ef2f568fe286f7fcc642e1cc8e626f4a88 (patch)
treec628128cdb702fefd05ca4f2aa84719fbe03d226 /pkg/btrfs
parent22c32850798c264b6a20539b9cd1699228368ce9 (diff)
clear-bad-nodes: support root nodes
Diffstat (limited to 'pkg/btrfs')
-rw-r--r--pkg/btrfs/btrfsitem/item_uuid.go34
-rw-r--r--pkg/btrfs/io4_fs.go2
2 files changed, 6 insertions, 30 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"`
}
diff --git a/pkg/btrfs/io4_fs.go b/pkg/btrfs/io4_fs.go
index 75b973b..37d949e 100644
--- a/pkg/btrfs/io4_fs.go
+++ b/pkg/btrfs/io4_fs.go
@@ -84,7 +84,7 @@ func (sv *Subvolume) init() {
rootBody, ok := root.Body.(btrfsitem.Root)
if !ok {
- sv.rootErr = fmt.Errorf("FS_TREE_ ROOT_ITEM has malformed body")
+ sv.rootErr = fmt.Errorf("FS_TREE ROOT_ITEM has malformed body")
return
}