Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Macintosh File System (MFS)

The Macintosh File System (MFS) is the first file system created for Mac OS, intended for 400 KiB floppy disks.

Overview

A MFS file system consists of:

The backup master directory block (MDB), is stored in the last 2 sectors of the volume.

Characteristics

CharacteristicsDescription
Byte orderbig-endian
Date and time valuesTODO
Character stringsNarrow character (Single Byte Character (SBC) or Multi Byte Character (MBC)) stored using a system defined codepage

Terminology

TermDescription
Clump sizeSize of the group of (allocation) blocks (or clump), in bytes, to avoid fragmentation

Boot Block

If a volume is bootable, the first 2 blocks of the volume contain boot block. The boot block consists of:

  • boot block header
  • boot code
  • unknown (filler)

Boot Block Header

The boot block header is 138 or 144 bytes in size and consists of:

OffsetSizeValueDescription
02"LK" (or "\x4c\x4b")Boot block signature
24Boot code entry point
61Flags
71Format version
82Page flags (or Secondary Sound and Video Pages)
101System file name size, with a maximum of 15
1115System file name
261Finder (or shell) file name size, with a maximum of 15
2715Finder (or shell) file name, typically "Finder"
421Debugger file name size, with a maximum of 15
4315Debugger file name, typically "Macsbug"
581Disassembler (or second debugger) file name size, with a maximum of 15
5915Disassembler (or second debugger) file name, typically "Disassembler"
741Startup screen file name size, with a maximum of 15
7515Startup screen file name, typically "StartUpScreen"
901Startup (or bootup) file name size, with a maximum of 15
9115Startup (or bootup) file name, typically "Finder"
1061Clipboard (or scrap) file name size, with a maximum of 15
10715Clipboard (or scrap) file name, typically "Clipboard"
1222Number of allocated file control blocks (FCBs)
1242Number of elements in the event queue, typically 20
1264System heap size on Macintosh computer with 128 KiB of RAM
1304System heap size on Macintosh computer with 256 KiB of RAM
1344System heap size on Macintosh computer with +512 KiB of RAM
Newer boot block header format
1384Additional system heap space
1404Fraction of available RAM for the system heap

Note that “LK” presumably is short for “Larry Kenyon” who originally designed MFS.

Boot code entry point

The boot code entry point contains machine-language instructions that translate to:

BRA.S *+ 0x90

Or for older versions of the boot block header:

BRA.S *+ 0x88
BRA.W *+ 0x88
BRA     $88(PC)         * $6000,$0086

This instruction jumps to the main boot code following the boot block header.

This field is ignored, however, if bit 6 is clear in the high-order byte of the boot block version number or if the low-order byte contains 0x0d.

Boot Block Header Flags

Bit(s)Description
0 - 4Unknown (Reserved), should contain 0
5Use relative system heap sizing
6Execute boot code
7Newer boot block header format is used

If bit 7 of the flag byte is clear, then bits 5 and 6 are ignored and the version number is set in the format version value.

If the format version value is:

  • less than 21, the values in the system heap size on 128K Mac and 256K Mac should be ignored and the value in system heap size on all machines should be used.
  • 13 the boot code should be executed using the value in boot code entry point.
  • greater than or equal to 21 the value in system heap size on all machines should be used.

If bit 7 of the flag byte is set

  • bit 6 should be used to determine whether to execute the boot code using the value in boot code entry point.
  • bit 5 should be used to determine whether to use relative System heap sizing. If bit 5 is
    • clear the value in system heap size on all machines should be used.
    • is set the System heap is extended by the value in the additional system heap space plus the fraction of available RAM for the system heap.

Master Directory Block (MDB)

The Master Directory Block (MDB) is located at offset 1024 of the volume and consists of:

  • master directory block header
  • block map

Master Directory Block (MDB) header

The Master Directory Block (MDB) header is 64 bytes in size and consists of:

OffsetSizeValueDescription
02"\xd2\xd7"Volume signature
24Creation date and time, which contains a HFS timestamp in local time
64Last modification date and time, which contains a HFS timestamp in local time
102Volume attribute flags
122Number of files in the root directory
142File directory area sector number, contains a sector number relative from the start of the volume, where 0 is the first sector number
162File directory area size, in number of sectors
182Number of blocks
204Block size, in bytes, must be a multitude of 512
244Clump size, in bytes
282Data area sector number, contains a sector number relative from the start of the volume, where 0 is the first sector number
304Next available file identifier
342Number of unused blocks
361Volume label size, with a maximum of 27
3727Volume label

Block map

TODO: describe similar to FAT-12 block allocation table

File Directory Area

The file directory area consists of:

  • one or more file directory entries, where an individual file directory entry does not span multiple blocks

File Directory Entry

A file directory entry is of variable size and consists of:

OffsetSizeValueDescription
01Flags, where 0x80 indicates the file directory entry is in use
110Format version
24"\x3f\x3f\x3f\x3f"File type
64File creator
102Finder flags
124Window position and dimension (boundaries), which contains the top, left, bottom, right-coordinate values
162Folder file identifier, where 0 represents the main volume, -2 the desktop, -3 the trash, otherwise, if positive, a file identifier
184File identifier
222Data fork block number, contains 0 if the file entry has no data fork
244Data fork size, in bytes
284Data fork allocated size, in bytes
322Resource fork block number, contains 0 if the file entry has no resource fork
344Resource fork size, in bytes
384Resource fork allocated size, in bytes
424Creation date and time, which contains a HFS timestamp in local time
464(Content) modification date and time, which contains a HFS timestamp in local time
501File name size, with a maximum of 255
51...File name
......16-bit alignment padding