mk90.system

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.

Byte offsetField
0–3ASCII MKS2.
4Version 2.
6Checksum word: sum of all 128 words in the sector is zero modulo 65536.
8Total sector count.
10Partition count, fixed at 1.
12First partition sector, fixed at 1.
14Partition length, total sectors minus 1.
16Partition type, fixed at 1.
18First data sector, fixed at 5.
20Sector size, fixed at 256.
22–255Reserved.

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 offsetField
0–13Zero-terminated name, maximum 12 characters; zero padding.
14Starting data sector; zero for a directory.
16Unsigned file length, 0–64256; zero for a directory.
18Sum of file bytes modulo 65536.
20Type: 0 free, 1 regular file, 2 directory.
22Parent: 0 for volume root, otherwise inode index 1–16.
24–27Reserved.

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.