Expand description
Directory records (APFS_TYPE_DIR_REC 9) and name→inode navigation.
A directory entry’s key is j_drec_key_t (parent oid + name) or, on
case-insensitive/normalization-aware volumes, j_drec_hashed_key_t (parent
oid + a packed name-length/hash word + name). After the 8-byte j_key
header:
- unhashed (
j_drec_key_t):name_lenu16 @8 (incl. the NUL), name @10. - hashed (
j_drec_hashed_key_t):name_len_and_hashu32 @8 (J_DREC_LEN_MASK 0x000003ff= name length incl. NUL,J_DREC_HASH_SHIFT 10for the 22-bit hash), name @12.
The value j_drec_val_t { u64 file_id; u64 date_added; u16 flags; xfields }
gives the target inode (file_id) and the time the entry was added
(date_added). Layout verified verbatim against the Apple reference +
libfsapfs format spec.
Navigation resolves a path component by scanning the volume fs-tree for
the DIR_REC whose key oid is the parent inode and whose name matches the
requested component, returning the child inode (file_id); full-path
resolution descends from ROOT_DIR_INO_NUM (2). The fs-tree is virtual —
its node oids resolve through the volume object map at the volume’s xid.
Structs§
- DirEntry
- A directory entry.
Constants§
- ROOT_
DIR_ INO_ NUM ROOT_DIR_INO_NUM(Apple) — the inode number of a volume’s root directory.
Functions§
- list_
dir - List the directory entries whose parent is
parent_oid, scanning the volume fs-tree forDIR_RECrecords. - load_
inode - Load the inode (
INODErecord) foroidfrom the volume fs-tree. - lookup_
child - Resolve a single path component: look up the
DIR_REC(parent_oid, name)in the fs-tree and return the child inode number, orNoneif absent. - open_
path - Resolve a
/-separated path to anInodeby descending the fs-tree from the root directory (ROOT_DIR_INO_NUM). Empty components (from a leading, trailing, or doubled/) are skipped;"/"resolves to the root inode.