MKS2 on-media format
The partition header, mirrored directory records and file extents.
Conventions
Offsets in format tables are byte offsets. Multi-byte fields are little-endian words unless a byte range is stated. Sectors are 256 bytes. Supported volumes have 32, 40, 64, 128 or 256 sectors. The first data sector is 5.
Volume header: sector 0
| Byte offset | Field |
|---|---|
| 0–3 | ASCII MKS2. |
| 4 | Version 2. |
| 6 | Checksum word: sum of all 128 words in the sector is zero modulo 65536. |
| 8 | Total sector count. |
| 10 | Partition count, fixed at 1. |
| 12 | First partition sector, fixed at 1. |
| 14 | Partition length, total sectors minus 1. |
| 16 | Partition type, fixed at 1. |
| 18 | First data sector, fixed at 5. |
| 20 | Sector size, fixed at 256. |
| 22–255 | Reserved. |
Metadata generations
Copy A occupies sectors 1–2; copy B occupies sectors 3–4. Each 512-byte copy begins with ASCII DIR2, generation at byte 4 and checksum at byte 6. Bytes 8–63 are reserved. Sixteen 28-byte inodes follow at byte 64.
The sum of the 256 words of each metadata copy is zero modulo 65536. The newer valid generation is selected using signed modular subtraction; equal generations prefer A. Consecutive generation wrap from 65535 to 0 is supported.
Inode record
| Byte offset | Field |
|---|---|
| 0–13 | Zero-terminated name, maximum 12 characters; zero padding. |
| 14 | Starting data sector; zero for a directory. |
| 16 | Unsigned file length, 0–64256; zero for a directory. |
| 18 | Sum of file bytes modulo 65536. |
| 20 | Type: 0 free, 1 regular file, 2 directory. |
| 22 | Parent: 0 for volume root, otherwise inode index 1–16. |
| 24–27 | Reserved. |
Extents and validation
A regular file uses max(1, ceil(length / 256)) contiguous sectors. Metadata validation checks types, bounds, extents and parent chains. Names are created under the public filename restrictions; MOUNT is not a complete hostile-image validator.
New allocations avoid both generations and open readers. Data writes are reread and verified before publishing the inactive metadata copy. The valid header is written last during formatting. This design does not provide secure deletion or an automatic repair command.
MBX executables are ordinary MKS2 files; their file checksum lives in this inode, not in a separate MBX checksum field. MBX1 format.