# Pre6 Initialization Baseline

## Repository Baseline

- Outer starting commit: `bfed0431693e7798bdecacd78b7e6258c2d93c5a`
- Starting `repo-pre-6` tree: `b4a40164394b378adc947d6ad14dc7c845e79b2c`
- Starting `repo-pre-6/src/super.c` blob: `03b92560bb5ef01f322b0d052f84bc3c577ef829`
- Execution target: the existing `repo-pre-6` directory
- Source allowlist for later extraction commits: `repo-pre-6/src/super.c`

The tree and blob identities above were read from Git before this document was
created. Pre6 works directly on `repo-pre-6`; it does not create another source
snapshot.

## Stage Scope

Pre6 is an L2-I private mount-initialization responsibility extraction stage.
It contains three helper tasks:

1. Extract one decoded external-device initialization block into
   `static int erofs_init_device(...)`.
2. Extract packed-carrier initialization into
   `static int erofs_init_packed_inode(struct erofs_mount *em)`.
3. Extract metabox initialization into
   `static int erofs_init_metabox_inode(struct erofs_mount *em)`.

These tasks move existing statements into private helpers. They must not change
features, behavior, public interfaces, error handling, allocation, cleanup,
logging, locking, GEOM operations, or object ownership.

## Source Commit Strategy

The source work is delivered in two commits:

1. One independent commit for `erofs_init_device()`.
2. One atomic commit for `erofs_init_packed_inode()` and
   `erofs_init_metabox_inode()`.

Packed and metabox initialization remain one ownership unit because their
blocks are adjacent and a fragment-backed metabox can depend on the packed
carrier. No intermediate commit may contain only one internal-inode helper.

Each commit, including this baseline commit, must be pushed immediately to
`xdm main`. Execution must stop if local HEAD, `xdm/main`, and remote `main`
do not agree after a push.

## Protected Paths

The following paths must remain unchanged during Pre6 execution:

- `repo-pre-1/`
- `repo-pre-2/`
- `repo-pre-3/`
- `repo-pre-5/`
- `src-linux/`
- `planning/reject/`
- `1-code-similarity-review/`
- existing planning documents and reports

Except for Pre6 documents under `repo-pre-6/docs/`, no path outside
`repo-pre-6/src/super.c` belongs in the planned source commits.

## Behavior-Preservation Invariants

- Preserve the order of every moved statement and every helper call.
- Preserve all conditions, loop direction, values, types, casts, and return
  values.
- Preserve every errno and log message without translation or normalization.
- Preserve allocations, frees, NULL assignments, and failure paths.
- Preserve the current owner and lifetime of every buffer, device, inode, and
  mount resource.
- Keep `erofs_open_device()` unchanged as the FreeBSD GEOM open transaction.
- Keep external-device slot lookup and ascending iteration in
  `erofs_scan_devices()`.
- Keep packed inode initialization before metabox inode initialization.
- Keep `erofs_mountfs()` as the common failure owner that calls
  `erofs_sb_free()`.
- Add no rollback, validation, cleanup, logging, locking, or defensive changes.
- Keep all new helpers private and add no header declarations.

If an extraction requires a behavior, ownership, ordering, or errno change,
execution must stop instead of expanding Pre6 scope.

## Validation Status at Baseline

| Validation item | Status |
|---|---|
| Static Git baseline capture | RECORDED |
| Device initialization extraction | NOT RUN |
| Packed and metabox initialization extraction | NOT RUN |
| Static equivalence and independent revert gates | NOT RUN |
| Build with `WITH_ZSTDIO=0` | NOT RUN |
| Plain/LZ4 smoke test | NOT RUN |
| Complete `TC099` multi-device smoke test | NOT RUN |
| Positive `TC142` metabox smoke test | NOT RUN |
| Other build, QEMU, or runtime tests | NOT RUN |

No source extraction, build, QEMU run, feature validation, regression test, or
runtime result is claimed by this baseline document.
