FAT file system, writing method thereof, medium and electronic device

By using the method of writing by path and sequential writing in cluster units, the file fragmentation problem in the FAT file system is solved, continuous storage and efficient reading and writing of files are achieved, and disk utilization and file management efficiency are improved.

CN115905109BActive Publication Date: 2025-10-03FUZHOU ROCKCHIP SEMICON
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110887322.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-03
Publication Date
2025-10-03
Estimated Expiration
2041-08-03

AI Technical Summary

Technical Problem

The existing FAT file system is prone to fragmentation when multiple files are written simultaneously, which is especially serious when supporting circular writing.

Method used

Adopting the write-by-path method, each file data is stored in the corresponding independent data area, and sequentially written in clusters to ensure that each file data is stored in a continuous area, supporting file attribute configuration and cyclic writing.

Benefits of technology

It effectively reduces the fragmentation problem in the file system, improves the file reading and writing speed and disk utilization, and supports automatic file deletion and protection of important files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115905109B_ABST
    Figure CN115905109B_ABST
Patent Text Reader

Abstract

The present invention provides a FAT file system and a writing method, medium, and electronic device thereof. The FAT file system includes a hidden area and a data area, wherein: the hidden area includes a boot area and a FAT table; the data area includes a parameter area, a first data area, and at least two second data areas; the parameter area is used to store the start and end position information of the first and second data areas, as well as the directory path corresponding to the second data area; the first data area is used to store directory information; and each second data area is used to store a path of file data with a corresponding directory path. The FAT file system can reduce the generation of fragmentation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a file system, in particular to a FAT file system and a writing method, medium and electronic equipment thereof. Background Art

[0002] The file system is an essential part of the operating system, used to organize and allocate space on file storage devices, and responsible for file storage, protection, and retrieval. Common file systems include the FAT (File Allocation Table) file system and the NTFS (New Technology File System) file system. The FAT file system is supported by most operating systems and is suitable for data exchange between different operating systems, making it widely used. However, existing FAT file systems suffer from severe fragmentation, which is exacerbated when multiple files are written simultaneously. Summary of the Invention

[0003] In view of the above-mentioned shortcomings of the related art, an object of the present invention is to provide a FAT file system and a writing method thereof, a medium and an electronic device, so as to solve the problems existing in the related art.

[0004] To achieve the above-mentioned purpose and other related purposes, the first aspect of the present invention provides a FAT file system, wherein the FAT file system includes a hidden area and a data area, wherein: the hidden area includes a boot area and a FAT table; the data area includes a parameter area, a first data area and at least two second data areas; the parameter area is used to store the start and end position information of the first data area and the second data area, and the directory path corresponding to the second data area; the first data area is used to store directory information; and each of the second data areas is used to store a path of file data with a corresponding directory path.

[0005] In an embodiment of the first aspect, the FAT file system supports writing file data using a path-by-path writing method, and the path-by-path writing method includes: obtaining a corresponding second data area as a target data area according to a directory path of the file to be written; obtaining a writing starting cluster of the target data area; starting from the writing starting cluster, writing the file to be written into the target data area in cluster order.

[0006] In an embodiment of the first aspect, the method for writing the files to be written sequentially into the target data area by cluster includes: obtaining the current available cluster based on the write start cluster; starting from the current available cluster, writing the files to be written sequentially into the available clusters in the target data area by cluster, wherein the available cluster refers to the cluster that is not occupied by the read-only file.

[0007] In an embodiment of the first aspect, the size of the file to be written is less than or equal to the currently available clusters, and the method for writing the file to be written into the available clusters in the target data area in cluster order includes: writing the file to be written into the currently available clusters.

[0008] In an embodiment of the first aspect, the size of the file to be written is larger than the currently available cluster, and the method for writing the file to be written into the available clusters in the target data area in cluster order includes: writing part of the data of the file to be written into the currently available cluster; obtaining the next available cluster of the currently available cluster as a new currently available cluster, and writing part of the data of the file to be written into the new currently available cluster in order, and repeating this step until all the data in the file to be written is written into the target data area; wherein, if the currently available cluster is the last available cluster in the target data area, the next available cluster of the currently available cluster is the first available cluster in the target data area.

[0009] In an embodiment of the first aspect, at any time, each of the second data areas supports opening at most one file with a write attribute.

[0010] In an embodiment of the first aspect, the second data area is further used to store file data in an unspecified directory.

[0011] A second aspect of the present invention provides a FAT file system writing method for writing a target file into the FAT file system described in any one of the first aspects of the present invention, the FAT file system writing method comprising: obtaining a corresponding second data area as a target data area according to a directory path of the target file; obtaining a writing starting cluster of the target data area; and starting from the writing starting cluster, writing the target file into the target data area sequentially by cluster.

[0012] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the FAT file system writing method described in the second aspect of the present invention.

[0013] A fourth aspect of the present invention provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is communicatively connected to the memory and is configured to execute the FAT file system writing method described in the second aspect of the present invention when calling the computer program; or, the electronic device comprises the FAT file system described in any one of the first aspect of the present invention.

[0014] As described above, the FAT file system described in one or more embodiments of the present invention has the following beneficial effects:

[0015] The data area of ​​the FAT file system includes a parameter area, a first data area, and a second data area, wherein each second data area is used to store a path of file data having a corresponding directory path. When multiple paths of file data are simultaneously written into the FAT file system of the present invention, each path of file data can be written into a corresponding second data area, thereby ensuring that each file is stored in a continuous area, thereby reducing the generation of fragmentation. In particular, when the FAT file system supports cyclic writing of file data, the advantages of the FAT file system of the present invention over related technologies are even more obvious. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 A schematic diagram showing the structure of the FAT file system in related technology.

[0017] Figure 2 FIG. 1 is a schematic diagram showing the structure of the FAT file system according to a specific embodiment of the present invention.

[0018] Figure 3A Shown is a flow chart of a method for writing by way in a specific embodiment of the FAT file system of the present invention.

[0019] Figure 3B Shown is a flowchart of step S33 in a specific embodiment of the FAT file system of the present invention.

[0020] Figure 3C Shown is a flowchart of step S332 in a specific embodiment of the FAT file system of the present invention.

[0021] Figure 4 Shown is a schematic diagram of writing files in a specific embodiment of the FAT file system of the present invention.

[0022] Figure 5 Shown is a schematic structural diagram of the electronic device according to a specific embodiment of the present invention.

[0023] Component number description

[0024] 1 FAT file system

[0025] 11 Hidden Area

[0026] 12 Data Area

[0027] 121 Parameter Area

[0028] 122 First data area

[0029] 123_1, 123_N Second data area

[0030] 500 Electronic Equipment

[0031] 510 Memory

[0032] 520 processor

[0033] 530 Display

[0034] Steps S31 to S33

[0035] Steps S331-S332

[0036] Steps S3321 to S3322 DETAILED DESCRIPTION

[0037] The following describes the embodiments of the present invention through specific examples. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments. The details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other unless they conflict.

[0038] It should be noted that the diagrams provided in the following embodiments are merely schematic illustrations of the basic concept of the present invention. The diagrams only show components relevant to the present invention and are not drawn according to the number, shape, and size of components in actual implementation. In actual implementation, the type, quantity, and proportion of each component may be arbitrarily varied, and the component layout may also be more complex. Furthermore, in this document, relational terms such as "first," "second," and the like are used solely to distinguish one entity or operation from another, and do not necessarily require or imply any actual relationship or order between these entities or operations.

[0039] See also Figure 1 , shown as an example of a FAT file system in the related art. When the FAT file system in this example is applied to a multi-channel file data scenario, such as a multi-channel monitoring scenario, assuming that file 11 in the first channel of file data and file 21 in the second channel of file data arrive at the same time, the example will write file 11 and file 21 into the data area of ​​the FAT file system at the same time, which will cause the two files to be stored in discontinuous areas, thus causing fragmentation problems. In particular, when the FAT file system in this example supports cyclic writing, the fragmentation problem will be more obvious. For this issue, please refer to Figure 2In one embodiment of the present invention, a FAT file system 1 is provided, wherein the FAT file system 1 includes a hidden area 11 and a data area 12, wherein the data area 12 includes a parameter area 121, a first data area 122 and N second data areas 123_1, ..., 123_N, wherein N is a positive integer.

[0040] The hidden area 11 includes a boot area and a FAT table, wherein the FAT table includes a FAT table 1 and a FAT table 2, and the contents of the two tables can be exactly the same.

[0041] The parameter area 121 is used to store parameters such as the start and end position information of the first data area 122 and the second data areas 123_1, ..., 123_N, and directory paths corresponding to the second data areas 123_1, ..., 123_N.

[0042] The first data area 122 is used to store directory information, and its reading and writing process can be consistent with the standard FAT file system, which will not be described in detail here.

[0043] Optionally, the first data area 122 may also be used to store file data in an unspecified directory.

[0044] Each second data area in the FAT file system 1 is used to store a path of file data with a corresponding directory path. Each path of file data can be stored in the form of an integer number of files in a corresponding second data area, and each second data area can correspond to one or more directory paths. For example, second data area 123_1 is used to store a first path of file data, which includes file 11, file 12, and file 13. For another example, second data area 123_N is used to store an Nth path of file data, which includes file N1, file N2, and file N3.

[0045] It should be noted that for any second data area A, the second data area A can only be used to store a channel of file data with a corresponding directory path. A channel of file data without a corresponding directory path cannot be stored in the second data area A. For example, if the directory path corresponding to the second data area A is / video0 / , when creating the / video0 / 1 / file1.mp4 file and writing the file data, the file data cannot be stored in the second data area A because the directory path is / video0 / 1 / . When creating the / video0 / file.mp4 file and writing the file data, the file's directory path corresponds to the second data area A, and the file data can be stored in the second data area A.

[0046] The FAT file system 1 of this embodiment supports simultaneous storage of multiple file data streams and is able to store all files in each file data stream in contiguous areas as much as possible, thereby reducing the amount of fragmentation in the FAT file system 1 and facilitating improved file read and write speeds. For example, if file 11 in the first file data stream and file N1 in the Nth file data stream arrive simultaneously, the FAT file system 1 of this embodiment will store file 11 in the second data area 123_1 and file N1 in the second data area 123_N, preventing them from interfering with each other. This ensures that both files are stored in contiguous areas as much as possible, and this process generates virtually no fragmentation.

[0047] Optionally, the disk mounting method based on the FAT file system 1 includes: obtaining parameters from the parameter area, and obtaining the starting position of the second data area according to the FAT table of the hidden area, obtaining the creation time of each file in the second data area according to the directory information in the first data area, and then finding the next cluster of the last cluster of the last created file in each second data area.

[0048] Optionally, the number of second data areas included in the FAT file system 1 is the same as the number of file data paths supported by the device. For example, when the FAT file system 1 is applied to a video recording device, if the device supports simultaneous recording of two video paths, the number of second data areas is two; if the device supports simultaneous recording of eight video paths, the number of second data areas is eight. This ensures that writing and deleting of file data in each path do not interfere with each other, while also ensuring the continuity of the data areas as much as possible.

[0049] In one embodiment of the present invention, the FAT file system supports writing file data using a path-by-path writing method. Figure 3A , the method of writing by path includes:

[0050] S31: Acquire a corresponding second data area as a target data area based on the directory path of the file to be written, wherein the file to be written may be any file in the file data. As previously described, each second data area may correspond to one or more directory paths, and the directory paths corresponding to the second data areas are stored in the parameter area. Therefore, the system kernel can acquire the target data area based on the contents of the parameter area and the directory path of the file to be written.

[0051] S32, obtaining the write-start cluster of the target data area. Specifically, when the target data area is empty, the write-start cluster is the start cluster of the target data area. In actual applications, the system kernel can obtain the start cluster of the target data area based on the FAT table of the hidden area. When the target data area stores files, the write-start cluster refers to the cluster next to the last cluster of the last file created in the target data area. In actual applications, the system kernel can obtain the creation time of each file in the target data area based on the directory information in the first data area, thereby obtaining the last file created in the target data area. It can also obtain the last cluster of the last file created in the target data area based on the FAT table of the hidden area, thereby obtaining the next cluster of the last cluster as the write-start cluster. In particular, when the last cluster of the last file created in the target data area is the last cluster of the target data area, its next cluster is the first cluster of the target data area. That is, the system kernel uses the first cluster of the target data area as the write-start cluster.

[0052] S33, starting from the write start cluster, writing the files to be written into the target data area in cluster order.

[0053] According to the above description, the above steps S31 to S33 provide a method of writing by path. The FAT file system described in this embodiment supports this method of writing by path. Therefore, the system kernel can use this method of writing by path to write to the FAT file system to ensure that each of the second data areas is used to store one path of file data with a corresponding directory path, thereby avoiding mutual interference when multiple files are written simultaneously.

[0054] Optionally, see Figure 3B In this embodiment, the method for writing the files to be written into the target data area in cluster order includes:

[0055] S331, obtaining a currently available cluster based on the write start cluster. If there is no available cluster in the target data area, the target data area cannot store new file data, and the writing of the file data ends.

[0056] Optionally, a method for implementing step S331 may include: sequentially determining within the target data area whether the write-start cluster and subsequent clusters are available clusters, wherein the first available cluster obtained in this process is the currently available cluster, wherein an available cluster refers to a cluster not occupied by a read-only file. If the write-start cluster and subsequent clusters are not available clusters, then, starting from the first cluster in the target data area, sequentially determining whether the first cluster and subsequent clusters are available clusters, wherein the first available cluster obtained in this process is the currently available cluster.

[0057] Optionally, another implementation method of step S331 may be:

[0058] S3311, determine whether the write starting cluster is an available cluster. If so, the write starting cluster is the currently available cluster, and step S331 ends. Otherwise, it means that a read-only file is stored in the currently available cluster. The read-only file is used as a reference file and step S3312 is executed.

[0059] S3312: The next cluster after the last cluster of the reference file is obtained based on the FAT table in the hidden area, and a determination is made as to whether it is an available cluster. If so, the next cluster after the last cluster of the reference file is the currently available cluster, and step S331 ends. Otherwise, it indicates that another read-only file is stored in the next cluster after the last cluster of the reference file. This other read-only file is used as the new reference file, and step S3312 is repeated. In this process, if the last cluster of a reference file is the last cluster of the target data area, the next cluster after the last cluster of the reference file is the first cluster of the target data area.

[0060] S332 , starting from the currently available cluster, writing the files to be written into the available clusters in the target data area in cluster order, wherein the available clusters refer to clusters not occupied by read-only files.

[0061] Optionally, if the size of the file to be written is smaller than or equal to the currently available cluster, step S332 writes the file to be written into the currently available cluster.

[0062] Optionally, if the size of the file to be written is larger than the currently available cluster, refer to Figure 3C A method for implementing step S332 includes:

[0063] S3321: Write part of the data of the file to be written into the currently available cluster.

[0064] S3322: Obtain the next available cluster after the currently available cluster as a new currently available cluster, and sequentially write the portion of the data of the file to be written to the new currently available cluster. Repeat this step until all the data of the file to be written has been written to the target data area. If the currently available cluster is the last available cluster in the target data area, the next available cluster after the currently available cluster is the first available cluster in the target data area.

[0065] For example, the file to be written can be divided into multiple file segments based on the size of the clusters in the target data area. The size of each file segment is preferably the same as the size of the clusters in the target data area. When writing, the first file segment is written to the currently available cluster, the second file segment is written to the next available cluster after the currently available cluster, and the next cluster after the currently available cluster is used as the new currently available cluster. The third file segment is written to the next available cluster after the new currently available cluster, and this process is repeated until all data in the file to be written is written to the target data area.

[0066] Optionally, step S3322 may determine in sequence whether the clusters following the currently available cluster are available clusters, and use the first available cluster following the currently available cluster as the next available cluster of the currently available cluster. If none of the clusters following the currently available cluster are available clusters, starting with the first cluster of the target data area, determine in sequence whether the first cluster and the clusters following it are available clusters. The first available cluster obtained in this process is the next available cluster of the currently available cluster.

[0067] Optionally, step S3322 can determine whether the next cluster of the currently available cluster is an available cluster. If so, the next cluster of the currently available cluster is the next available cluster of the currently available cluster. Otherwise, the read-only file stored in the next cluster of the currently available cluster is used as a reference file, and the next available cluster of the currently available cluster is obtained in a manner similar to step S3312.

[0068] As can be seen from the above description, the writing method described in steps S3321 to S3322 can achieve cyclic writing of file data. Moreover, during the writing process of file data, existing non-read-only files in the target data area can be automatically overwritten, thereby achieving automatic deletion of files. Compared with the related art method of deleting files through the application layer, this embodiment has a higher deletion speed. In addition, this cyclic writing method can effectively reduce the fragmentation problem caused by cyclic deletion of files, which is conducive to improving the read and write speed of the disk.

[0069] Optionally, the path-by-path writing method further includes: updating the directory information in the first data area and the FAT table in the hidden area during the writing process of the file to be written and / or after the writing is completed.

[0070] Optionally, the path-by-path writing method further includes: configuring the attribute of the file to be written as a read-only file, thereby preventing important files in the second data area from being overwritten.

[0071] In one embodiment of the present invention, each second data area supports at most one open file with write attributes at any one time. This configuration prevents interference between multiple files in the same second data area, ensuring that each file in the second data area is stored in a continuous area. This significantly reduces or even completely eliminates disk fragmentation in the second data area, further improving disk read and write speeds.

[0072] In one embodiment of the present invention, the FAT file system includes a hidden area and a data area, wherein: the hidden area includes a boot area and a FAT table; the data area includes a parameter area, a first data area and at least two second data areas; the parameter area is used to store the start and end position information of the first data area and the second data area, and the directory path corresponding to the second data area; the first data area is used to store directory information and file data of an unspecified directory; each second data area is used to store a path of file data with a corresponding directory path.

[0073] When mounting a disk based on the FAT file system described in this embodiment, the system kernel first reads parameters from the parameter area, and obtains the starting position of the second data area based on the read parameters, obtains the creation time of each file in the second data area based on the directory information of the first data area, and obtains the next cluster of the last cluster of the last created file in each second data area based on the FAT table in the hidden area.

[0074] In this embodiment, each of the second data areas supports opening at most one file with a write attribute at any one time, that is, the system kernel cannot open multiple files with a write attribute in the same second data area at the same time, thereby avoiding mutual interference between multiple files in the same second data area during writing.

[0075] In this embodiment, when writing to any of the second data areas B, writing is performed in cluster order starting from the previously recorded starting position (i.e., the currently available clusters). When writing to a certain location, if the cluster to be written is already occupied, a determination is made as to whether the file occupying the cluster is read-only. If the file is not read-only, the file is deleted and all clusters occupied by the file are released. Writing to the file data continues from that location. If the file is read-only, the cluster to be written is skipped and the search continues. If writing has already reached the end of the second data area B, the writing is continued by jumping to the beginning of the second data area B.

[0076] For example, see Figure 4, which shows an example of the writing process to the second data area B. Specifically, after the disk is formatted, starting from the beginning of the second data area B, files 1B, 2B, ..., and 9B are written to the second data area B in order, and the attribute of file 3B is configured as read-only. Thereafter, the process jumps to the beginning of the second data area B to continue writing files 10B and 11B, while overwriting files 1B and 2B to achieve automatic deletion of files 1B and 2B. When writing to the position of file 3B, since file 3B is read-only, file 3B is skipped and files 12B, 13B, ..., and 17B are written to the second data area B starting from the position of file 4B. Then, the process jumps to the beginning of the second data area B to continue writing file data until all the file data corresponding to the second data area B are written.

[0077] As can be seen from the above description, the FAT file system described in this embodiment automatically and quickly deletes old files by overwriting them when the space in the second data area is full. Because each path of file data is stored separately in a specific second data area, the storage of file data in each path does not interfere with each other. In addition, the FAT file system supports writing and deleting data in chronological order. Therefore, after a long period of cyclic deletion and creation of files, most files can still remain fragmented, while a few files may have very little fragmentation, which helps to improve file reading and writing speeds. Moreover, in this embodiment, the deletion of old files can be implemented by the system kernel, which is faster.

[0078] In addition, the FAT file system supports configuring file attributes as read-only, so read-only files will not be automatically deleted, which helps prevent the accidental deletion of important files. Furthermore, the FAT file system does not require the pre-creation of large files or pre-alignment of file sizes, which helps improve disk space utilization.

[0079] Furthermore, the FAT file system described in this embodiment only modifies the storage structure within the kernel, without affecting underlying layers. Therefore, a memory card based on this FAT file system can be read and written normally in systems like Windows, with no difference in data written using a standard file system. Furthermore, the FAT file system described in this embodiment writes and deletes data in clusters, the smallest unit of FAT storage. This provides higher disk utilization and operational flexibility compared to related techniques that operate in data blocks.

[0080] Based on the above description of the FAT file system, the present invention also provides a method for reading a FAT file system, which is used to write a target file into the FAT file system. Figure 2The FAT file system 1 shown in FIG. Specifically, the FAT file system writing method includes: obtaining a corresponding second data area as a target data area according to a directory path of the target file; obtaining a write start cluster of the target data area; and writing the target file into the target data area sequentially, cluster by cluster, starting from the write start cluster.

[0081] It should be understood that the reading method of the FAT file system is the same as Figure 3A The steps S31 to S33 are the same and will not be described in detail here to save space.

[0082] Based on the above description of the method for reading the FAT file system, the present invention further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method for reading the FAT file system of the present invention is implemented.

[0083] Based on the above description of the method for reading the FAT file system, the present invention further provides an electronic device. Specifically, please refer to Figure 5 In one embodiment of the present invention, the electronic device 500 includes a memory 510 and a processor 520. The memory 510 stores a computer program, and the processor 520 is in communication with the memory 510 and is configured to execute the FAT file system writing method of the present invention when calling the computer program.

[0084] Optionally, the electronic device further includes a display 530 , which is communicatively connected to the memory 510 and the processor 520 and is configured to display a GUI interaction interface related to the FAT file system writing method.

[0085] Based on the above description of the FAT file system, the present invention also provides another electronic device, the electronic device includes Figure 2 The electronic device is, for example, a variety of memories.

[0086] The protection scope of the FAT file system writing method described in the present invention is not limited to the execution order of the steps listed in this embodiment. All solutions implemented by adding, subtracting, or replacing steps in the prior art based on the principles of the present invention are included in the protection scope of the present invention.

[0087] In summary, the FAT file system described in one or more embodiments of the present invention includes a hidden area and a data area, wherein the data area includes a parameter area, a first data area, and a second data area, wherein each second data area is used to store a path of file data having a corresponding directory path. When multiple paths of file data are simultaneously written into the FAT file system of the present invention, each path of file data can be written into a corresponding second data area, thereby ensuring that each file is stored in a continuous area, which reduces the occurrence of fragmentation problems. In particular, when the FAT file system supports cyclic writing of file data, the advantages of the FAT file system over related technologies are more obvious. Therefore, the present invention effectively overcomes the various shortcomings of the prior art and has a high industrial utilization value.

[0088] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the present invention. Anyone skilled in the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by one of ordinary skill in the art without departing from the spirit and technical principles disclosed herein are intended to be covered by the claims of the present invention.

Claims

1. A FAT file system, characterized in that: The FAT file system includes a hidden area and a data area, wherein: The hidden area includes a boot area and a FAT table; The data area includes a parameter area, a first data area and at least two second data areas; The parameter area is used to store the start and end position information of the first data area and the second data area, and the directory path corresponding to the second data area; The first data area is used to store directory information; Each of the second data areas is used to store a path of file data having a corresponding directory path.

2. The FAT file system according to claim 1, wherein: The FAT file system supports writing file data using a path-by-path writing method, and the path-by-path writing method includes: According to the directory path of the file to be written, the corresponding second data area is obtained as the target data area; Obtaining a write start cluster of the target data area; Starting from the write start cluster, the files to be written are written into the target data area in cluster order.

3. The FAT file system according to claim 2, wherein: The method for writing the files to be written into the target data area in cluster order includes: Acquire a currently available cluster according to the write start cluster; Starting from the currently available cluster, the files to be written are written sequentially into the available clusters in the target data area in cluster order, wherein the available clusters refer to clusters not occupied by read-only files.

4. The FAT file system according to claim 3, wherein: The size of the file to be written is less than or equal to the currently available clusters, and the method for writing the file to be written into the available clusters in the target data area in cluster order includes: Write the file to be written into the currently available cluster.

5. The FAT file system according to claim 3, wherein: The size of the file to be written is larger than the currently available clusters, and the method for writing the file to be written into the available clusters in the target data area in cluster order includes: Writing part of the data of the file to be written into the currently available cluster; Obtaining the next available cluster of the currently available cluster as a new currently available cluster, and sequentially writing part of the data of the to-be-written file into the new currently available cluster, and repeating this step until all the data in the to-be-written file is written into the target data area; If the current available cluster is the last available cluster in the target data area, the next available cluster of the current available cluster is the first available cluster in the target data area.

6. The FAT file system according to claim 1, wherein: At any one time, each of the second data areas supports at most one file opened with a write attribute.

7. The FAT file system according to claim 1, wherein: The second data area is also used to store file data in an unspecified directory.

8. A method for writing to a FAT file system, characterized in that: A method for writing a target file into the FAT file system according to any one of claims 1 to 7, wherein the method comprises: Acquire the corresponding second data area as the target data area according to the directory path of the target file; Obtaining a write start cluster of the target data area; Starting from the write start cluster, the target file is written into the target data area in cluster order.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the FAT file system writing method according to claim 8 is implemented.

10. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor is communicatively connected to the memory and is configured to execute the FAT file system writing method according to claim 8 when calling the computer program; or The electronic device comprises the FAT file system according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method for improving flash memory medium read-write speed

    CN101441596A

  • File system data management method and system

    CN102253985A