Skip to main content

Module dir

Module dir 

Source
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_len u16 @8 (incl. the NUL), name @10.
  • hashed (j_drec_hashed_key_t): name_len_and_hash u32 @8 (J_DREC_LEN_MASK 0x000003ff = name length incl. NUL, J_DREC_HASH_SHIFT 10 for 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 for DIR_REC records.
load_inode
Load the inode (INODE record) for oid from 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, or None if absent.
open_path
Resolve a /-separated path to an Inode by 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.