{"record":{"id":"71cae355219126e6","repo":"lima-vm/lima","slug":"inode-d-not-found-in-filesystem-b-tree","errorCode":null,"errorMessage":"inode %d not found in filesystem B-tree","messagePattern":"inode (.+?) not found in filesystem B-tree","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apfs/chown.go","lineNumber":698,"sourceCode":"\t\t\t\t}\n\n\t\t\t\tif privateID := le.Uint64(blk[valStart+inodePrivateIDOff:]); privateID != inodeNum {\n\t\t\t\t\treturn fmt.Errorf(\"inode %d has mismatched private_id %d\", inodeNum, privateID)\n\t\t\t\t}\n\n\t\t\t\tcurrentUID := le.Uint32(blk[valStart+inodeOwnerOff:])\n\t\t\t\tcurrentGID := le.Uint32(blk[valStart+inodeGroupOff:])\n\t\t\t\tif currentUID != noownersPlaceholderID || currentGID != noownersPlaceholderID {\n\t\t\t\t\treturn fmt.Errorf(\"inode %d has ownership %d:%d, expected %d:%d from noowners mount\",\n\t\t\t\t\t\tinodeNum, currentUID, currentGID, noownersPlaceholderID, noownersPlaceholderID)\n\t\t\t\t}\n\n\t\t\t\tle.PutUint32(blk[valStart+inodeOwnerOff:], uid)\n\t\t\t\tle.PutUint32(blk[valStart+inodeGroupOff:], gid)\n\t\t\t\tupdateChecksum(blk)\n\t\t\t\treturn c.writeBlock(blkAddr, blk)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"inode %d not found in filesystem B-tree\", inodeNum)\n\t\t}\n\n\t\t// Internal node: descend.\n\t\tchildIdx := uint32(0)\n\t\tfor i := range nkeys {\n\t\t\tkOff, _ := c.readTocEntry(blk, tocStart, i, isFixedKV)\n\t\t\tkeyStart := keyAreaStart + kOff\n\t\t\tkeyHeader := le.Uint64(blk[keyStart:])\n\n\t\t\tif compareFSKeyHeader(keyHeader, targetKeyHeader) <= 0 {\n\t\t\t\tchildIdx = i\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t_, vOff := c.readTocEntry(blk, tocStart, childIdx, isFixedKV)\n\t\tchildOID := le.Uint64(blk[valueAreaEnd-vOff:])","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/apfs/chown.go#L680-L716","documentation":"chownInode walked the inode B-tree to a leaf and scanned all keys for the target inode number's key header without finding a match. The tree is healthy; the requested inode simply has no record in this filesystem B-tree.","triggerScenarios":"Calling chownInode with an inode number that does not exist in the volume — a stale inode number from a deleted file, an inode from a different volume/snapshot, or a wrong file_id obtained from an earlier directory lookup against a different tree.","commonSituations":"Resolving a path in one snapshot and chowning in another; inode recycled after deletion; targeting a volume where the path resolved to a different file.","solutions":["Re-resolve the path with resolvePath against the same volume/tree immediately before chownInode","Verify the inode number exists (e.g. via fsck or by listing directory entries)","Ensure fsRootPhys/omapTreeAddr/maxXID are consistent between lookup and chown","Treat as a clean not-found and skip the inode rather than retrying"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Re-resolve immediately before chown with identical tree parameters\nino, err := c.resolvePath(fsRoot, omap, maxXID, path)\nif err != nil {\n    return err\n}\n_ = c.chownInode(fsRoot, omap, maxXID, ino, uid, gid)","typeGuard":"func isInodeNotFound(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"not found in filesystem B-tree\")\n}","tryCatchPattern":"if err := c.chownInode(root, omap, maxXID, ino, uid, gid); isInodeNotFound(err) {\n    return fmt.Errorf(\"inode %d vanished; re-resolve path: %w\", ino, err)\n}","preventionTips":["Always resolve and chown against the same volume/snapshot/maxXID","Do not cache inode numbers across tree mutations","Treat not-found as an expected outcome and skip gracefully"],"tags":["apfs","inode","not-found","b-tree","chown"],"backgroundTag":"inode-not-found","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}