Saltar al contenido ForoHackers

Where the files live on a 1.44 MB floppy (FAT12 walkthrough)

Estructuras de datosSistemas de archivosRetroinformática
#989 · floppy_disk_farmer · · Denunciar

I recover disks as a hobby, so I end up looking at hex a lot. A 3.5" 1.44 MB floppy formatted with FAT12 has a simple layout of 2880 sectors of 512 bytes:

Region Sectors What
Boot sector 1 Geometry, label, boot code
FAT #1 9 The allocation chain
FAT #2 9 A copy, for luck
Root directory 14 224 entries of 32 bytes
Data area 2847 One sector per cluster

A directory entry holds the name (8.3), attributes, dates, the first cluster and the file size. To read a file you take its first cluster, then ask the FAT "what comes next?". The answer is another cluster number, or an end-of-chain marker (0xFF8 to 0xFFF).

The "12" is for 12-bit entries, so two entries are packed into three bytes. Fetching entry n:

uint16_t fat12_get(const uint8_t *fat, unsigned n) {
    unsigned off = n + n / 2;               /* n * 1.5 */
    uint16_t v = fat[off] | (fat[off + 1] << 8);
    return (n & 1) ? (v >> 4) : (v & 0x0FFF);
}

Clusters are numbered from 2, because entries 0 and 1 are reserved for the media descriptor. An entry of 0x000 means free, 0xFF7 marks a bad cluster.

When a floppy "lost its files", the directory is usually fine and it is a damaged FAT sector that cut a chain in half. The second FAT copy has saved a few of mine.

#1348 · r3l1c_0f_bbs · · Denunciar

The table and the 1.5 bytes per entry trick are what I wish somebody had shown me in 1992. I learned all this by trial, error and one very sorry directory.

#1349 · hexdump_hermit · · Denunciar

Small addition: deleting a file in FAT only overwrites the first byte of the directory entry with 0xE5 and marks the clusters free in the FAT. The data stays until reuse, which is why undelete tools worked at all. The first character of the name is the part that is lost.

#1350 · floppy_disk_farmer · · Denunciar

Yes, and that is why recovering ?ELLO.TXT always feels like detective work. You guess the first letter from context.

Inicia sesión o únete para responder.