File system management in FAT32 - Sub-directory management in FAT32

Besides establishing the file directly in logical drive root directory, we may also establish the inferior directory, which is called sub-directory of the root directory. So called sub-directory and parental directory are relative: a parental directory may have many sub-directories, while a sub-directory has only one parental directory. Under the sub-directory of root directory, we may create more inferior sub-directories, thus forming a directory tree. For directories under root directory, its entrance still exists in root directory.

To establish a long filename sub-directory "test folder" under the FAT32 root directory, the registration entry in root directory FDT are as following chart:

From the chart we may see, the sub-directory management completely complies with the FAT32 long filename management rule.

From this file's registration entry, we may know the start cluster of "test folder" is located in cluster "00000003". Here is an examination of its content:

From this file's registration entry, we may know the start cluster of "test folder" is located in cluster "00000003". Here is an examination of its content:

From the chart we know there are 3 directories in "test folder":

1. Folder "." and ".."

Note: These two are system folders, existing under each sub-directory. Thereto "." represents current directory, while".."represents parental directory of the current directory, pointing to the start cluster of its parental directory. Readers who ever used DOS may remember that using DOS command "CD .."can jump to the upper directory. The system realizes the bidirectional connection between directories by this way, thus system can switch between directories.
2.Folder "subdirectory", this is a long filename folder, which can be known from the 0FH mark of file registration entry.

From above introduction, we may know that, managements of sub-directory and the file have similarities as well as differences. first, the expressive way of directory name and filename is same, including the naming rule of its long and short form as well as all dates, time definitions and so on; secondly, the expressive way of start cluster is also same, except that of attribute and length; for sub-directory, its length is fixed 0, which is convenient for system administration. Otherwise, any change under the sub-directory will affect it, causing low efficiency; moreover, the directory length is not convenient to define. it may conflict with the file length.

Let's check the start cluster of (000B) content of sub-directory "subdirectory":

Obviously, the start sector content of "subdirectory" is similar to the root directory structure; it stores separate file directory entry, whose management is an extension of the file directory management under the root directory. This sub-directory manages its files and directories in the same way as the root directory does. But there is some difference between sub-directory and the root directory, that is how they manage themselves: the root directory is determined by DBR, while the sub-directory of root directory by directory registration under root directory.

From the chart above we can see the last file registration is file "teset1.txt", the start cluster is "0000000C". To examine this cluster:

The corresponding file contents are in the following notepad: