I am working on a low-level application that uses the FAT16 file system structure on a resource-limited microcontroller, which requires me to write my own user access code. I have already studied the use of libraries such as Petit FAT and FatFS, but, unfortunately, I do not think that any of them will satisfy my needs. They have provided useful links to how FAT works.
In one area in which I still have problems, there are entries in a subdirectory.
According to this , a directory entry can point to 1 start cluster. For a data file, this is simply the first data cluster. For a directory, this is the start cluster of a subdirectory (presumably a different entry in the directory).
This works fine if there is only one directory path from the root directory to the base file, but I donβt understand how it allows branching into several files / directories under any given directory.
ex. Directory structure:
- root dir 1 - sub dir 1 - file 1 - sub dir 2 - file 2 - root dir 2 - sub dir 3
Based on my understanding of the structure of FAT16,
Immediately after the FAT, there will be a cluster for the first root directory entry containing information for root dir 1 . The first cluster field will contain the cluster address for sub dir 1 , in which the first cluster field will contain the cluster address for file 1 , which indicates the data cluster by the first cluster.
The second root directory entry will then begin in the second cluster after the end of the FAT containing information for root dir 2 . Its first cluster will point to the cluster for sub dir 3 , which will point to the empty cluster as the first cluster (as noted in the FAT).
What am I missing here? I cannot find a way to go from root directory entry to sub dir 2 .