I’m trying to understand how FAT file systems work from a higher (more logical) level. A FAT file system has a file allocation table, with 1 entry for each available allocation unit (cluster) in the disk. This data structure is used to map a file with the address of the first cluster in which the file appears on the disk (a file almost certainly occupies more than 1 cluster, and these clusters are connected together in a linked-list style). So far so good. But what is the key in the file allocation table? Is the file name with full path?
For instance, let’s say that I need to access file C:\folder1\myFile.txt, the I/O manager searches the file name (including the path) in the file allocation table until it finds an entry, and if so, it returns the address of the first cluster. Is that how it works? I read a lot of documentation online about this topic, but somehow the access to the file allocation table is still fuzzy for me. Thank you in advance for your help.
[EDIT]
The more I read on line, the more confused I am. I'm going to try with this simple example, hopefully it will clarify my question. Let's say I have only 2 files in my C drive:
C:\myFile.txt
C:\folder1\myFile.txt
The file allocation table (in a very abstract way) would have 3 entries:
| Filename | Extension | First Cluster |
|----------|-----------|---------------|
1 | MYFILE | TXT | 150 |
2 | FOLDER1 | | 300 |
3 | MYFILE | TXT | 900 |
Assuming I'm correct so far, let's say that I want to access myFile.txt in C:\folder1: I cannot use the file name (MYFILE.TXT) itself as my key, because I have 2 entries with the same name (I wouldn't know which entry to pick).
At this point I guess I have to start from the folder, so I scan the FAT to find FOLDER1: I get entry #2 (cluster 300). What's next? How I would I keep scanning the table to find the directory entry that I need for "MYFILE.TXT", so that I can access the hard drive at specified cluster?
Maybe I'm looking at this from the wrong perspective, I don't know. Thanks everyone for your help.