File Systems There are SMALL and WIDE file systems BYTE: 8 bit 16 bit WORD: 16 bit 32 bit CHAR: Latin-1 UCS-2 MDATE: days seconds since 2000 since 2000 (179 years) (136 years) For the Z80 all wide words (uint32) look word-swapped. All IDE devices are WIDE. All I2C devices are SMALL. Block size of all IDE devices is 512 8-bit bytes Block size of all I2C EEproms is 16/32/64 bytes Definitions: RANGE: WORD start // block number of first block, 0-based WORD count // amount of consecutive blocks DIRENTRY: directory entry for file BYTE FILETYPE = 0x02 = ISAFILE WORD filesize WORD timestamp BYTE name.count // file name BYTE[] name BYTE ranges.count // block allocation RANGE[] ranges DIRENTRY: directory entry for directory BYTE FILETYPE = 0x01 = ISADIR WORD filesize WORD timestamp BYTE name.count BYTE[] name WORD block0 // block number of first block, 0-based DIRENTRY: erased data or spare: BYTE[] 0x80 + num bytes to skip should be a series of 0x80+N ... 0x83, 0x82, 0x81, 0x80 DIRENTRY: directory end marker BYTE 0x7E Directory file: WORD parent // block0 of parent directory BYTE ranges.count // allocation for the directory file itself RANGE[] ranges DIRENTRY[] // Directory entries BYTE 0x7E // end marker Root directory file, starting at block 1: WORD 0x0000 // block0 of parent directory BYTE ranges.count // allocation for the root directory file itself RANGE[] ranges DIRENTRY[0] ".trash" // first directory entry is for the trash directory DIRENTRY[…] BYTE 0x7E // end marker Root block (block 0) on device: WORD 0x11C3 = 1st magic word small: bytes = C3 11 C6 6D WORD 0x6DC6 = 2nd magic word wide: bytes = 00 00 C3 11 00 00 C6 6D BlockDevice info: BYTE log2blocksize WORD num_blocks BYTE 0x00 = spare standard directory entry for root dir: DIRENTRY root directory BYTE 0x7E // end marker const FSMagic1 = 0x11C3 small: bytes = C3 11 C6 6D const FSMagic2 = 0x6DC6 wide: bytes = 00 00 C3 11 00 00 C6 6D