FAT12 - reading first cluster number of file from root directory

1.2k views Asked by At

In the root directory of FAT12, bytes 26-27 represent the number of the first cluster of the file. However, cluster numbers in FAT12 are 12 bits long. So what part of that 2 byte entry in the root directory contains the actual 12 bit cluster number ? Is there any conversion that needs to be performed on reading those 2 bytes to get the cluster ? I have looked around over the Internet, but cant find a proper explanation for this.

1

There are 1 answers

0
mirabilos On

The lowest 12 bits, i.e. you do an & 0x0FFF in your code. But on the other hand, the full 16 bits are used – the other 4 bits are just filled with 0, so the number is a valid word (16-bit integer).