# Test Case: Primary Plus Three External Providers

**Test ID**: TC100-multidev-4devices  
**Category**: Multi-Device  
**Priority**: Critical

## Objective

Verify a four-provider filesystem, option-order independence, cross-slot and
concurrent reads, and missing, duplicate, and short slot cleanup.

## Fixture qualification

The G6 verifier reports `multi3` primary blocks 2 and slots `(89,2)`, `(90,91)`,
and `(51,181)`.  `/cross-device.bin` has three 131072-byte indexes with device
IDs `1,2,3`.  The generator host-fsck extracts all three providers and compares
the complete source tree.  `multi3-slot3-short.blob` is exactly one block below
the declared slot-3 size.

## Positive procedure

```sh
I=/root/repo22-g6/images
S=/root/repo22-g6/sources/chunk
mkdir -p /mnt/g6
kldload /root/repo22-g6/erofs.ko
mdconfig -a -t vnode -f "$I/multi3-primary.erofs" -u 90
mdconfig -a -t vnode -f "$I/multi3-slot1.blob" -u 91
mdconfig -a -t vnode -f "$I/multi3-slot2.blob" -u 92
mdconfig -a -t vnode -f "$I/multi3-slot3.blob" -u 93
mount -t erofs -o ro -o device.3=/dev/md93 -o device.1=/dev/md91 \
  -o device.2=/dev/md92 /dev/md90 /mnt/g6
sha256 "$S/cross-device.bin" /mnt/g6/cross-device.bin
cmp "$S/cross-device.bin" /mnt/g6/cross-device.bin
dd if="$S/cross-device.bin" of=/tmp/tc100.cross.src bs=1 skip=126976 count=262144 2>/dev/null
dd if=/mnt/g6/cross-device.bin of=/tmp/tc100.cross.mnt bs=1 skip=126976 count=262144 2>/dev/null
cmp /tmp/tc100.cross.src /tmp/tc100.cross.mnt
sha256 /mnt/g6/cross-device.bin >/tmp/tc100.concurrent.1 &
sha256 /mnt/g6/indexed.bin >/tmp/tc100.concurrent.2 &
sha256 /mnt/g6/cold-slot2.bin >/tmp/tc100.concurrent.3 &
wait
cat /tmp/tc100.concurrent.1 /tmp/tc100.concurrent.2 /tmp/tc100.concurrent.3
```

The 262144-byte range starts before the slot-1/slot-2 transition and ends
after the slot-2/slot-3 transition.  All full, range, and concurrent reads must
pass.

Unmount and detach 93, 92, 91, 90 before each negative step.

## Negative mount cases

Run each case directly and capture `nmount` with `truss`:

1. Omit `device.3`: expected `ENXIO`.
2. Map both `device.1` and `device.2` to md91: expected `EINVAL`.
3. Attach `multi3-slot3-short.blob` as md93: expected `ENXIO`.

For the short case, the exact command is:

```sh
mdconfig -a -t vnode -f "$I/multi3-primary.erofs" -u 90
mdconfig -a -t vnode -f "$I/multi3-slot1.blob" -u 91
mdconfig -a -t vnode -f "$I/multi3-slot2.blob" -u 92
mdconfig -a -t vnode -f "$I/multi3-slot3-short.blob" -u 93
truss -f -o /tmp/tc100-short.truss mount -t erofs -o ro \
  -o device.1=/dev/md91 -o device.2=/dev/md92 -o device.3=/dev/md93 \
  /dev/md90 /mnt/g6
tail -20 /tmp/tc100-short.truss
```

After each failure, detach all attached md units in descending order and
verify no EROFS mount or matching GEOM consumer remains.

## Cleanup and zero-state check

```sh
umount /mnt/g6 2>/dev/null || true
mdconfig -d -u 93 2>/dev/null || true
mdconfig -d -u 92 2>/dev/null || true
mdconfig -d -u 91 2>/dev/null || true
mdconfig -d -u 90 2>/dev/null || true
kldunload erofs
rm -f /tmp/tc100.cross.* /tmp/tc100.concurrent.*
mount -p | awk '$3 == "erofs" { print }'
mdconfig -l
kldstat -n erofs 2>/dev/null || true
sysctl -n kern.geom.conftxt | grep -E 'md9[0-3]|erofs' || true
```

All four final outputs must be empty, with no panic, trap, or hang.
