I'm trying to implement a read only FAT16/32 Filesystem library for embedded systems, to read SD Cards (reinventing the wheel for educational purpose).
It seems like there are cards which are formatted without an MBR; just the FAT without any partition table.
I have read FAT docs and MBR docs and learnt how to read an SD Card which both has MBR and FAT.
I need my C++ library to support reading SD Cards without an MBR.
My current approach is the following:
- Try reading the first sector assuming it contains FAT BPB (Boot Parameter Block).
- Check whether the information is valid.
- If yes, continue reading root directory.
- Otherwise assume it has an MBR.
- Read the partition table starting at 0x1BE.
- If a supported partition type is available, try reading its first sector as FAT.
- If the read information is valid, continue reading root directory.
- Otherwise return an ERROR_CODE
Is there a better approach? For example, is there any magic number or a specific pattern that can be identified?