# Test Case: Sparse 64-bit File Boundary

**Test ID**: TC121-maximum-file-size  
**Category**: Boundary & Stress  
**Priority**: High  
**Regression**: None

## Objective

Verify a reproducible sparse file across 2 GiB and 4 GiB offset boundaries,
including exact 64-bit size, hole bytes, marker bytes, and EOF behavior.

## Preconditions

- Complete `G7-MANUAL-SETUP.md` and its fixture self-check.
- The source is exactly 4294971393 bytes and consumes less than 1 MiB of host
  blocks; this is a practical sparse boundary, not a fabricated 16 TiB run.

## Manual Steps

```sh
G7=/root/repo22-g7
FIX=$G7/fixtures
SRC=$FIX/sources/boundaries/maximum/sparse-boundary.bin
IMAGE=$FIX/images/boundaries.erofs
MNT=/mnt/repo22-g7-tc121
E=$G7/evidence/TC121
mkdir -p "$MNT" "$E"
stat -f 'source_size=%z source_blocks=%b blocksize=%k' "$SRC" \
  | tee "$E/source-stat.txt"
test "$(stat -f %z "$SRC")" -eq 4294971393
test "$(stat -f %b "$SRC")" -lt 2048
unit=$(mdconfig -a -t vnode -f "$IMAGE")
mount -t erofs -o ro "/dev/$unit" "$MNT"
TARGET=$MNT/maximum/sparse-boundary.bin
stat -f 'target_size=%z target_blocks=%b blocksize=%k' "$TARGET" \
  | tee "$E/target-stat.txt"
test "$(stat -f %z "$TARGET")" -eq 4294971393
: > "$E/ranges.txt"
while IFS="$(printf '\t')" read -r label offset length; do
  "$G7/g7_probe" range "$SRC" "$TARGET" "$offset" "$length" \
    > "$E/range-$label.txt"
  rc=$?
  printf 'label=%s rc=%s\n' "$label" "$rc" | tee -a "$E/ranges.txt"
  cat "$E/range-$label.txt" | tee -a "$E/ranges.txt"
  test "$rc" -eq 0 || exit 1
done < "$FIX/SPARSE-RANGES.tsv"
"$G7/g7_probe" eof "$TARGET" 4294971393 | tee "$E/eof.txt"
umount "$MNT"
mdconfig -d -u "${unit#md}"
test -z "$(mount -p | awk -v m="$MNT" '$2 == m { print }')"
test -z "$(mdconfig -l | tr ' ' '\n' | grep -x "$unit")"
```

## PASS Gate

- Source and mounted sizes are exactly 4294971393.
- Every listed range exits 0 with `mismatches=0`; the list covers a pure hole,
  block edge, 2 GiB edge, 4 GiB edge, and final 64 bytes.
- A read at exact EOF returns 0 bytes with errno 0.
- The guest remains responsive and cleanup removes the exact mount/provider.

A range mismatch, overflow errno, panic, trap, or hang is KFAIL. Do not change
kernel source during this regression group.
