summaryrefslogtreecommitdiff
path: root/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuilttrees.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuilttrees.go')
-rw-r--r--lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuilttrees.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuilttrees.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuilttrees.go
index 17116c6..37db791 100644
--- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuilttrees.go
+++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuilttrees.go
@@ -54,19 +54,26 @@ func (fs *RebuiltTrees) WriteAt(p []byte, off btrfsvol.LogicalAddr) (int, error)
return fs.inner.WriteAt(p, off)
}
-// btrfstree.NodeSource backend
+// btrfstree.NodeFile
func (fs *RebuiltTrees) ParentTree(tree btrfsprim.ObjID) (btrfsprim.ObjID, bool) {
- if tree < btrfsprim.FIRST_FREE_OBJECTID {
+ if tree < btrfsprim.FIRST_FREE_OBJECTID || tree > btrfsprim.LAST_FREE_OBJECTID {
+ // no parent
+ return 0, true
+ }
+ parentUUID, ok := fs.uuidMap.TreeParent[tree]
+ if !ok {
+ // could not look up parent info
return 0, false
}
- parentUUID := fs.uuidMap.TreeParent[tree]
if parentUUID == (btrfsprim.UUID{}) {
- return 0, false
+ // no parent
+ return 0, true
}
parentObjID, ok := fs.uuidMap.UUID2ObjID[parentUUID]
if !ok {
- panic(fmt.Errorf("should not happen: could not resolve parentUUID=%v to an ObjID", parentUUID))
+ // could not look up parent info
+ return 0, false
}
return parentObjID, true
}