Storage Organization Structure of the FAT32 File System (2)

Source: Internet
Author: User

We have analyzed the structure of FAT32 File System Storage Based on A formatted empty USB flash disk. Next we will analyze the operating mechanism of the file system from the perspective of file operations. Because I changed a USB flash drive, several important data areas of the just-formatted empty USB flash drive are still pasted as follows:

 

As we can see, during partition formatting, the system stores the file size test_fat32 in cluster 2, that is, the directory area, as shown in the root directory texture above. At the same time, the file Terminator FF 0f is written to the position marked by the FDT Zone 2 cluster. Obviously, the FAT32 file system treats directories as common files.

Next we will create a new folder test1 in the root directory to see what changes will happen:

After the test1 folder is created, FDT becomes as follows:

The root directory is changed to the following:

Cluster 3 is reassigned:

From the above changes, we can intuitively see that the system has completed the following actions when creating a folder:

A. Create a new directory item in the cluster where the parent directory is located to store the folder information currently created.

B. allocate a new cluster and create two directory items for the new Folder: parent directory and current directory.

C. Write the file terminator at the corresponding location of the newly allocated cluster in the FDT table.

D. establish the link relationship between each part: Write the cluster number of the newly allocated cluster in the file starting cluster number field of the Directory item corresponding to the new folder, the file starting cluster number field of the two directory items on the new cluster is allocated with the cluster number of the parent directory (0 here, I thought it was 2, that is, the cluster where the root directory is located. I don't know why, it may be used to indicate the root directory with 0) and the current cluster number (3 here ).

To verify the correctness of the above analysis, we create a new folder named test11 in the test1 folder to check whether the following operations are performed:

A. Create a new directory item in the parent directory (test1) Cluster (cluster 3) to store the test11 Folder Information.

B. assign a new cluster (which should be cluster 4) and create two directory items for the new folder (test11): parent directory and current directory.

C. Write the file terminator at the corresponding location of the newly allocated cluster (which should be cluster 4) in the FDT table.

D. establish the link relationship between each part: Create the file starting cluster number field of the Directory item corresponding to the folder (test11) and write the cluster number of the newly allocated cluster (which should be cluster 4 ),, the file start cluster number field of the two directory items on the new cluster is allocated with the cluster number (cluster 3) of the parent directory and the current cluster number (which should be cluster 4 ).

After creating the test11 folder, The FDT becomes:

The root directory has not changed:

Cluster 3 becomes:

New cluster 4:

Obviously, our estimation is correct and further proves that our previous analysis is correct.

Next we will analyze the file creation situation

We first create a 100-byte file test. txt, and then copy the file to the root directory of the USB flash drive. The FDT is changed to the following:

The root directory is changed:

New cluster 5 is assigned to save the file content:

From the above changes, we can intuitively see that the operations performed by the system to create a file are the same as those performed by creating a folder:

A. Create a new directory item in the cluster where the parent directory is located to store the file information currently created.

B. allocate a new cluster to store the content of the new file.

C. Write the file terminator at the corresponding location of the newly allocated cluster in the FDT table.

D. Establish a link: Write the cluster number of the newly allocated cluster to the file starting cluster number field of the Directory item corresponding to the new file.

Conclusion:

1. In the FAT32 file system, directories and files are stored in a unified manner.

2. The operating unit of the file system is a cluster. Every time a file or folder is created, at least one cluster number will be assigned again.

3. If the content of a file or directory needs to be stored in multiple clusters, the system will allocate multiple clusters to store the content of files or directories.

4. When multiple clusters are required, these clusters may be continuous or discontinuous, but the system uses the FDT linked list form to organize them.

Storage Organization Structure of the FAT32 File System (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.