diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/btrfs-fsck/pass1.go | 22 | ||||
-rw-r--r-- | cmd/btrfs-rec/inspect_lsfiles.go | 12 | ||||
-rw-r--r-- | cmd/btrfs-rec/inspect_lstrees.go | 2 |
3 files changed, 16 insertions, 20 deletions
diff --git a/cmd/btrfs-fsck/pass1.go b/cmd/btrfs-fsck/pass1.go index c75e066..e8398f9 100644 --- a/cmd/btrfs-fsck/pass1.go +++ b/cmd/btrfs-fsck/pass1.go @@ -92,12 +92,10 @@ func pass1WriteReconstructedChunks(fs *btrfs.FS) { for _, dev := range fs.LV.PhysicalVolumes() { superblock, _ := dev.Superblock() reconstructedNode.Data.BodyLeaf = append(reconstructedNode.Data.BodyLeaf, btrfs.Item{ - Head: btrfs.ItemHeader{ - Key: btrfs.Key{ - ObjectID: btrfs.DEV_ITEMS_OBJECTID, - ItemType: btrfsitem.DEV_ITEM_KEY, - Offset: uint64(superblock.Data.DevItem.DevID), - }, + Key: btrfs.Key{ + ObjectID: btrfs.DEV_ITEMS_OBJECTID, + ItemType: btrfsitem.DEV_ITEM_KEY, + Offset: uint64(superblock.Data.DevItem.DevID), }, Body: superblock.Data.DevItem, }) @@ -105,14 +103,12 @@ func pass1WriteReconstructedChunks(fs *btrfs.FS) { for _, mapping := range fs.LV.Mappings() { chunkIdx := len(reconstructedNode.Data.BodyLeaf) - 1 - if len(reconstructedNode.Data.BodyLeaf) == 0 || reconstructedNode.Data.BodyLeaf[chunkIdx].Head.Key.Offset != uint64(mapping.LAddr) { + if len(reconstructedNode.Data.BodyLeaf) == 0 || reconstructedNode.Data.BodyLeaf[chunkIdx].Key.Offset != uint64(mapping.LAddr) { reconstructedNode.Data.BodyLeaf = append(reconstructedNode.Data.BodyLeaf, btrfs.Item{ - Head: btrfs.ItemHeader{ - Key: btrfs.Key{ - ObjectID: btrfs.FIRST_CHUNK_TREE_OBJECTID, - ItemType: btrfsitem.CHUNK_ITEM_KEY, - Offset: uint64(mapping.LAddr), - }, + Key: btrfs.Key{ + ObjectID: btrfs.FIRST_CHUNK_TREE_OBJECTID, + ItemType: btrfsitem.CHUNK_ITEM_KEY, + Offset: uint64(mapping.LAddr), }, Body: btrfsitem.Chunk{ Head: btrfsitem.ChunkHeader{ diff --git a/cmd/btrfs-rec/inspect_lsfiles.go b/cmd/btrfs-rec/inspect_lsfiles.go index 2da31aa..a859be3 100644 --- a/cmd/btrfs-rec/inspect_lsfiles.go +++ b/cmd/btrfs-rec/inspect_lsfiles.go @@ -51,7 +51,7 @@ func printSubvol(fs *btrfs.FS, prefix0, prefix1, name string, key btrfs.Key) { } rootBody := root.Body.(btrfsitem.Root) - printDir(fs, root.Head.Key.ObjectID, prefix0, prefix1, name, rootBody.RootDirID) + printDir(fs, root.Key.ObjectID, prefix0, prefix1, name, rootBody.RootDirID) } func printDir(fs *btrfs.FS, fsTree btrfs.ObjID, prefix0, prefix1, dirName string, dirInode btrfs.ObjID) { @@ -67,7 +67,7 @@ func printDir(fs *btrfs.FS, fsTree btrfs.ObjID, prefix0, prefix1, dirName string membersByIndex := make(map[uint64]btrfsitem.DirEntry) membersByNameHash := make(map[uint64]btrfsitem.DirEntry) for _, item := range items { - switch item.Head.Key.ItemType { + switch item.Key.ItemType { case btrfsitem.INODE_ITEM_KEY: if dirInodeDatOK { if !reflect.DeepEqual(dirInodeDat, item.Body.(btrfsitem.Inode)) { @@ -82,9 +82,9 @@ func printDir(fs *btrfs.FS, fsTree btrfs.ObjID, prefix0, prefix1, dirName string case btrfsitem.DIR_ITEM_KEY: entry := item.Body.(btrfsitem.DirEntry) namehash := btrfsitem.NameHash(entry.Name) - if namehash != item.Head.Key.Offset { + if namehash != item.Key.Offset { errs = append(errs, fmt.Errorf("read dir: direntry crc32c mismatch: key=%#x crc32c(%q)=%#x", - item.Head.Key.Offset, entry.Name, namehash)) + item.Key.Offset, entry.Name, namehash)) continue } if other, exists := membersByNameHash[namehash]; exists { @@ -101,7 +101,7 @@ func printDir(fs *btrfs.FS, fsTree btrfs.ObjID, prefix0, prefix1, dirName string } membersByNameHash[btrfsitem.NameHash(entry.Name)] = entry case btrfsitem.DIR_INDEX_KEY: - index := item.Head.Key.Offset + index := item.Key.Offset entry := item.Body.(btrfsitem.DirEntry) if other, exists := membersByIndex[index]; exists { if !reflect.DeepEqual(entry, other) { @@ -112,7 +112,7 @@ func printDir(fs *btrfs.FS, fsTree btrfs.ObjID, prefix0, prefix1, dirName string membersByIndex[index] = entry //case btrfsitem.XATTR_ITEM_KEY: default: - errs = append(errs, fmt.Errorf("TODO: handle item type %v", item.Head.Key.ItemType)) + errs = append(errs, fmt.Errorf("TODO: handle item type %v", item.Key.ItemType)) } } fmt.Printf("%s%q\t[ino=%d", diff --git a/cmd/btrfs-rec/inspect_lstrees.go b/cmd/btrfs-rec/inspect_lstrees.go index e308b20..b55acf0 100644 --- a/cmd/btrfs-rec/inspect_lstrees.go +++ b/cmd/btrfs-rec/inspect_lstrees.go @@ -40,7 +40,7 @@ func init() { }, TreeWalkHandler: btrfs.TreeWalkHandler{ Item: func(_ btrfs.TreePath, item btrfs.Item) error { - typ := item.Head.Key.ItemType + typ := item.Key.ItemType treeItemCnt[typ] = treeItemCnt[typ] + 1 return nil }, |