CN109697019B - Data writing method and system based on FAT file system - Google Patents

Data writing method and system based on FAT file system Download PDF

Info

Publication number
CN109697019B
CN109697019B CN201710984493.0A CN201710984493A CN109697019B CN 109697019 B CN109697019 B CN 109697019B CN 201710984493 A CN201710984493 A CN 201710984493A CN 109697019 B CN109697019 B CN 109697019B
Authority
CN
China
Prior art keywords
data
fat
written
fat table
writing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710984493.0A
Other languages
Chinese (zh)
Other versions
CN109697019A (en
Inventor
孙祖鑫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201710984493.0A priority Critical patent/CN109697019B/en
Publication of CN109697019A publication Critical patent/CN109697019A/en
Application granted granted Critical
Publication of CN109697019B publication Critical patent/CN109697019B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • G06F3/0611Improving I/O performance in relation to response time
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a data writing method and a data writing system based on a FAT file system, and relates to the technical field of computers. One embodiment of the method comprises: determining the number of FAT table entries of an FAT file system to be searched according to the residual storage space of the cluster space corresponding to the FAT table entry occupied by the file in which the data to be written is located and the data volume of the data to be written; and finding out the FAT table entries corresponding to the quantity, and writing the data to be written into the residual storage space and the cluster space corresponding to the found FAT table entries. The implementation mode can improve the speed of writing data and solve the problem of low file data writing speed caused by small data volume writing and multiple times of accessing the file directory to search FAT table entries.

Description

Data writing method and system based on FAT file system
Technical Field
The invention relates to the technical field of computers, in particular to a data writing method and system based on a FAT file system.
Background
In recent years, with the continuous development of embedded systems, the embedded devices have more and more demands on flexible, high-speed, and large-data-volume data storage. Many embedded systems have added functional support for small-capacity storage devices such as external SD cards (secure digital cards), usb disks, and the like. The FAT file system is a file system widely used in an embedded system by virtue of the advantages of complete function, simple structure and easy software implementation. By using the FAT file system, the embedded device can easily organize and manage data on small-capacity storage devices such as FLASH, SD cards, U disks and the like.
In the prior art, the data operation of the FAT file system is based on clusters, and the amount of data written at a time does not exceed the number of bytes contained in one cluster space. The method comprises the steps that data with the size of one cluster space can be written in each writing operation, the FAT table needs to be searched in each data writing operation, the idle FAT table items occupied by the current files are searched according to the root directory or the file directory, then the target storage space position is obtained by calculating the physical address of the clusters corresponding to the FAT table items, and then the file data is read and written. And if the data still remain after the data is stored in the cluster space corresponding to the FAT table item, searching the FAT table item again for data storage. Furthermore, a complete data writing process includes multiple cluster writing processes.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art: when the content of a file with a large data volume needs to be written, because the data volume which can be contained in a single cluster space is limited, the whole data needs to be written, and the entries in the directory file and the FAT table need to be read and written for many times, so that more time needs to be spent on the writing operation, and the space complexity and the time complexity of data writing are further increased.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and a system for data writing based on a FAT file system, which can improve the speed of writing data and solve the problem of low speed of writing file data due to small data volume writing and multiple times of accessing a file directory to search for a FAT entry.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method of data writing based on a FAT file system.
The data writing method based on the FAT file system comprises the following steps: determining the number of FAT table entries of an FAT file system to be searched according to the residual storage space of a cluster space corresponding to the FAT table entry occupied by the file in which the data to be written is located and the data volume of the data to be written; and finding out the FAT table entries corresponding to the quantity, and writing the data to be written into the residual storage space and the cluster space corresponding to the found FAT table entries.
Optionally, the step of determining the number of FAT entries of the FAT file system to be searched includes: determining an FAT table entry occupied by a file where data to be written is located, and determining the residual storage space of a cluster space corresponding to the occupied FAT table entry; calculating the data volume of the data to be written, and determining the difference value between the data volume of the data to be written and the residual storage space; and determining the number of FAT table entries of the FAT file system to be searched according to the difference.
Optionally, the step of finding out the FAT table entries corresponding to the number includes: and inquiring the FAT table entries marked as idle one by one to find out the idle FAT table entries with continuous sequence numbers.
Optionally, before determining the number of FAT entries of the FAT file system to be searched, the method further includes: and determining that the cluster space for storing the data is sufficient according to the data volume of the data to be written.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is provided a system for data writing based on a FAT file system.
The data writing system based on the FAT file system comprises the following components: the determining module is used for determining the number of FAT table entries of the FAT file system to be searched according to the residual storage space of the cluster space corresponding to the FAT table entries occupied by the files in which the data to be written are located and the data volume of the data to be written; and the searching and writing module is used for searching the FAT table entries corresponding to the number, and writing the data to be written into the residual storage space and the cluster space corresponding to the searched FAT table entries.
Optionally, the determining module is further configured to: determining an FAT table entry occupied by a file in which data to be written is located, and determining the residual storage space of a cluster space corresponding to the occupied FAT table entry; calculating the data volume of the data to be written, and determining the difference value between the data volume of the data to be written and the residual storage space; and determining the number of FAT table entries of the FAT file system to be searched according to the difference.
Optionally, the lookup and write module is further configured to: and inquiring the FAT table entries marked as idle one by one to find out the idle FAT table entries with continuous sequence numbers.
Optionally, the apparatus further includes a space sufficiency determining module, configured to determine that the cluster space for storing the data is sufficient according to the data amount of the data to be written.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided an apparatus for data writing based on a FAT file system.
The data writing device based on the FAT file system comprises: one or more processors; and the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize any one of the above data writing methods based on the FAT file system.
To achieve the above object, according to a further aspect of the embodiments of the present invention, there is provided a computer readable medium having a computer program stored thereon, wherein the computer program is configured to implement any of the above methods for writing data based on the FAT file system when executed by a processor.
One embodiment of the above invention has the following advantages or benefits: the method comprises the steps of determining the number of FAT table entries of the FAT file system to be searched before all data is written in, and further searching cluster space blocks corresponding to a plurality of continuous FAT table entries when the corresponding number of FAT table entries is searched. For small capacity storage devices, the continuous sector large data volume write-once speed is much faster than the scattered sector small data volume write speed. Therefore, after the cluster space blocks corresponding to a plurality of continuous FAT table entries are found, the data can be written into the cluster space blocks, the time for searching the FAT table entries by accessing the file directory for many times is reduced, the data writing speed based on the FAT file system is improved, and the problem of low data writing efficiency caused by the fact that only one FAT table entry can be found at one time in the prior art is solved. In addition, the data writing method based on the FAT file system does not destroy the original FAT file system structure, is compatible with the situation of writing and modifying single data for many times, and can realize continuous writing of files.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a schematic diagram of a main flow of a method of data writing based on a FAT file system according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a preferred flow of a method of data writing based on a FAT file system according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of the main modules of a system for data writing based on the FAT file system according to an embodiment of the present invention;
FIG. 4 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
fig. 5 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
BPB_BytePerSec Byte number occupied by one sector
BPB_RootEntCnt Directory entry number for root directory
BPB_FATSz32 Number of sectors occupied by one FAT table
BPB_SecPerClust Number of sectors occupied by one cluster
BPB_NumFATs Number of copies of FAT table in file system
The FAT file system mainly comprises a BPB data structure, a FAT data table, a root directory and file data. The BPB is stored in the first sector of the FAT volume, which is part of the boot sector. The method includes some important parameters of the FAT file system, such as the number of bytes included in each sector, the size of the FAT data structure, and other important information. The FAT data table is a list indicating cluster numbers, and each FAT table entry represents a cluster, which are in a one-to-one correspondence relationship. Both the root directory and the file data are treated as files in the FAT32 file system. Typically, the storage location of the root directory, when the file system is formatted, is set to the first sector of cluster 2.
Wherein, the cluster: a unit of storage of a data block.
And (3) rolling: a partition on a storage device. Taking the SD card as an example, one SD card may be divided into a plurality of volumes, each volume containing a plurality of clusters, each cluster containing a plurality of sectors, each sector containing a plurality of bytes.
FAT32: file Allocation Table, a 32-bit version of the FAT File system.
BPB: BIOS Parameters Block. A data structure in a file system volume boot space. The data in the structure represents part of important parameter information in the file system.
In the prior art, when the content of a file with a large data volume needs to be written, because the data volume which can be contained in a single cluster space is limited, the table entries in the directory file and the FAT table need to be read and written for many times to write the whole data, and the problem of low data writing speed exists. Moreover, a small-capacity storage device has a large data amount write-once speed faster than data written in a small data amount of scattered sectors, so writing data in a single cluster space reduces the data writing speed. For example, the size of one sector of the SD card is set to 512 bytes. When the SD card is formatted, a FAT32 cluster space is set to 8 sectors, i.e., 8 × 512 bytes. And when data is written in each time, acquiring the FAT table position corresponding to the file data from the file directory, then querying the FAT table, acquiring the physical address of the actual operation, and then writing the data. But no more than 8 x 512 bytes of data per write.
Fig. 1 is a schematic diagram of a main flow of a method for writing data based on a FAT file system according to an embodiment of the present invention, and as shown in fig. 1, the method for writing data based on a FAT file system according to an embodiment of the present invention mainly includes:
step S101: and determining the number of FAT table entries of the FAT file system to be searched according to the residual storage space of the cluster space corresponding to the FAT table entry occupied by the file in which the data to be written is located and the data volume of the data to be written. Specifically, determining an FAT table entry occupied by a file where data to be written is located, and determining a residual storage space of a cluster space corresponding to the occupied FAT table entry; calculating the data volume of the data to be written, and determining the difference value between the data volume of the data to be written and the residual storage space; and determining the number of the FAT table entries of the FAT file system to be searched according to the difference. And determining that the FAT table entries needing to be searched do not include the FAT table entries occupied by the files in which the data to be written are located. Since the data to be written is not necessarily the entire file data, a part of the file data may need to be saved, for example, a word file is edited, 1000 words are edited and saved, and then 300 words are edited, and the 300 words need to be saved. The 300 words are data to be written, and the word file is a file where the data to be written is located. When the 300 words are stored, whether the word file to which the 300 words belong occupies the FAT table entry is judged, and since the word file stores 1000 words and the stored 1000 words do not occupy a cluster space, it can be known that the data to be written occupies the FAT table entry.
If a new file is written, the file has no occupied FAT table entry, and the residual storage space of the cluster space corresponding to the FAT table entry occupied by the file in which the data to be written is located is zero, so that the data is not required to be written into the residual storage space in the writing process. In addition, if the file in which the data to be written is located has an occupied FAT table entry, but the remaining storage space of the cluster space corresponding to the occupied FAT table entry is zero, the data does not need to be written into the remaining storage space of the cluster space corresponding to the occupied FAT table entry in the writing process. The above cases are included in the embodiments of the present invention.
Before step S101, it is also determined that the cluster space for storing data is sufficient according to the data amount of the data to be written. If the data volume of the data to be written is larger than the capacity of all cluster spaces for storing the data, it indicates that the storage device cannot completely store the data to be written, and at this time, it indicates that the cluster space for storing the data is insufficient. If the data volume of the data to be written is smaller than the capacity of the cluster space for storing the data, the storage device can completely store the data to be written, and at this time, the cluster space for storing the data is sufficient, so that the data to be written can be written into the cluster space.
The FAT file system is a FAT32 file system. The FAT32 file system has a cluster number of 32 bits, and is a file system widely used in the PC field, and is used for organizing and managing file data on a storage medium such as a disk in an operating system environment. The FAT32 file system is an important component of the FAT file system, is supported by mainstream operating systems such as Windows and Linux, and is widely applied to small-capacity mobile storage devices. And moreover, the embedded equipment using the FAT32 file system can transfer data in a universal data format between different hardware environments and different operating systems, so that the data transfer efficiency is greatly improved.
Step S102: and finding out the FAT table entries corresponding to the quantity, and writing the data to be written into the residual storage space and the cluster space corresponding to the found FAT table entries. In this step, the processes of searching and writing are not sequential. For example, if the number of the FAT entries to be searched is 100, after 10 consecutive FAT entries are searched, writing data into the cluster space block corresponding to the 10 consecutive FAT entries, then continuously searching the remaining 90 FAT entries, and writing the data into the cluster space block in the searching process. The cluster space block is composed of cluster spaces corresponding to several consecutive FAT table entries, for example, three cluster spaces corresponding to the 101 th entry, the 102 th entry and the 103 th entry of the FAT form a cluster space block, and two cluster spaces corresponding to the 111 th entry and the 112 th entry of the FAT form a cluster space block. In the embodiment of the present invention, all of the 100 FAT entries may also be found, which include cluster space blocks corresponding to a plurality of consecutive AT entries, and then data is written into the cluster space block corresponding to the found FAT entry. Through the process, data which can be contained in cluster space blocks corresponding to 10 continuous FAT table entries can be written in one time, and the problem of low data writing speed caused by the fact that only one cluster space is acquired for data processing in the prior art is solved.
In the process of finding out the FAT table entries corresponding to the number, whether the FAT table entries are occupied is searched one by one, and the FAT table entries marked as idle at present are searched, and idle FAT table entries with continuous sequence numbers are searched. Further, the cluster spaces corresponding to the continuous free FAT table entries constitute a cluster space block. In data writing, the data amount written each time is not just the number of bytes contained in one cluster space, but the number of bytes contained in one cluster space block. The method not only reduces the times of searching the root directory and searching the FAT table entry and saves time, but also greatly improves the data writing speed due to the characteristic that the writing speed of large data volume of small-capacity storage equipment is faster than that of small data volume.
After writing the data to be written into the remaining storage space and the cluster space corresponding to the found FAT table entry, the method further includes: judging whether residual data to be written exist or not; if yes, determining the number of the needed FAT table entries according to the data volume of the residual data to be written; and finding out the FAT table entries corresponding to the number, and writing the residual data to be written into the cluster space corresponding to the FAT table entries until all the data are written. Through this process, the problem of data omission can be avoided.
Fig. 2 is a schematic diagram of a preferred flow of a method of data writing based on a FAT file system according to an embodiment of the present invention.
As shown in fig. 2, a preferred flow of the method for writing data based on the FAT file system according to the embodiment of the present invention includes:
step S201: and judging whether the file where the data to be written occupies the FAT table entry or not. If yes, go to step S202; otherwise, step S205 is performed.
After the small-capacity storage device is formatted into the FAT file system, a write-in thread of the small-capacity storage device receives data to be written in, and judges whether the remaining storage space of the small-capacity storage device is sufficient or not according to the data amount of the data to be written in and the remaining storage space of the small-capacity storage device, if so, the step S201 is performed, otherwise, the data writing is abandoned. Wherein, the small-capacity storage device comprises an SD card, a U disk and the like, and for the small-capacity storage device, the writing speed of the large data volume of the continuous sector is far faster than the writing speed of the small data volume of the scattered sector. In the embodiment of the present invention, an SD card is taken as an example for further description.
Step S202: and judging whether the cluster space corresponding to the FAT table entry occupied by the file in which the data to be written is in has a residual storage space. If yes, go to step S203; otherwise, step S205 is performed.
Step S201 determines that the file in which the current data to be written occupies the FAT entry, which indicates that the current data to be written is continuous content, that is, the current data to be written may not be written from the start position of a cluster. If the cluster space corresponding to the FAT table entry occupied by the file in which the data to be written currently exists has a residual storage space, it is indicated that the data cannot be written from the initial position of one cluster, and in order to ensure the continuity of the data, the data can be written into other cluster spaces only after the residual storage space is completely stored.
Step S203: and writing the data to be written into the residual storage space of the cluster space corresponding to the FAT table entry occupied by the file. If the current data to be written can not be written from the initial position of one cluster space, calculating the data volume of the current cluster space which can be continuously written, and writing the data corresponding to the data volume, so that the current cluster space is fully written. The process can ensure that the file system realizes the continuous storage of the data, thereby not requiring that each data segment needs to be written from the initial position of the cluster. The process is only for one cluster, i.e. the last writing does not fill one cluster, and the next writing needs to continue writing at a free position in the current cluster.
Step S204: it is determined whether there is remaining data that has not been written. If yes, go to step S205; otherwise, the data writing process ends. The existence of the residual data which is not written indicates that data is still to be written, and the residual data needs to be continuously written.
Step S205: and determining the number of the required FAT table entries according to the data volume of the current data to be written. The current data to be written in this step is the remaining data determined in step S204 that has not been written. And calculating the storage space required to be occupied by the current target write-in data according to the physical storage space size of the SD card represented by each FAT table entry and the data size of the current data to be written in, thereby obtaining the total number of the FAT table entries required to be occupied by the current storage.
Depending on the physical structure of a small capacity storage device, such as an SD card, the FAT entries themselves are also stored in individual sectors on the SD, each sector containing a partial entry of the FAT entry. In the prior art, when one FAT table entry is read, the corresponding sector content needs to be read from the card, and if a plurality of FAT table entries are retrieved, the SD card needs to be read and written for many times, which is time-consuming. The embodiment of the invention can retrieve the FAT table entries with corresponding quantity by reading the SD card sector once, thereby reducing the reading and writing times of the SD card and saving time.
Step S206: and finding out the FAT table entries corresponding to the number, and writing the current data to be written into the cluster space corresponding to the found FAT table entries. Specifically, the FAT entries that the data needs to occupy at present are found according to the file directory or the root directory, and the number of the found FAT entries is the number determined in step S205. And searching the continuous idle FAT table items one by one from the first idle FAT table item searched currently. If the size of the storage space represented by the searched continuous FAT table entry is enough to store the target data, the searched idle FAT table entry is occupied, and all data are written in one time. And if the size of the storage space represented by the searched continuous FAT table entry is not enough to write all target data, occupying the searched idle FAT table entry according to the size of the available storage space, and writing file data with the corresponding space size. Through the process, the number of times of finding the FAT table entries can be reduced, and the data volume of the sector block of the write-once SD card is increased, so that the write-in speed of the whole file is improved.
If the data a is written into the SD card according to the method for writing data based on the FAT file system of the embodiment of the present invention, the specific process is as follows. Wherein, the data A to be written is the content of the continuous file, and the data volume is 41472 bytes; the case of this SD card is: 512 bytes per sector, 8 sectors per cluster, namely 4096 bytes, and the FAT entry occupied by the file of the current data a is 100, and the 100 th entry is free 512 bytes. After confirming that the current capacity of the SD card is sufficient, confirming that data a is the continuous content (the data a needs to be written into the remaining space of the cluster space corresponding to the 100 th entry, and cannot be written from the start position of a cluster space), and writing data of a corresponding data amount into the remaining storage space of the cluster space corresponding to the FAT 100 th entry. If the FAT table entry occupied by the file in which the data A to be written is 100 corresponds to 512 bytes of cluster space, and the data amount of the data A to be written is 41472 bytes, the number of the FAT table entries of the FAT file system to be searched is 10.
The data written into the remaining storage space is the first 512 bytes of the data a to be written, and 40960 bytes remain after writing. The table entries after the FAT entry 100 can be searched one by one, and if the FAT entry 101, the FAT entry 102 are found to be free and the FAT entry 103 is found to be occupied, data with the capacity of two cluster spaces (the two cluster spaces form a cluster space block) can be written in this time, and the first 8192 bytes of the remaining 40960 bytes are written in. Since data is still to be written, the FAT102 starts to search, and finds that the 104 th to 111 th table entries are free (the cluster spaces corresponding to the 104 th to 111 th table entries form a cluster space block), and the free cluster space is the maximum value of the required residual space, so that all the remaining data can be written at one time.
The data writing method based on the FAT file system can determine the number of the FAT table entries of the FAT file system to be searched before all data is written, and further find out the cluster space blocks corresponding to a plurality of continuous FAT table entries when the corresponding number of the FAT table entries is searched. And for small capacity storage devices, the continuous sector large data volume write-once speed is much faster than the scattered sector small data volume write speed. Therefore, after the cluster space blocks corresponding to a plurality of continuous FAT table entries are found, the data can be written into the cluster space blocks, so that the time for accessing the file directory for finding the FAT table entries for a plurality of times is reduced, the data writing speed based on the FAT file system is improved, and the problem of low data writing efficiency caused by the fact that only one FAT table entry can be found at one time in the prior art is solved. Moreover, the data writing method based on the FAT file system can realize continuous writing of files, is compatible with the situation of multiple writing and modification of single data, conforms to the rule of data storage of the existing FAT file system, does not damage the structure of the existing FAT file system, and has high practicability.
Fig. 3 is a schematic diagram of the main modules of a system for data writing based on the FAT file system according to an embodiment of the present invention.
As shown in fig. 3, the system for writing data based on the FAT file system 300 according to the embodiment of the present invention mainly includes:
the determining module 301 is configured to determine, according to the remaining storage space of the cluster space corresponding to the FAT entry occupied by the file in which the data to be written is located and the data amount of the data to be written, the number of FAT entries of the FAT file system to be searched. The determining module 301 is further configured to: determining FAT table entries occupied by files where data to be written are located, and determining the residual storage space of cluster spaces corresponding to the occupied FAT table entries; calculating the data volume of the data to be written, and determining the difference value between the data volume of the data to be written and the residual storage space; and determining the number of FAT table entries of the FAT file system to be searched according to the difference.
The searching and writing module 302 is configured to search for the FAT entries corresponding to the number of the FAT entries, and write the data to be written into the remaining storage space and the cluster space corresponding to the found FAT entries. In the process of finding out the FAT table entries corresponding to the number, whether the FAT table entries are occupied is inquired one by one, the FAT table entries marked as idle at present are searched, and the idle FAT table entries with continuous sequence numbers are searched. Further, cluster spaces corresponding to the continuous free FAT table entries constitute a cluster space block. In data writing, the data amount written each time is no longer just the number of bytes contained in one cluster space, but the number of bytes contained in one cluster space block. The method not only reduces the times of searching the root directory and searching the FAT table entry and saves time, but also greatly improves the data writing speed due to the characteristic that the writing speed of large data volume of small-capacity storage equipment is faster than that of small data volume.
The FAT-based file system of the embodiment of the invention further comprises a space sufficiency determining module which is used for determining the sufficiency of the cluster space for storing the data according to the data volume of the data to be written. If the data volume of the data to be written is larger than the capacity of all cluster spaces for storing the data, the storage device cannot completely store the data to be written, and at this time, the cluster spaces for storing the data are insufficient. If the data volume of the data to be written is smaller than the capacity of the cluster space for storing the data, the storage device can completely store the data to be written, and at this time, the cluster space for storing the data is sufficient, so that the data to be written can be written into the cluster space.
According to the technical scheme of the embodiment of the invention, the cluster space blocks corresponding to a plurality of continuous FAT table entries can be found out by determining the number of the FAT table entries of the FAT file system to be searched. And for a small capacity storage device, the continuous sector large data volume write-once speed is far faster than the scattered sector small data volume write speed. Therefore, after the cluster space blocks corresponding to a plurality of continuous FAT table entries are found, the data can be written into the cluster space blocks, the time for searching the FAT table entries by accessing the file directory for many times is reduced, the data writing speed based on the FAT file system is improved, and the problem of low data writing efficiency caused by the fact that only one FAT table entry can be found at one time in the prior art is solved. In addition, the data writing method based on the FAT file system does not damage the original FAT file system structure, is compatible with the situation of writing and modifying single data for many times, and can realize continuous writing of files.
Fig. 4 illustrates an exemplary system architecture 400 of a FAT file system-based data writing method or a FAT file system-based data writing system to which embodiments of the present invention may be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405. The network 404 serves as a medium for providing communication links between the terminal devices 401, 402, 403 and the server 405. Network 404 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 401, 402, 403 to interact with a server 405 via a network 404 to receive or send messages or the like. The terminal devices 401, 402, 403 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 405 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 401, 402, 403. The background management server can analyze and process the received data such as the product information inquiry request and feed back the processing result to the terminal equipment.
It should be noted that the method for writing data based on the FAT file system provided by the embodiment of the present invention is generally executed by the server 405, and accordingly, the system for writing data based on the FAT file system is generally disposed in the server 405.
It should be understood that the number of terminal devices, networks, and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 5, shown is a block diagram of a computer system 500 suitable for use with a terminal device implementing embodiments of the present invention. The terminal device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU) 501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. A drive 510 is also connected to the I/O interface 505 as needed. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted on the storage section 508 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 501.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a determination module, a lookup and write module. For example, the determining module may be further described as a module that determines the number of FAT entries of the FAT file system to be searched according to the remaining storage space of the cluster space corresponding to the FAT entry occupied by the file in which the data to be written is located and the data amount of the data to be written.
As another aspect, the present invention also provides a computer-readable medium, which may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: determining the number of FAT table entries of an FAT file system to be searched according to the residual storage space of the cluster space corresponding to the FAT table entry occupied by the file in which the data to be written is and the data volume of the data to be written; and finding out the FAT table entries corresponding to the quantity, and writing the data to be written into the residual storage space and the cluster space corresponding to the found FAT table entries.
According to the technical scheme of the embodiment of the invention, the cluster space blocks corresponding to a plurality of continuous FAT table entries can be found out by determining the number of the FAT table entries of the FAT file system to be searched. And for a small capacity storage device, the continuous sector large data volume write-once speed is far faster than the scattered sector small data volume write speed. Therefore, after the cluster space blocks corresponding to a plurality of continuous FAT table entries are found, the data can be written into the cluster space blocks, so that the time for accessing the file directory for finding the FAT table entries for a plurality of times is reduced, the data writing speed based on the FAT file system is improved, and the problem of low data writing efficiency caused by the fact that only one FAT table entry can be found at one time in the prior art is solved. In addition, the data writing method based on the FAT file system does not destroy the original FAT file system structure, is compatible with the situation of writing and modifying single data for many times, and can realize continuous writing of files.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (8)

1. A data writing method based on a FAT file system is characterized by comprising the following steps:
determining the number of FAT table entries of an FAT file system to be searched according to the residual storage space of the cluster space corresponding to the FAT table entry occupied by the file in which the data to be written is located and the data volume of the data to be written;
finding out FAT table entries corresponding to the quantity, and writing the data to be written into the residual storage space and the cluster space corresponding to the found FAT table entries;
the process of finding the FAT table entries corresponding to the number comprises the following steps:
and inquiring the FAT table entries marked as idle one by one to find out idle FAT table entries with continuous sequence numbers to form a cluster space block, so that when data is written, the data volume written each time is the number of bytes contained in one cluster space block.
2. The method according to claim 1, wherein said step of determining the number of FAT entries of the FAT file system to be looked up comprises:
determining an FAT table entry occupied by a file where data to be written is located, and determining the residual storage space of a cluster space corresponding to the occupied FAT table entry;
calculating the data volume of the data to be written, and determining the difference value between the data volume of the data to be written and the residual storage space;
and determining the number of FAT table entries of the FAT file system to be searched according to the difference.
3. The method of claim 1, prior to determining the number of FAT entries of the FAT file system to be looked up, further comprising:
and determining that the cluster space for storing the data is sufficient according to the data volume of the data to be written.
4. A system for data writing based on a FAT file system, comprising:
the determining module is used for determining the number of FAT table entries of the FAT file system to be searched according to the residual storage space of the cluster space corresponding to the FAT table entry occupied by the file in which the data to be written is located and the data volume of the data to be written;
the searching and writing module is used for searching the FAT table entries corresponding to the quantity, and writing the data to be written into the residual storage space and the cluster space corresponding to the searched FAT table entries;
the lookup and write module is further to: and inquiring the FAT table entries marked as idle one by one to find out idle FAT table entries with continuous sequence numbers to form a cluster space block, so that when data is written, the data volume written each time is the number of bytes contained in one cluster space block.
5. The system of claim 4, wherein the determination module is further configured to: determining an FAT table entry occupied by a file where data to be written is located, and determining the residual storage space of a cluster space corresponding to the occupied FAT table entry; calculating the data volume of the data to be written, and determining the difference value between the data volume of the data to be written and the residual storage space; and determining the number of FAT table entries of the FAT file system to be searched according to the difference.
6. The system according to claim 4, further comprising a space sufficiency determining module configured to determine that the cluster space for storing data is sufficient according to the data amount of the data to be written.
7. An apparatus for writing data based on a FAT file system, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-3.
8. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-3.
CN201710984493.0A 2017-10-20 2017-10-20 Data writing method and system based on FAT file system Active CN109697019B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710984493.0A CN109697019B (en) 2017-10-20 2017-10-20 Data writing method and system based on FAT file system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710984493.0A CN109697019B (en) 2017-10-20 2017-10-20 Data writing method and system based on FAT file system

Publications (2)

Publication Number Publication Date
CN109697019A CN109697019A (en) 2019-04-30
CN109697019B true CN109697019B (en) 2022-12-27

Family

ID=66225368

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710984493.0A Active CN109697019B (en) 2017-10-20 2017-10-20 Data writing method and system based on FAT file system

Country Status (1)

Country Link
CN (1) CN109697019B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111897484B (en) * 2019-05-05 2024-03-29 兆易创新科技集团股份有限公司 Data storage method and device, electronic equipment and storage medium
CN111159064B (en) * 2019-12-30 2023-09-01 南京六九零二科技有限公司 Low-complexity data block caching method
CN113064605B (en) * 2021-03-26 2023-09-15 中国航空无线电电子研究所 Configuration-based multi-data card automatic identification and unloading method
CN113900994B (en) * 2021-12-02 2022-03-01 新华三智能终端有限公司 File writing method and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101042696A (en) * 2006-03-23 2007-09-26 北京握奇数据系统有限公司 Smart card storage system and managing method for file creation in the system
CN101876956A (en) * 2009-12-15 2010-11-03 北京中星微电子有限公司 File access method and device of SD (Secure Digital) card
CN101882132A (en) * 2009-04-27 2010-11-10 深圳市闪联信息技术有限公司 Creating and reading method and device for virtual FAT file system
CN102841894A (en) * 2011-06-22 2012-12-26 比亚迪股份有限公司 Data storage method of file allocation table

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100533443C (en) * 2007-05-11 2009-08-26 北京中星微电子有限公司 Method for cluster linking and track hunting magnetic disc data using file distribution table
CN101303667B (en) * 2008-06-25 2010-06-09 炬力集成电路设计有限公司 Method and device for establishing magnetic disk null cluster table and seeking magnetic disk null cluster
JP2011022875A (en) * 2009-07-17 2011-02-03 Sanyo Electric Co Ltd Data access apparatus
CN102004700A (en) * 2010-11-26 2011-04-06 华为终端有限公司 Memory space distribution method and device for flash memory
CN104394371B (en) * 2014-12-01 2017-09-29 北京理工大学 A kind of system for being adapted to a large amount of sequential image acquisitions and quick storage

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101042696A (en) * 2006-03-23 2007-09-26 北京握奇数据系统有限公司 Smart card storage system and managing method for file creation in the system
CN101882132A (en) * 2009-04-27 2010-11-10 深圳市闪联信息技术有限公司 Creating and reading method and device for virtual FAT file system
CN101876956A (en) * 2009-12-15 2010-11-03 北京中星微电子有限公司 File access method and device of SD (Secure Digital) card
CN102841894A (en) * 2011-06-22 2012-12-26 比亚迪股份有限公司 Data storage method of file allocation table

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
"FAT文件系统元数据合理性检测的研究";李奇阳;《中国优秀硕士学位论文全文数据库(信息科技辑)》;20161215(第2016年第12期);第I138-31页正文第16-18,22-30页 *
"基于ARM7TDMI实现简易嵌入式文件";张延伟 等;《电脑知识与技术》;20070823(第2007年第16期);第1081-1083页 *
"基于TMS320VC5509A的SD卡文件系统的开发应用";刘晓明 等;《工业控制计算机》;20080625;第21卷(第2008年第6期);第79-80页 *

Also Published As

Publication number Publication date
CN109697019A (en) 2019-04-30

Similar Documents

Publication Publication Date Title
KR102240557B1 (en) Method, device and system for storing data
CN107870728B (en) Method and apparatus for moving data
US11003625B2 (en) Method and apparatus for operating on file
CN109697019B (en) Data writing method and system based on FAT file system
CN109947668B (en) Method and device for storing data
US8578096B2 (en) Policy for storing data objects in a multi-tier storage system
CN107480205B (en) Method and device for partitioning data
CN107704202B (en) Method and device for quickly reading and writing data
US11226778B2 (en) Method, apparatus and computer program product for managing metadata migration
US20210132860A1 (en) Management of multiple physical function non-volatile memory devices
CN110569218B (en) Offline modification method and device for EXT file system and storage medium
CN112783887A (en) Data processing method and device based on data warehouse
CN109165723B (en) Method and apparatus for processing data
CN106156038B (en) Date storage method and device
US10311026B2 (en) Compressed data layout for optimizing data transactions
CN110427394B (en) Data operation method and device
CN113742376A (en) Data synchronization method, first server and data synchronization system
CN113986134B (en) Method for storing data, method and device for reading data
CN111857556A (en) Method, apparatus and computer program product for managing metadata of storage objects
CN113076175B (en) Memory sharing method and device for virtual machine
CN112711572B (en) Online capacity expansion method and device suitable for database and table division
CN113760861A (en) Data migration method and device
CN112699116A (en) Data processing method and system
CN113778318B (en) Data storage method and device
US20240103722A1 (en) Metadata management for transparent block level compression

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant