CN106708831B - FAT (file allocation table) image file processing method and device - Google Patents

FAT (file allocation table) image file processing method and device Download PDF

Info

Publication number
CN106708831B
CN106708831B CN201510469405.4A CN201510469405A CN106708831B CN 106708831 B CN106708831 B CN 106708831B CN 201510469405 A CN201510469405 A CN 201510469405A CN 106708831 B CN106708831 B CN 106708831B
Authority
CN
China
Prior art keywords
data
file
image file
structure information
information
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
CN201510469405.4A
Other languages
Chinese (zh)
Other versions
CN106708831A (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.)
Actions Technology Co Ltd
Original Assignee
Actions 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 Actions Technology Co Ltd filed Critical Actions Technology Co Ltd
Priority to CN201510469405.4A priority Critical patent/CN106708831B/en
Publication of CN106708831A publication Critical patent/CN106708831A/en
Application granted granted Critical
Publication of CN106708831B publication Critical patent/CN106708831B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a method and a device for processing a FAT (file allocation table) image file. The method comprises the following steps: creating a compressed file of a File Allocation Table (FAT) mirror image file; and adding the structure information of the FAT image file and the data of each used data structure of the FAT image file into the compressed file, wherein the compressed file does not comprise the data of the unused data structure in the FAT image file. The size of the compressed file is reduced because the compressed file does not contain data of unused data structures. Therefore, the storage resource occupied by the compressed file of the FAT image file is reduced, and the transmission time of the compressed file is reduced under the same transmission speed, so that the transmission efficiency is improved.

Description

FAT (file allocation table) image file processing method and device
Technical Field
The invention relates to the field of computers, in particular to a method and a device for processing an FAT (file allocation table) image file.
Background
File Allocation Table (FAT) files are a common type of file system, and the existing file systems of several FAT types include FAT16, FAT32 and EXFAT file systems, which are commonly used in hot-plug removable storage devices such as a usb disk, and both a Windows system and a Linux system can support these FAT file systems.
Current FAT image files store the complete data structure of the FAT file system, which causes a series of problems. For example, in the process of transmitting the image file of the FAT file system, the transmission efficiency is often limited by the transmission medium, such as the network bandwidth and the USB speed, and the like. For another example, there is a problem that an excessive amount of storage resources are occupied for storing an image file of the FAT file system.
Disclosure of Invention
The embodiment of the invention aims to provide a FAT image file processing method and device, which are used for solving a series of problems caused by the fact that the FAT image file stores the complete data structure of a FAT file system.
The purpose of the embodiment of the invention is realized by the following technical scheme:
a FAT image file processing method comprises the following steps:
creating a compressed file of a File Allocation Table (FAT) mirror image file;
and adding the structure information of the FAT image file and the data of each used data structure of the FAT image file into the compressed file, wherein the compressed file does not comprise the data of the unused data structure in the FAT image file.
Optionally, adding the structure information of the FAT image file and the data of each used data structure of the FAT image file to the compressed file, including:
generating at least one first data block, each first data block corresponding to one or at least two consecutive unused data structures, each first data block including structure information of the corresponding data structure, excluding data of the corresponding data structure;
generating at least one second data block, each second data block corresponding to one or at least two consecutive used data structures, each second data block including structure information and data of the corresponding data structure;
generating a file header of the compressed file, wherein the file header of the compressed file comprises the structure information of the first data block and the second data block and the overall structure information of the FAT mirror image file;
adding the file header, the first data block and the second data block to the compressed file.
Optionally, the second data block includes data of a corresponding data structure, which refers to all data including the corresponding data structure.
Optionally, if the data of the data structure corresponding to the second data block is not the repetition of the feature data, the data of the data structure corresponding to the second data block includes all data of the corresponding data structure;
if the data of the data structure corresponding to the second data block is the repetition of the feature data, the data of the data structure corresponding to the second data block means that the feature data of the corresponding data structure is included.
Optionally, adding the structure information of the FAT image file and the data of each used data structure of the FAT image file to the compressed file, including:
generating at least one first data block, each first data block corresponding to one or at least two consecutive unused data structures, each first data block including structure information of the corresponding data structure, excluding data of the corresponding data structure;
generating a file header of the compressed file, wherein the file header of the compressed file comprises the structure information of the first data block, the structure information of a used data structure and the position information of the used data structure in the compressed file, and the overall structure information of the FAT mirror image file;
adding the used data structures of the file header, the first data block and the FAT image file to the compressed file.
Optionally, adding the structure information of the FAT image file and the data in each used data structure of the FAT image file to the compressed file, including:
generating at least one second data block, each second data block corresponding to one or at least two consecutive used data structures, each second data block including structure information and data of the corresponding data structure;
generating a file header of the compressed file, wherein the file header of the compressed file comprises structure information of an unused data structure in the FAT image file and position information of the unused data structure in the FAT image file, structure information of the second data block and overall structure information of the FAT image file;
and adding the file header and the second data block into the compressed file.
Optionally, after adding the structure information of the FAT image file and the data of each used data structure of the FAT image file to the compressed file, the method further includes:
and sending the compressed file.
An apparatus for processing a FAT image file, comprising:
a create compressed file module to: creating a compressed file of the FAT mirror image file;
a compressed file addition module to: and adding the structure information of the FAT image file and the data of each used data structure of the FAT image file into the compressed file, wherein the compressed file does not comprise the data of the unused data structure in the FAT image file.
The embodiment of the invention has the following beneficial effects:
in the embodiment of the invention, a compressed file of the FAT image file is created; and adding the structure information of the FAT image file and the data in each used data structure of the FAT image file into a compressed file, wherein the compressed file does not comprise the data in the unused data structure of the FAT image file. The compressed file is reduced because the compressed file does not contain data of unused data structures. Therefore, the storage resource occupied by the compressed file of the FAT image file is reduced, and the transmission time of the compressed file is reduced under the same transmission speed, so that the transmission efficiency is improved.
A FAT image file processing method comprises the following steps:
reading the structure information of the FAT image file from a compressed file of the FAT image file, wherein the compressed file does not comprise data of an unused data structure;
reading the data of the used data structure from the compressed file according to the read structure information of the FAT image file;
recovering the used data structure in the FAT image file according to the read structure information of the FAT image file and the data of the used data structure;
and recovering the unused data structure in the FAT image file according to the read structure information of the FAT image file and the default data of the unused data structure.
Optionally, reading the structure information of the FAT image file from the compressed file of the FAT image file includes:
reading the structure information of a first data block and a second data block and the whole structure information of the FAT mirror image file from the file header of the compressed file; wherein each first data block corresponds to one or at least two consecutive unused data structures; each second data block corresponds to one or at least two consecutive used data structures;
searching the first data block from the compressed file according to the structure information of the first data block, and reading the structure information of the corresponding data structure from the searched first data block;
searching a second data block from the compressed file according to the structure information of the second data block, and reading the structure information of the corresponding data structure from the searched second data block;
reading the data of the used data structure from the compressed file according to the read structure information of the FAT image file, and the method comprises the following steps:
reading the data of the used data structure from the searched second data block;
restoring the used data structure in the FAT image file according to the read structure information of the FAT image file and the data of the used data structure, and the method comprises the following steps:
writing the data of the used data structure read from the searched second data block into the corresponding data structure according to the structure information of the data structure read from the searched second data block;
recovering the unused data structure in the FAT image file according to the read structure information of the FAT image file and the default data of the unused data structure, wherein the recovering method comprises the following steps:
and writing default data into the corresponding data structure according to the structure information of the data structure read from the searched first data block.
Optionally, the second data block includes data of a corresponding data structure, which refers to all data including the corresponding data structure.
Optionally, if the data of the data structure corresponding to the second data block is not the repetition of the feature data, the data of the data structure corresponding to the second data block includes all data of the corresponding data structure;
if the data of the data structure corresponding to the second data block is the repetition of the characteristic data, the data of the data structure corresponding to the second data block is the characteristic data of the corresponding data structure; writing the data of the used data structure read from the searched second data block into the corresponding data structure according to the structure information of the data structure read from the searched second data block, including:
and writing the characteristic data of the used data structure read from the searched second data block into the corresponding data structure according to the structure information of the data structure read from the searched second data block.
Optionally, reading the structure information of the FAT image file from the compressed file of the FAT image file includes:
reading the structure information of a first data block, the structure information of a used data structure and the position information of the used data structure in the compressed file, and the overall structure information of the FAT mirror image file from the file header of the compressed file; wherein each first data block corresponds to one or at least two consecutive unused data structures;
searching the first data block according to the structure information of the first data block, and reading the structure information of the corresponding data structure from the searched first data block;
reading the data of the used data structure from the compressed file according to the read structure information of the FAT image file, and the method comprises the following steps:
reading the data of the used data structure from the compressed file according to the position information of the read used data structure in the compressed file;
restoring the used data structure in the FAT image file according to the read structure information of the FAT image file and the data of the used data structure, and the method comprises the following steps:
writing the read data of the used data structure into the corresponding data structure according to the read structure information of the used data structure;
recovering the unused data structure in the FAT image file according to the read structure information of the FAT image file and the default data of the unused data structure, wherein the recovering method comprises the following steps:
and writing default data into the corresponding data structure according to the structure information of the data structure read from the searched first data block.
Optionally, reading the structure information of the FAT image file from the compressed file of the FAT image file includes:
reading the structure information of a second data block, the structure information of an unused data structure and the position information of the unused data structure in the compressed file, and the overall structure information of the FAT mirror image file from the file header of the compressed file; wherein each second data block corresponds to one or at least two consecutive used data structures;
searching the second data block according to the structure information of the second data block, and reading the structure information of the corresponding data structure from the searched second data block;
reading the data of the used data structure from the compressed file according to the read structure information of the FAT image file, and the method comprises the following steps:
reading the data of the used data structure from the searched second data block;
restoring the used data structure in the FAT image file according to the read structure information of the FAT image file and the data of the used data structure, and the method comprises the following steps:
writing the data of the used data structure read from the searched second data block into the corresponding data structure according to the structure information of the data structure read from the searched second data block;
recovering the unused data structure in the FAT image file according to the read structure information of the FAT image file and the default data of the unused data structure, wherein the recovering method comprises the following steps:
and writing default data into the corresponding data structure according to the read structure information of the unused data structure and the position information of the unused data structure in the compressed file.
Optionally, before reading the structure information of the FAT image file from the compressed file of the FAT image file, the method further includes:
and receiving the compressed file of the FAT image file.
An apparatus for processing a FAT image file, comprising:
a configuration information reading module for: reading the structure information of the FAT image file from a compressed file of the FAT image file, wherein the compressed file does not comprise data of an unused data structure;
a data reading module to: reading the data of the used data structure from the compressed file according to the read structure information of the FAT image file;
a first recovery module to: recovering the used data structure in the FAT image file according to the read structure information of the FAT image file and the data of the used data structure;
a second recovery module to: and recovering the unused data structure in the FAT image file according to the read structure information of the FAT image file and the default data of the unused data structure.
The embodiment of the invention has the following beneficial effects:
in the embodiment of the invention, the compressed file does not contain data of an unused data structure, so that the size of the compressed file is reduced, and the storage resources occupied by the compressed file are saved. In addition, in the recovery process, data fields do not need to be read from the compressed file, recovery is directly performed according to default data, and the processing speed is high. In addition, the transmission time required for such compressed files is reduced at the same transmission speed, thereby improving the transmission efficiency.
Drawings
Fig. 1 is a flowchart of a first FAT image file processing method according to an embodiment of the present invention;
fig. 2 is a flowchart of a second FAT image file processing method according to an embodiment of the present invention;
fig. 3 is a flowchart of a third FAT image file processing method according to an embodiment of the present invention;
fig. 4 is a flowchart of a fourth FAT image file processing method according to an embodiment of the present invention;
fig. 5 is a flowchart of a fifth FAT image file processing method according to an embodiment of the present invention;
fig. 6 is a flowchart of a sixth FAT image file processing method according to an embodiment of the present invention;
fig. 7 is a flowchart of a seventh FAT image file processing method according to an embodiment of the present invention;
fig. 8 is a flowchart of an eighth FAT image file processing method according to an embodiment of the present invention;
FIG. 9 is a table of cluster chains in a conventional FAT image file;
FIG. 10 illustrates cluster usage in a conventional FAT image file;
fig. 11 is a logic diagram of a FAT image file compressed file according to an embodiment of the present invention;
fig. 12 is a schematic diagram of a first FAT image file processing apparatus according to an embodiment of the present invention;
fig. 13 is a schematic diagram of a second FAT image file processing apparatus according to an embodiment of the present invention;
fig. 14 is a schematic diagram of a third FAT image file processing apparatus according to an embodiment of the present invention;
fig. 15 is a schematic diagram of a fourth FAT image file processing apparatus according to an embodiment of the present invention.
Detailed Description
The method and the apparatus for processing the FAT image file according to the present invention will be described in more detail with reference to the accompanying drawings and embodiments.
As shown in fig. 1, an embodiment of the present invention provides a method for processing a FAT image file, which is implemented in the following specific manner:
step 110: a compressed file of the FAT image file is created.
In this step, an empty compressed file is created.
Step 120: adding the structure information of the FAT image file and the data of each used data structure of the FAT image file into a compressed file, wherein the compressed file does not comprise the data of the unused data structure in the FAT image file.
The data structure of the FAT image file is a component of the FAT image file, i.e., a component of the corresponding FAT file system. Taking the FAT16/32 file system as an example, the file system can be divided into an operating system Boot Record (DBR), a reserved area, a FAT table area and a data area, the capacity of each partition is represented by the number of occupied sectors, the data area takes a cluster as a basic unit, and each cluster occupies one or more sectors; the data structure may be a partition, a sector, a cluster.
The structure information of the FAT image file comprises the whole structure information of the FAT image file and the structure information of each data structure. The overall structure information of the FAT image file includes the total number of data structures in the FAT image file, the total number of bytes of the FAT image file, and the like. Wherein the structure information of each data structure includes the number of bytes of the data structure, and the like.
In the embodiment of the invention, a compressed file of the FAT image file is created; adding the structure information of the FAT image file and the data of each used data structure of the FAT image file into a compressed file, wherein the compressed file does not comprise the data of the unused data structure in the FAT image file. The size of the compressed file is reduced because the compressed file does not contain data of unused data structures. Therefore, the storage resource occupied by the compressed file of the FAT image file is reduced, and the transmission time of the compressed file is reduced under the same transmission speed, so that the transmission efficiency is improved.
There are various implementations of the step 120, as shown in fig. 2, a first implementation may be:
step 210: and generating at least one first data block, wherein each first data block corresponds to one or at least two continuous unused data structures, and each first data block comprises the structure information of the corresponding data structure and does not comprise the data of the corresponding data structure.
The first data block is generated according to a predetermined format, and the first data block includes structure information of the first data block, such as a length, a type, and the like of the first data block, in addition to structure information of a corresponding data structure.
The structure information of the data structure includes the number of bytes of the data structure, and the like.
Step 220: at least one second data block is generated, each second data block corresponding to one or at least two consecutive used data structures, each second data block comprising structure information and data of the corresponding data structure.
The format of the second data block is the same as the format of the first data block, and the second data block includes structure information of the second data block, such as the length and type of the second data block, in addition to the structure information and data of the corresponding data structure.
The structure information of the data structure includes the number of bytes of the data structure, and the like.
Step 230: and generating a file header of the compressed file, wherein the file header of the compressed file comprises the structure information of the first data block and the second data block and the overall structure information of the FAT mirror image file.
The overall structure information of the FAT image file comprises the total number of the first data block and the second data block, the total byte number of the FAT image file, and the like.
Step 240: and adding the file header, the first data block and the second data block into the compressed file.
In the embodiment of the invention, the unused data structure and the used data structure generate data blocks, so that the data processing is more convenient.
It should be noted that the timing of steps 210 and 220 is not limited, and the first data block may be generated first, and then the second data block may be generated, or the first data block and the second data block may be generated in parallel.
Alternatively, the type of data block may be set. In one implementation, the data blocks are divided into two types, the first data block is a type, the data structure corresponding to the data block is an UNUSED data structure, which is called an UNUSED (UNUSED) type, and the second data block is a type, the data structure corresponding to the data block is a used data structure, which is called an original data (RAW) type. Correspondingly, the data in the second data block including the corresponding data structure refers to all data including the corresponding data structure.
The following examples illustrate how the second data block in this classification mode includes data of a corresponding data structure: for example, if the data in the data structure is a, b, c, d, e, the generated second data block includes the data a, b, c, d, e, so that the second data block includes all the data in the corresponding data structure; for another example, if the data in the data structure is f, f, f, the generated second data block includes the data f, f, f, f, f, so that the second data block includes all the data in the corresponding data structure.
In the process of implementing the present invention, the inventor finds that the data in the latter exemplary data structure is a repetition of the data f, and the corresponding data f also includes a repetition in the second data block, and the repeated storage of the same data would cause a waste of storage resources, and in order to further save the storage resources, another classification formula of the data block is provided.
In another implementation, the data blocks are divided into three types, the first data block is a type, the data structure corresponding to such data block is an UNUSED data structure, which is called an UNUSED (UNUSED) type, and the second data block is divided into two types, wherein the data structure corresponding to one type of data block is a used data structure without repeated data, which is called an original data (RAW) type, and the data structure corresponding to another type of data block is a used data structure with characteristic data repetition, which is called a FILL (FILL) type. Correspondingly, if the data of the corresponding data structure of the second data block is not the repetition of the characteristic data, the data of the corresponding data structure included in the second data block means that all the data of the corresponding data structure are included; if the data of the corresponding data structure of the second data block is a repetition of the characteristic data, the data of the corresponding data structure included in the second data block means that the characteristic data of the corresponding data structure is included.
The following examples illustrate how the second data block in this classification mode includes data of a corresponding data structure: for example, if the data in the data structure is a, b, c, d, e, the generated second data block includes the data a, b, c, d, e, so that the second data block includes all the data in the corresponding data structure; for another example, if the data in the data structure is f, f, f, f, f, then the generated second data block includes the data f, so that the second data block only includes the feature data f in the corresponding data structure, instead of including all the data f, f, f, and thus, the storage resource is saved.
In the above embodiment, for the data structure including the repeated data, the characteristic data of the data structure is included only in the second data block, that is, the repeated data is stored only once, so that the data amount in the second data block is reduced, the size of the compressed file is further reduced, and the storage resource occupied by the compressed file is reduced. For the transmission of such a compressed file, the transmission efficiency thereof is further improved.
A first implementation of the above step 120 is described in more detail below by way of example.
In this embodiment, the formats of the first data block and the second data block are as follows:
data block (Chunk) { Chunk type, Chunk length, sector number, data };
the Chunk type and the Chunk length are structure information of the data block, the sector number is structure information of a data structure corresponding to the data block, and the data is data of the data structure corresponding to the data block.
Among them, the Chunk type has two types, RAW type and UNUSED type. In the RAW type, the number of sectors is not 0 and data exists. In the UNUSED type, the number of sectors is not 0 and data does not exist.
The format of the file header is as follows:
file header ═ file ID, file header size, Chunk header structure size (i.e., the size of a Chunk that does not contain data), number of bytes per sector, total number of sectors, total number of chunks, data checksum }
The byte number, the total sector number and the Chunk total number of each sector represent the overall structure information of the FAT image file. The Chunk header structure size embodies the structure information of the data block.
When processing the FAT image file, the specific implementation manner of the step 210 may be: the UNUSED type data blocks are generated for the UNUSED data structures according to the format of Chunk described above.
The specific implementation manner of the step 220 may be: and generating a data block of a RAW type according to the format of the Chunk for the used data structure.
The specific implementation manner of the step 230 may be: and adding the file identification ID, the size of a file header structure, the generated Chunk header structures of the RAW type and the UNUSED type, the byte number of each sector, the total sector number, the total Chunk number and the data checksum into the file header.
The specific implementation manner of the step 240 is: the header, all Chunk are added to the compressed file.
Optionally, as shown in fig. 3, a second implementation manner of the step 120 may be:
step 310: and generating at least one first data block, wherein each first data block corresponds to one or at least two continuous unused data structures, and each first data block comprises the structure information of the corresponding data structure and does not comprise the data of the corresponding data structure.
The first data block is generated according to a predetermined format, and the first data block includes structure information of the first data block, such as a length, a type, and the like of the first data block, in addition to structure information of a corresponding data structure.
The structure information of the data structure includes the number of bytes of the data structure, and the like.
Step 320: and generating a file header of the compressed file, wherein the file header of the compressed file comprises the structure information of the first data block, the structure information of the used data structure and the position information of the used data structure in the compressed file, and the overall structure information of the FAT image file.
The overall structure information of the FAT image file includes the total number of the first data blocks, the total byte number of the FAT image file, and the like.
Step 330: the header, the first data block, and the respective used data structures of the FAT image file are added to the compressed file.
In the embodiment, only the unused data structures are generated into the data blocks, so that the number of the data structures needing to be generated into the data blocks is reduced, and the processing efficiency is improved.
The first implementation manner of step 120 may be referred to for the specific implementation manner of the foregoing embodiments.
Optionally, as shown in fig. 4, a third implementation manner of step 120 may be:
step 410: generating at least one second data block, each second data block corresponding to one or at least two consecutive used data structures, each second data block including structure information and data of the corresponding data structure;
the second data block is generated according to a predetermined format, and the second data block includes structure information of the second data block, such as a length, a type, and the like of the second data block, in addition to the structure information and data of the corresponding data structure.
The structure information of the data structure includes the number of bytes of the data structure, and the like.
Step 420: and generating a file header of the compressed file, wherein the file header of the compressed file comprises the structure information of the unused data structure in the FAT image file and the position information thereof in the compressed file, the structure information of the second data block and the overall structure information of the FAT image file.
The overall structure information of the FAT image file includes the total number of the second data blocks, the total byte number of the FAT image file, and the like.
Step 430: the header and the second data block are added to the compressed file.
In the embodiment, only the data blocks of the used data structure are generated, and the structure information of the unused data structure is added in the file header, and the generated data blocks occupy a certain space, so that the number of the generated data blocks is reduced, and the size of the compressed file is further reduced.
The first implementation manner of step 120 may be referred to for the specific implementation manner of the foregoing embodiments.
On the basis of any of the above embodiments, after the structure information of the FAT image file and the data in each used data structure of the FAT image file are added to the compressed file according to step 120, the obtained compressed file may also be sent. The FAT image file is received by other equipment or terminals, and the transmission of the FAT image file is realized.
Based on the same inventive concept, as shown in fig. 5, when the compressed file needs to be restored to the FAT image file, the embodiment of the present invention further provides a method for processing the FAT image file, which is specifically implemented as follows:
step 510: and reading the structure information of the FAT image file from a compressed file of the FAT image file, wherein the compressed file does not comprise data of unused data structures.
Step 520: and reading the data of the used data structure from the compressed file according to the read structure information of the FAT image file.
The structure information of the FAT image file comprises the whole structure information of the FAT image file and the structure information of each data structure. The overall structure information of the FAT image file includes the total number of data structures in the FAT image file, the total number of bytes of the FAT image file, and the like. Wherein the structure information of each data structure includes the number of bytes of the data structure, and the like.
Step 530: and recovering the used data structure in the FAT image file according to the read structure information of the FAT image file and the data of the used data structure.
Step 540: and recovering the unused data structure in the FAT image file according to the read structure information of the FAT image file and the default data of the unused data structure.
In the embodiment of the invention, the compressed file does not contain data of an unused data structure, so that the size of the compressed file is reduced, and the storage resources occupied by the compressed file are saved. In addition, in the recovery process, data fields do not need to be read from the compressed file, recovery is directly performed according to default data, and the processing speed is high. In addition, the transmission time required for such compressed files is reduced at the same transmission speed, thereby improving the transmission efficiency.
Optionally, there are multiple implementation manners of the above steps 510 to 540, as shown in fig. 6, a first implementation manner may be:
step 610: reading the structure information of the first data block and the second data block and the overall structure information of the FAT mirror image file from the file header of the compressed file; wherein each first data block corresponds to one or at least two consecutive unused data structures; each second data block corresponds to one or at least two consecutive used data structures; searching a first data block from the compressed file according to the structure information of the first data block, and reading the structure information of the corresponding data structure from the searched first data block; and searching the second data block from the compressed file according to the structure information of the second data block, and reading the structure information of the corresponding data structure from the searched second data block.
The first data block is generated according to a predetermined format, and the first data block includes structure information of the first data block, such as a length, a type, and the like of the first data block, in addition to structure information of a corresponding data structure.
The format of the second data block is the same as the format of the first data block, and the second data block includes structure information of the second data block, such as the length and type of the second data block, in addition to the structure information and data of the corresponding data structure.
The structure information of the data structure includes the number of bytes of the data structure, and the like.
The overall structure information of the FAT image file comprises the total number of the first data block and the second data block, the total byte number of the FAT image file, and the like.
Step 620: and reading the data of the used data structure from the searched second data block.
Step 630: and writing the data of the used data structure read from the searched second data block into the corresponding data structure according to the structure information of the data structure read from the searched second data block.
Step 640: and writing default data into the corresponding data structure according to the structure information of the data structure read from the searched first data block.
In this embodiment, the unused data structure and the used data structure have corresponding data blocks, so that data processing is more convenient.
It should be noted that the timing of steps 620 and 640 is not limited, and the first data block may be processed first and then the second data block, or the first data block and the second data block may be processed in parallel.
In the embodiment of processing the FAT image file to obtain the compressed file, optionally, in the embodiment, the second data block includes data of a corresponding data structure, which refers to all data including the corresponding data structure.
Optionally, in the foregoing embodiment, if the data of the corresponding data structure of the second data block is not a duplicate of the feature data, the data of the corresponding data structure included in the second data block means that all data of the corresponding data structure is included. If the data of the data structure corresponding to the second data block is the repetition of the feature data, and the data of the data structure corresponding to the second data block means that the feature data of the corresponding data structure is included, correspondingly, the specific implementation manner of step 630 may be:
and writing the characteristic data of the used data structure read from the searched second data block into the corresponding data structure according to the structure information of the data structure read from the searched second data block.
In this embodiment, for the data structure including the duplicate data, only the second data block includes the feature data of the data structure, that is, the duplicate data is stored only once, and accordingly, the read data is reduced, thereby improving the processing efficiency.
Alternatively, the default data mentioned in the above embodiments may be all 0, or all F, and so on.
For example, the specific implementation manner of the steps 610 to 640 may be to restore a compressed file obtained in the first implementation manner of the step 120:
reading the file header of the Sparse (Sparse) file (i.e. the compressed file) to obtain the number of bytes, the total number of sectors, the total number of chunks, and the like of each sector. Reading a Chunk head structure in sequence, and if the Chunk head structure is of an RAW type, directly reading data in a data block Chunk and writing the data into an FAT (file allocation table) image file; if the FAT image file is of a FILL type, reading the characteristic data, and writing the characteristic data of the corresponding sector number into the FAT image file, and if the FAT image file is of an UNUSED type, directly writing all 0 data in the corresponding sector of the FAT image file.
Optionally, when recovering the compressed file obtained in the second implementation manner of step 120, as shown in fig. 7, the second implementation manner of steps 510 to 540 may be:
step 710: reading the structure information of a first data block, the structure information of a used data structure and the position information of the used data structure in the compressed file and the overall structure information of the FAT mirror image file from the file header of the compressed file; wherein each first data block corresponds to one or at least two consecutive unused data structures; and searching the first data block according to the structure information of the first data block, and reading the structure information of the corresponding data structure from the searched first data block.
The first data block is generated according to a predetermined format, and the first data block includes structure information of the first data block, such as a length, a type, and the like of the first data block, in addition to structure information of a corresponding data structure.
The structure information of the data structure includes the number of bytes of the data structure, and the like.
The overall structure information of the FAT image file includes the total number of the first data blocks, the total byte number of the FAT image file, and the like.
Step 720: and reading the data of the used data structure from the compressed file according to the position information of the read used data structure in the compressed file.
Step 730: and writing the data of the read used data structure into the corresponding data structure according to the structure information of the read used data structure.
Step 740: and writing default data into the corresponding data structure according to the structure information of the data structure read from the searched first data block.
In the embodiment of the invention, only the first data block of the unused data structure needs to be processed, so that the number of the data structures needing to be processed is reduced, and the processing efficiency is improved.
Optionally, when recovering the compressed file obtained in the third implementation manner of step 120, as shown in fig. 8, the third implementation manner of steps 510 to 540 may be:
step 810: reading the structure information of the second data block, the structure information of an unused data structure and the position information of the unused data structure in the compressed file, and the overall structure information of the FAT mirror image file from the file header of the compressed file; wherein each second data block corresponds to one or at least two consecutive used data structures; and searching the second data block according to the structure information of the second data block, and reading the structure information of the corresponding data structure from the searched second data block.
The second data block is generated according to a predetermined format, and the second data block includes structure information of the second data block, such as a length, a type, and the like of the second data block, in addition to the structure information and data of the corresponding data structure.
The structure information of the data structure includes the number of bytes of the data structure, and the like.
The overall structure information of the FAT image file includes the total number of the second data blocks, the total byte number of the FAT image file, and the like.
Step 820: and reading the data of the used data structure from the searched second data block.
Step 830: and writing the data of the used data structure read from the searched second data block into the corresponding data structure according to the structure information of the data structure read from the searched second data block.
Step 840: and writing default data into the corresponding data structure according to the read structure information of the unused data structure and the position information of the unused data structure in the compressed file.
In this embodiment, only the second data block of the used data structure exists in the compressed file, and only the structure information of the unused data structure exists in the header, so that the number of data blocks is reduced, the size of the compressed file is further reduced, and the processing efficiency is improved.
On the basis of any of the above embodiments, before performing step 510, the method further includes: a compressed file of the FAT image file is received.
Wherein the compressed file may be received from other devices or terminals.
The following describes a method for processing a FAT image file according to an embodiment of the present invention in more detail by taking the FAT image file as an example.
In this embodiment, taking the FAT16/32 image file as an example, in the FAT16/32 disk image, the FAT file system can be divided into a DBR, a reserved area, a FAT table area, and a data area.
Wherein the DBR specifies: the number of bytes per sector, the number of reserved sectors, the number of FAT tables (1 or 2, FAT2 being a backup of FAT 1), the number of sectors per FAT table, the number of sectors per cluster, the number of bytes per cluster (number of bytes per sector x number of sectors per cluster).
The FAT table is an index table that indicates the usage status (used or unused) of all clusters in the data area, and is also a linked list that indicates the splicing order of large blocks of data, for example, a large file needs to occupy multiple clusters, and the data of each cluster can be found in order through the linked list in the FAT table. The cluster number of FAT16 has 16 bits (bit) as a basic unit, and the structure is shown in fig. 9. In the cluster chain table, the cluster 0/1 is a reserved area, the content of the cluster n is a number pointing to the next cluster, if it is FFFF, it indicates that the cluster chain ends up, if the content of the cluster 2 is 0300, it indicates that the next cluster of the cluster 2 is cluster 3, and the content of the cluster 3 is FFFF, which indicates that there is no next cluster.
Each cluster of the data area has a number (starting with 2 by default), and the state and continuity of the cluster are stored by number in the FAT table.
When a series of operations of adding, deleting and renaming directories/files and increasing and decreasing files are carried out on the FAT16/32 disk, the directories/files are increased: finding out the cluster where the current directory is located, reallocating a new cluster and modifying a corresponding cluster chain in the FAT if the cluster is full, finding out the position of an unused directory entry for adding, and allocating a cluster for the directory entry; delete directory/file: finding out the cluster of the parent directory entry, modifying the corresponding cluster of the directory entry in the FAT table to be in an unallocated state (recovery), finding out the juxtaposition mark 0xE5 (deleted) of the entry from the parent directory entry, and enabling the deleted directory entry not to be used any more; if the directory entry monopolizes a cluster, the FAT table can be modified to recover the cluster; directory/file renaming: deleting and then adding; file enlargement: re-allocating clusters for the file and modifying cluster chain information of the file in the FAT table; file reduction: directly modifying the cluster chain information of the file in the FAT table and recycling the vacant clusters.
The allocation principle of clusters in the data area is: as continuous as possible. One file occupies a plurality of clusters, and the fastest access efficiency can be ensured if the cluster numbers are consecutive. Such as: the file f1 occupies 5 clusters, and the cluster chain 3-4-5-6-7 allocated to it is a block. If there are not so many consecutive clusters in a free cluster, it is possible to allocate such a cluster chain 3-4-5-9-10 as a plurality of blocks, and many fragmentation occurs. As shown in fig. 10, the cluster m +1, the cluster m +2, the cluster n, the cluster k +1, the cluster j +1, and the cluster j +2 are allocated (bold font in the figure). The allocation status of these clusters is managed by the FAT table.
When the FAT image file is compressed, the first method of step 120 is adopted to perform processing, where the first data block and the second data block have the same format, and the format is as follows:
chunk ═ Chunk type, Chunk length, number of sectors, data };
the Chunk type and the Chunk length are structure information of the data block, the sector number is structure information of a data structure corresponding to the data block, and the data is data of the data structure corresponding to the data block.
Among them, the Chunk type has two types, RAW type and UNUSED type. The RAW type indicates that a corresponding data structure is used, the number of sectors in Chunk is not 0, and data exists. UNUSED type, indicating that the corresponding data structure is UNUSED, the number of sectors in Chunk is not 0 and data does not exist.
In addition, the format of the spare file header is as follows:
the spare header is { file ID, spare header structure size, Chunk header structure size (i.e., size of Chunk structure not including data field), number of bytes per sector, total number of sectors, total number of chunks, data checksum }.
The byte number, the total sector number and the Chunk total number of each sector represent the overall structure information of the FAT image file. The Chunk header structure size embodies the structure information of the data block.
When the FAT image file is processed according to the file header formats of the Chunk and spare files, a compressed file of the FAT image file is created, the DBR (initial 512 bytes) is read from the source FAT image file, the information such as the byte number of each sector is obtained, the spare file header of the compressed file is initialized by the information, and the information is added to the compressed file. Reading the data of the reserved area in the FAT image file, generating a Chunk #0, wherein the Chunk type is a RAW type, and adding the Chunk type into the compressed file. Reading the sector number of each FAT table in the FAT table data and the number of the FAT tables to generate a Chunk #1, wherein the Chunk type is a RAW type and is added into a compressed file. Traversing FAT1 starting from cluster number 2, generating a RAW type of Chunk for a single used cluster or consecutive used clusters, generating an UNUSED type of Chunk for UNUSED clusters, and adding to the compressed file. Wherein, each Chunk contains the sector number equal to the product of the sector number of each cluster and the number of clusters. And updating the spare file header according to the format of the spare file header and adding the spare file header to the compressed file. The resulting spare file (i.e., compressed file) is shown in fig. 11.
If the classification mode of the UNUSED type, the RAW type and the FILL type is adopted, the data are analyzed and judged, and if the data are the repetition of a certain value X. Here, X is feature data, and default feature data is 0X00000000, 0 xFFFFFFFF. For example, the above Chunk #0 corresponds to the data structure of the reserved area, in the reserved area, the 0 th sector includes DBR information, and cannot be of a FILL type, and the default padding is 0 from sector 1, and this part of sectors can be represented by a FILL type, so that Chunk #0 can be represented as two data blocks, Chunk #01(RAW type) and Chunk #02(FILL type, data is 0x00000000), at this time, and the purpose of further reducing the size of the compressed file is achieved.
In this embodiment, taking the exFAT image file as an example, in the disk image of the exFAT image file, the file system may be divided into a reserved area, a BOOT area, a FAT table area, and a data area.
The main BOOT partition DBR through the BOOT area can specify: the number of bytes of each sector, the number of sectors of each cluster, the number of bytes of each cluster, the number of FAT tables, the number of FAT table offset sectors, the number of FAT table sectors, the number of total sectors of a disk, the number of cluster pile offset sectors, and the number of total clusters of a data area.
Referring to the FAT16/32 image file processing method, a compressed file of the exFAT image file is created, the DBR in the exFAT image file is read, information such as the number of bytes of each sector is obtained, a spare file header is initialized by the information, and the information is added to the compressed file. Reading the FAT table offset sector number of the BOOT area, creating a Chunk #0 with the type of RAW, and adding the Chunk #0 to the compressed file. And reading data in the FAT area before the cluster heap allocation table to create a Chunk #2 with the type of RAW, and adding the Chunk #2 into the compressed file. The FAT table is traversed starting from cluster number 2, a RAW type Chunk is generated for a single used cluster or consecutive used clusters, an UNUSED type Chunk is generated for UNUSED clusters, and added to the compressed file. Wherein, each Chunk contains the sector number equal to the product of the sector number of each cluster and the number of clusters. The spare file header is updated and added to the compressed file.
If classification such as the UNUSED type, the RAW type and the FILL type is adopted, the processing method also refers to the processing method of the FAT16/32 image file.
In the above embodiment, after the FAT image file is compressed to obtain the compressed file, the FAT image file can be reversely restored, and the specific implementation manner is as follows:
and reading a file header of the spare file to obtain the byte number, the total sector number, the total Chunk number and the like of each sector. Reading a Chunk head structure in sequence, and if the Chunk head structure is of an RAW type, directly reading data in the Chunk and writing the data into an FAT image file; if the FAT image file is of a FILL type, reading the characteristic data, and writing the characteristic data of the corresponding sector number into the FAT image file, and if the FAT image file is of an UNUSED type, directly writing all 0 data in the corresponding sector of the FAT image file.
It should be noted that the above embodiments can be applied in the FAT image file compression scenario, the FAT disk fast clone scenario, and the FAT image fast mass production scenario.
Based on the same inventive concept, as shown in fig. 12, an embodiment of the present invention provides an apparatus for FAT image file processing, which includes a compressed file creating module 1201 and a compressed file adding module 1202.
A create compressed file module 1201 for: creating a compressed file of the FAT mirror image file;
a compressed file adding module 1202 for: the structure information of the FAT image file and the data of each used data structure of the FAT image file are added to a compressed file that does not include the data of the unused data structure in the FAT image file.
In the embodiment of the invention, a compressed file of the FAT image file is created; adding the structure information of the FAT image file and the data of each used data structure of the FAT image file into a compressed file, wherein the compressed file does not comprise the data of the unused data structure in the FAT image file. The size of the compressed file is reduced because the compressed file does not contain data of unused data structures. Therefore, the storage resource occupied by the compressed file of the FAT image file is reduced, and the transmission time of the compressed file is reduced under the same transmission speed, so that the transmission efficiency is improved.
Optionally, the compressed file adding module 1202 is specifically configured to:
generating at least one first data block, each first data block corresponding to one or at least two consecutive unused data structures, each first data block including structure information of the corresponding data structure, excluding data of the corresponding data structure;
generating at least one second data block, each second data block corresponding to one or at least two consecutive used data structures, each second data block including structure information and data of the corresponding data structure;
generating a file header of a compressed file, wherein the file header of the compressed file comprises structure information of a first data block and a second data block and integral structure information of an FAT (file allocation table) image file;
and adding the file header, the first data block and the second data block into the compressed file.
Optionally, the data in the corresponding data structure included in the second data block refers to all data in the corresponding data structure.
Optionally, if the data of the data structure corresponding to the second data block is not the repetition of the feature data, the data of the data structure corresponding to the second data block includes all data of the corresponding data structure;
if the data of the corresponding data structure of the second data block is a repetition of the characteristic data, the data of the corresponding data structure included in the second data block means that the characteristic data of the corresponding data structure is included.
Optionally, the compressed file adding module 1202 is specifically configured to:
generating at least one first data block, each first data block corresponding to one or at least two consecutive unused data structures, each first data block including structure information of the corresponding data structure, excluding data of the corresponding data structure;
generating a file header of a compressed file, wherein the file header of the compressed file comprises structure information of a first data block, structure information of a used data structure and position information of the used data structure in the compressed file, and overall structure information of an FAT (file allocation table) image file;
the header, the first data block, and the respective used data structures of the FAT image file are added to the compressed file.
Optionally, the compressed file adding module 1202 is specifically configured to:
generating at least one second data block, each second data block corresponding to one or at least two consecutive used data structures, each second data block including structure information and data of the corresponding data structure;
generating a file header of a compressed file, wherein the file header of the compressed file comprises structure information of an unused data structure in the FAT image file and position information of the unused data structure in the compressed file, structure information of a second data block and overall structure information of the FAT image file;
and adding the file header and the second data block into the compressed file.
Optionally, as shown in fig. 13, the apparatus further includes a compressed file sending module 1203.
A compressed file sending module 1203, configured to: the compressed file adding module 1202 adds the structure information of the FAT image file and the data in each used data structure of the FAT image file to the compressed file, and then transmits the compressed file.
Based on the same inventive concept, as shown in fig. 14, an embodiment of the present invention further provides an apparatus for processing a FAT image file, including: a configuration information reading module 1401, a data reading module 1402, a first restoring module 1403, and a second restoring module 1404.
A configuration information reading module 1401 configured to: reading the structure information of the FAT image file from a compressed file of the FAT image file, wherein the FAT image file does not comprise data of an unused data structure;
a data reading module 1402 for: reading the data of the used data structure from the compressed file according to the read structure information of the FAT image file;
a first recovery module 1403 for: recovering the used data structure in the FAT image file according to the read structure information of the FAT image file and the used data structure;
a second recovery module 1404 configured to: and recovering the unused data structure in the FAT image file according to the read structure information of the FAT image file and the default data of the unused data structure.
In the embodiment of the invention, the compressed file does not contain data of an unused data structure, so that the size of the compressed file is reduced, and the storage resources occupied by the compressed file are saved. In addition, in the recovery process, data fields do not need to be read from the compressed file, recovery is directly performed according to default data, and the processing speed is high. In addition, the transmission time required for such compressed files is reduced at the same transmission speed, thereby improving the transmission efficiency.
Optionally, the structural information reading module 1401 is specifically configured to:
reading the structure information of the first data block and the second data block and the overall structure information of the FAT mirror image file from the file header of the compressed file; wherein each first data block corresponds to one or at least two consecutive unused data structures; each second data block corresponds to one or at least two consecutive used data structures; searching a first data block from the compressed file according to the structure information of the first data block, and reading the structure information of the corresponding data structure from the searched first data block; searching a second data block from the compressed file according to the structure information of the second data block, and reading the structure information of the corresponding data structure from the searched second data block;
the data reading module 1402 is specifically configured to:
reading the data of the used data structure from the searched second data block;
the first recovery module 1403 is specifically configured to:
writing the data of the used data structure read from the searched second data block into the corresponding data structure according to the structure information of the data structure read from the searched second data block;
the second recovery module 1404 is specifically configured to:
and writing default data into the corresponding data structure according to the structure information of the data structure read from the searched first data block.
Optionally, the data in the corresponding data structure included in the second data block refers to all data in the corresponding data structure.
Optionally, if the data of the data structure corresponding to the second data block is not the repetition of the feature data, the data of the data structure corresponding to the second data block includes all data of the corresponding data structure;
if the data of the corresponding data structure of the second data block is the repetition of the characteristic data, the data of the corresponding data structure of the second data block means that the characteristic data of the corresponding data structure is included; when the data of the used data structure read from the searched second data block is written into the corresponding data structure according to the structure information of the data structure read from the searched second data block, the first recovery module 1403 is specifically configured to: and writing the characteristic data of the used data structure read from the searched second data block into the corresponding data structure according to the structure information of the data structure read from the searched second data block.
Optionally, the structural information reading module 1401 is specifically configured to: reading the structure information of a first data block, the structure information of a used data structure and the position information of the used data structure in the compressed file and the overall structure information of the FAT mirror image file from the file header of the compressed file; wherein each first data block corresponds to one or at least two consecutive unused data structures; searching the first data block according to the structure information of the first data block, and reading the structure information of the corresponding data structure from the searched first data block;
the data reading module 1402 is specifically configured to: reading the data of the used data structure from the compressed file according to the position information of the read used data structure in the compressed file;
the first recovery module 1403 is specifically configured to: writing the read data of the used data structure into the corresponding data structure according to the read structure information of the used data structure;
the second recovery module 1404 is specifically configured to: and writing default data into the corresponding data structure according to the structure information of the data structure read from the searched first data block.
Optionally, the structural information reading module 1401 is specifically configured to: reading the structure information of the second data block, the structure information of an unused data structure and the position information of the unused data structure in the compressed file, and the overall structure information of the FAT mirror image file from the file header of the compressed file; wherein each second data block corresponds to one or at least two consecutive used data structures; searching the second data block according to the structure information of the second data block, and reading the structure information of the corresponding data structure from the searched second data block;
the data reading module 1402 is specifically configured to: reading the data of the used data structure from the searched second data block;
the first recovery module 1403 is specifically configured to:
writing the data of the used data structure read from the searched second data block into the corresponding data structure according to the structure information of the data structure read from the searched second data block;
the second recovery module 1404 is specifically configured to:
and writing default data into the corresponding data structure according to the read structure information of the unused data structure and the position information of the unused data structure in the compressed file.
Optionally, as shown in fig. 15, the apparatus further includes a compressed file receiving module 1405.
The compressed file receiving module 1405 is configured to: the structure information reading module 1401 receives the compressed file of the FAT image file before reading the structure information of the FAT image file from the compressed file of the FAT image file.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (16)

1. A method for processing FAT image files is characterized by comprising the following steps:
creating a compressed file of a File Allocation Table (FAT) mirror image file;
adding the structure information of the FAT image file and the data of each used data structure of the FAT image file into the compressed file, wherein the compressed file does not comprise the data of the unused data structure in the FAT image file;
the structure information of the FAT image file comprises the whole structure information of the FAT image file and the structure information of each data structure;
the structure information of the used data structure and the structure information of the unused data structure of the FAT mirror image file are in different data blocks in the compressed file, and the data block in which the structure information of the used data structure is located comprises the data of the used data structure;
the file header of the compressed file comprises structure information of each data block and the whole structure information, the whole structure information comprises the total number of the data blocks and the total byte number of the FAT mirror image file, and the structure information of the data blocks comprises the length and the type of the data blocks;
the type is used for representing that a data structure corresponding to the data block is an unused data structure or a used data structure;
wherein the compressed file is used to recover the FAT image file from the compressed file.
2. The method according to claim 1, wherein adding the structure information of the FAT image file and the data of the respective used data structures of the FAT image file to the compressed file comprises:
generating at least one first data block, each first data block corresponding to one or at least two consecutive unused data structures, each first data block including structure information of the corresponding data structure, excluding data of the corresponding data structure;
generating at least one second data block, each second data block corresponding to one or at least two consecutive used data structures, each second data block including structure information and data of the corresponding data structure;
generating a file header of the compressed file, wherein the file header of the compressed file comprises the structure information of the first data block and the second data block and the overall structure information of the FAT mirror image file;
adding the file header, the first data block and the second data block to the compressed file.
3. The method according to claim 2, wherein the data in the second data block that includes the corresponding data structure refers to all data that includes the corresponding data structure.
4. The method of claim 2, wherein if the second data block corresponds to a data structure whose data is not a duplicate of the characteristic data, the second data block includes the data of the corresponding data structure, which means that all data of the corresponding data structure is included;
if the data of the data structure corresponding to the second data block is the repetition of the feature data, the data of the data structure corresponding to the second data block means that the feature data of the corresponding data structure is included.
5. The method according to claim 1, wherein adding the structure information of the FAT image file and the data of the respective used data structures of the FAT image file to the compressed file comprises:
generating at least one first data block, each first data block corresponding to one or at least two consecutive unused data structures, each first data block including structure information of the corresponding data structure, excluding data of the corresponding data structure;
generating a file header of the compressed file, wherein the file header of the compressed file comprises the structure information of the first data block, the structure information of a used data structure and the position information of the used data structure in the compressed file, and the overall structure information of the FAT mirror image file;
adding the used data structures of the file header, the first data block and the FAT image file to the compressed file.
6. The method according to claim 1, wherein adding the structure information of the FAT image file and the data in the respective used data structures of the FAT image file to the compressed file comprises:
generating at least one second data block, each second data block corresponding to one or at least two consecutive used data structures, each second data block including structure information and data of the corresponding data structure;
generating a file header of the compressed file, wherein the file header of the compressed file comprises structure information of an unused data structure in the FAT image file and position information of the unused data structure in the FAT image file, structure information of the second data block and overall structure information of the FAT image file;
and adding the file header and the second data block into the compressed file.
7. The method according to any one of claims 1 to 6, wherein after adding the structure information of the FAT image file and the data of each used data structure of the FAT image file to the compressed file, the method further comprises:
and sending the compressed file.
8. A method for processing FAT image files is characterized by comprising the following steps:
reading the structure information of the FAT image file from a compressed file of the FAT image file, wherein the compressed file does not comprise data of an unused data structure;
the structure information of the FAT image file comprises the whole structure information of the FAT image file and the structure information of each data structure;
the structure information of the used data structure and the structure information of the unused data structure of the FAT mirror image file are in different data blocks in the compressed file, and the data block in which the structure information of the used data structure is located comprises the data of the used data structure;
the file header of the compressed file comprises structure information of each data block and the whole structure information, the whole structure information comprises the total number of the data blocks and the total byte number of the FAT mirror image file, and the structure information of the data blocks comprises the length and the type of the data blocks;
the type is used for representing that a data structure corresponding to the data block is an unused data structure or a used data structure;
reading the data of the used data structure from the compressed file according to the read structure information of the FAT image file;
recovering the used data structure in the FAT image file according to the read structure information of the FAT image file and the data of the used data structure;
and recovering the unused data structure in the FAT image file according to the read structure information of the FAT image file and the default data of the unused data structure.
9. The method of claim 8, wherein reading the structure information of the FAT image file from a compressed file of the FAT image file comprises:
reading the structure information of a first data block and a second data block and the whole structure information of the FAT mirror image file from the file header of the compressed file; wherein each first data block corresponds to one or at least two consecutive unused data structures; each second data block corresponds to one or at least two consecutive used data structures;
searching the first data block from the compressed file according to the structure information of the first data block, and reading the structure information of the corresponding data structure from the searched first data block;
searching a second data block from the compressed file according to the structure information of the second data block, and reading the structure information of the corresponding data structure from the searched second data block;
reading the data of the used data structure from the compressed file according to the read structure information of the FAT image file, and the method comprises the following steps:
reading the data of the used data structure from the searched second data block;
restoring the used data structure in the FAT image file according to the read structure information of the FAT image file and the data of the used data structure, and the method comprises the following steps:
writing the data of the used data structure read from the searched second data block into the corresponding data structure according to the structure information of the data structure read from the searched second data block;
recovering the unused data structure in the FAT image file according to the read structure information of the FAT image file and the default data of the unused data structure, wherein the recovering method comprises the following steps:
and writing default data into the corresponding data structure according to the structure information of the data structure read from the searched first data block.
10. The method according to claim 9, wherein the data in the second data block that includes the corresponding data structure refers to all data that includes the corresponding data structure.
11. The method of claim 9, wherein if the second data block corresponds to a data structure whose data is not a duplicate of the characteristic data, the second data block includes the corresponding data structure's data, which means that all data of the corresponding data structure is included;
if the data of the data structure corresponding to the second data block is the repetition of the characteristic data, the data of the data structure corresponding to the second data block is the characteristic data of the corresponding data structure; writing the data of the used data structure read from the searched second data block into the corresponding data structure according to the structure information of the data structure read from the searched second data block, including:
and writing the characteristic data of the used data structure read from the searched second data block into the corresponding data structure according to the structure information of the data structure read from the searched second data block.
12. The method of claim 8, wherein reading the structure information of the FAT image file from a compressed file of the FAT image file comprises:
reading the structure information of a first data block, the structure information of a used data structure and the position information of the used data structure in the compressed file, and the overall structure information of the FAT mirror image file from the file header of the compressed file; wherein each first data block corresponds to one or at least two consecutive unused data structures;
searching the first data block according to the structure information of the first data block, and reading the structure information of the corresponding data structure from the searched first data block;
reading the data of the used data structure from the compressed file according to the read structure information of the FAT image file, and the method comprises the following steps:
reading the data of the used data structure from the compressed file according to the position information of the read used data structure in the compressed file;
restoring the used data structure in the FAT image file according to the read structure information of the FAT image file and the data of the used data structure, and the method comprises the following steps:
writing the read data of the used data structure into the corresponding data structure according to the read structure information of the used data structure;
recovering the unused data structure in the FAT image file according to the read structure information of the FAT image file and the default data of the unused data structure, wherein the recovering method comprises the following steps:
and writing default data into the corresponding data structure according to the structure information of the data structure read from the searched first data block.
13. The method of claim 8, wherein reading the structure information of the FAT image file from a compressed file of the FAT image file comprises:
reading the structure information of a second data block, the structure information of an unused data structure and the position information of the unused data structure in the compressed file, and the overall structure information of the FAT mirror image file from the file header of the compressed file; wherein each second data block corresponds to one or at least two consecutive used data structures;
searching the second data block according to the structure information of the second data block, and reading the structure information of the corresponding data structure from the searched second data block;
reading the data of the used data structure from the compressed file according to the read structure information of the FAT image file, and the method comprises the following steps:
reading the data of the used data structure from the searched second data block;
restoring the used data structure in the FAT image file according to the read structure information of the FAT image file and the data of the used data structure, and the method comprises the following steps:
writing the data of the used data structure read from the searched second data block into the corresponding data structure according to the structure information of the data structure read from the searched second data block;
recovering the unused data structure in the FAT image file according to the read structure information of the FAT image file and the default data of the unused data structure, wherein the recovering method comprises the following steps:
and writing default data into the corresponding data structure according to the read structure information of the unused data structure and the position information of the unused data structure in the compressed file.
14. The method according to any one of claims 8 to 13, wherein before reading the structure information of the FAT image file from the compressed file of the FAT image file, the method further comprises:
and receiving the compressed file of the FAT image file.
15. An apparatus for processing a FAT image file, comprising:
a create compressed file module to: creating a compressed file of the FAT mirror image file;
a compressed file addition module to: adding the structure information of the FAT image file and the data of each used data structure of the FAT image file into the compressed file, wherein the compressed file does not comprise the data of the unused data structure in the FAT image file;
the structure information of the FAT image file comprises the whole structure information of the FAT image file and the structure information of each data structure;
the structure information of the used data structure and the structure information of the unused data structure of the FAT mirror image file are in different data blocks in the compressed file, and the data block in which the structure information of the used data structure is located comprises the data of the used data structure;
the file header of the compressed file comprises structure information of each data block and the whole structure information, the whole structure information comprises the total number of the data blocks and the total byte number of the FAT mirror image file, and the structure information of the data blocks comprises the length and the type of the data blocks;
the type is used for representing that a data structure corresponding to the data block is an unused data structure or a used data structure;
wherein the compressed file is used to recover the FAT image file from the compressed file.
16. An apparatus for processing a FAT image file, comprising:
a configuration information reading module for: reading the structure information of the FAT image file from a compressed file of the FAT image file, wherein the compressed file does not comprise data of an unused data structure;
the structure information of the FAT image file comprises the whole structure information of the FAT image file and the structure information of each data structure;
the structure information of the used data structure and the structure information of the unused data structure of the FAT mirror image file are in different data blocks in the compressed file, and the data block in which the structure information of the used data structure is located comprises the data of the used data structure;
the file header of the compressed file comprises structure information of each data block and the whole structure information, the whole structure information comprises the total number of the data blocks and the total byte number of the FAT mirror image file, and the structure information of the data blocks comprises the length and the type of the data blocks;
the type is used for representing that a data structure corresponding to the data block is an unused data structure or a used data structure;
a data reading module to: reading the data of the used data structure from the compressed file according to the read structure information of the FAT image file;
a first recovery module to: recovering the used data structure in the FAT image file according to the read structure information of the FAT image file and the data of the used data structure;
a second recovery module to: and recovering the unused data structure in the FAT image file according to the read structure information of the FAT image file and the default data of the unused data structure.
CN201510469405.4A 2015-07-31 2015-07-31 FAT (file allocation table) image file processing method and device Active CN106708831B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510469405.4A CN106708831B (en) 2015-07-31 2015-07-31 FAT (file allocation table) image file processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510469405.4A CN106708831B (en) 2015-07-31 2015-07-31 FAT (file allocation table) image file processing method and device

Publications (2)

Publication Number Publication Date
CN106708831A CN106708831A (en) 2017-05-24
CN106708831B true CN106708831B (en) 2020-12-01

Family

ID=58929776

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510469405.4A Active CN106708831B (en) 2015-07-31 2015-07-31 FAT (file allocation table) image file processing method and device

Country Status (1)

Country Link
CN (1) CN106708831B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112235427B (en) * 2020-12-14 2021-03-30 广东睿江云计算股份有限公司 Merging method and system for mirror image files

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101499027A (en) * 2009-03-06 2009-08-05 赵晓宇 Intelligent memory system based on independent kernel and distributed architecture

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3940902B2 (en) * 2002-04-22 2007-07-04 ソニー株式会社 Information processing apparatus, information processing apparatus control method, information processing apparatus control program, and recording medium recording information processing apparatus control program
CN101923553A (en) * 2009-06-11 2010-12-22 鸿富锦精密工业(深圳)有限公司 Installation method of FAT (File Allocation Table) file system
CN102929884B (en) * 2011-08-10 2016-05-04 阿里巴巴集团控股有限公司 A kind of method and device that shrinks virtual disk image file
CN103677915B (en) * 2013-12-11 2018-08-07 厦门雅迅网络股份有限公司 A method of card is started based on TF and carries out the automatic programming of flash mirror
CN104572492A (en) * 2015-01-22 2015-04-29 福州瑞芯微电子有限公司 Method and apparatus of burning data to FAT (File Allocation Table)32 partition

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101499027A (en) * 2009-03-06 2009-08-05 赵晓宇 Intelligent memory system based on independent kernel and distributed architecture

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"FAT32下有效数据快速恢复方法";杨德明;《计算机应用》;20120901;第32卷(第9期);第2500-2503页 *

Also Published As

Publication number Publication date
CN106708831A (en) 2017-05-24

Similar Documents

Publication Publication Date Title
KR102007070B1 (en) Reference block aggregating into a reference set for deduplication in memory management
US9928250B2 (en) System and method for managing deduplication using checkpoints in a file storage system
US20200226100A1 (en) Metadata query method and apparatus
JP5732536B2 (en) System, method and non-transitory computer-readable storage medium for scalable reference management in a deduplication-based storage system
US10802923B2 (en) Method and apparatus for incremental backup based on file paths and a prefix tree
CN103098035A (en) Storage system
JP6527462B2 (en) Compression device, compression method, recording medium and decompression device
CN107798063B (en) Snapshot processing method and snapshot processing device
CN103995855A (en) Method and device for storing data
CN103678337A (en) Data eliminating method, device and system
US20170242872A1 (en) Method for reliable and efficient filesystem metadata conversion
CN112612576B (en) Virtual machine backup method and device, electronic equipment and storage medium
US20130262799A1 (en) Control method and storage device
CN112732191A (en) Method, system, device and medium for merging tree merging data based on log structure
CN106708831B (en) FAT (file allocation table) image file processing method and device
CN105573862B (en) Method and equipment for recovering file system
CN115543859A (en) Wear leveling optimization method, device, equipment and medium for multi-partition SSD
CN112380174B (en) XFS file system analysis method containing deleted files, terminal device and storage medium
CN103559106A (en) Data backup method, device and system
CN111125011A (en) File processing method, system and related equipment
CN114691418B (en) Information recovery method and device for storage device, electronic device and storage medium
CN106033454B (en) Formatting method, processing method and device of virtual file system
CN111857547A (en) Method, apparatus and computer program product for managing data storage
CN111143284A (en) Dynamic indexing method and device for file system
US20230273727A1 (en) Dynamic storage for adaptive mapping for data compression on a storage device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 519085 High-tech Zone, Tangjiawan Town, Zhuhai City, Guangdong Province

Applicant after: ACTIONS TECHNOLOGY Co.,Ltd.

Address before: 519085 High-tech Zone, Tangjiawan Town, Zhuhai City, Guangdong Province

Applicant before: ACTIONS (ZHUHAI) TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant