Sparse mirror image file analysis method and system, electronic equipment and medium

By analyzing the header data and cache tables of sparse mirror files, the problem that sparse mirror file parsing in the existing technology is difficult to ensure data reading accuracy, and high accuracy and completeness of data recovery and analysis are achieved.

CN118916335APending Publication Date: 2024-11-08SHANGHAI HONGLIAN NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411201258.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-29
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

The lack of effective analysis methods for sparse mirror files in the prior art, making it difficult to ensure the accuracy and completeness of data reading, and data omissions or errors are prone to occur.

Method used

By obtaining the header data of the sparse mirror file, judging its legitimacy and parsing the header information, obtaining the mirror offset stored in the cache table, parsing the cache table fields to read the actual data blocks, ensuring the accuracy of data recovery and analysis.

Benefits of technology

Improve the accuracy and completeness of data recovery and analysis, avoid data omissions or errors caused by blank data blocks, and ensure accurate parsing of sparse mirror files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916335A_ABST
    Figure CN118916335A_ABST
Patent Text Reader

Abstract

The invention provides a sparse mirror image file analysis method and system, electronic equipment and a medium, and the method comprises the steps: obtaining the head data of a sparse mirror image file according to the sparse mirror image file, so as to judge whether the sparse mirror image file is read legally, if the reading fails, closing the sparse mirror image file, and if the reading fails, closing the sparse mirror image file; if reading succeeds, analyzing the head data; judging whether the header data comprises header information or not according to an analysis result of the header data, and if yes, reading the header information; acquiring mirror image offset of the sparse mirror image file according to the head information, and storing the mirror image offset into a cache table; and analyzing the field of the cache table and reading the actual data block of the sparse mirror image file. According to the sparse mirror image file analysis method, the accuracy and integrity of data recovery and analysis can be improved, and data omission or errors are avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology and relates to a sparse image file parsing method, and in particular to a sparse image file parsing method, system, electronic device and medium. Background Art

[0002] Sparse image files are a storage technology that allows the creation of a file that does not occupy disk space at the beginning and allocates space only when data is written. This type of file is often used in virtualization technology, such as creating virtual hard disk images. When a virtual machine writes data to an image file, only the data that is actually written will occupy disk space, and the unwritten part remains sparse. Sparse image files are often used to create virtual disks, backup and store large amounts of data while saving disk space. However, there is currently a lack of parsing methods for sparse image files, making it difficult to ensure accurate data reading. Summary of the invention

[0003] The purpose of the present application is to provide a sparse image file parsing method, system, electronic device and medium, which are used to solve the problem that there is a lack of a parsing method for sparse image files in the prior art, and it is difficult to ensure accurate data reading.

[0004] In a first aspect, the present application provides a sparse image file parsing method, the sparse image file parsing method comprising: obtaining header data of the sparse image file according to the sparse image file to determine whether the sparse image file is legally read, if the reading fails, closing the sparse image file, if the reading is successful, parsing the header data; judging whether the header data includes header information according to the parsed result of the header data, if so, reading the header information; obtaining the image offset of the sparse image file according to the header information and storing it in a cache table; parsing the fields of the cache table and reading the actual data blocks of the sparse image file.

[0005] In the present application, the header data of the sparse image file is obtained, and it is determined whether it is legally read. If the reading is successful, the header data is parsed to determine whether the header information is included according to the parsing result of the header data. If the header information is included, the mirror offset of the sparse image file is obtained according to the header information and stored in a cache table, and the fields of the cache table are parsed and the actual data blocks of the sparse image file are read. The sparse image file parsing method can improve the accuracy and integrity of data recovery and analysis, and avoid data omissions or errors caused by blank data blocks.

[0006] In an implementation of the first aspect, parsing the header data includes: parsing the header information using a function to obtain parameters and a basic structure of the header data, wherein the parameters of the header data include the number of sectors and the size of a band.

[0007] In an implementation of the first aspect, judging whether the header data includes header information according to the parsing result of the header data includes: judging whether the header data includes the header information according to the parsing result of the header data; when the header data includes the header information, reading the header information and detecting whether the header data is valid; judging whether the header data is valid according to the detection result of the header data, and if so, confirming that the header data includes the header information.

[0008] In an implementation of the first aspect, obtaining the mirror offset of the sparse mirror file according to the header information and storing it in a cache table includes: parsing according to the header information to obtain data corresponding to the header information; using the data corresponding to the header information to perform analysis and processing to obtain the field and mirror offset of the sparse mirror file, and storing the field and the mirror offset in the cache table.

[0009] In an implementation of the first aspect, parsing the fields of the cache table and reading the actual data blocks of the sparse image file includes: using a function to parse the various fields of the cache table according to a preset data structure; and reading the actual data blocks of the sparse image file containing actual data according to the various fields of the cache table.

[0010] In an implementation of the first aspect, the sparse image file parsing method further includes: acquiring mapping information of the sparse image file according to the image offset of the cache table; and reading data at a specified position of the sparse image file using the mapping information.

[0011] In an implementation of the first aspect, the sparse image file parsing method further includes: judging whether the header data includes next header information according to the parsing result of the header data, and if not, closing the sparse image file; if so, reading the next header information to parse the sparse image file.

[0012] In a second aspect, the present application provides a sparse image file parsing system, the sparse image file parsing system comprising: a file header parsing module, used to obtain header data of the sparse image file according to the sparse image file to determine whether the image file is legally read, if the reading fails, the sparse image file is closed, if the reading is successful, the header data is parsed; a header information reading module, used to determine whether the header data includes header information according to the parsing result of the header data, if so, read the header information; a mirror offset acquisition module, used to obtain the mirror offset of the sparse image file according to the header information and store it in a cache table; an actual data acquisition module, used to parse the fields of the cache table and read the actual data blocks of the sparse image file.

[0013] In a third aspect, the present application provides an electronic device, comprising: a memory for storing a computer program; and a processor for executing the computer program stored in the memory, so that the electronic device performs the sparse image file parsing method as described in any one of the first aspects.

[0014] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the sparse image file parsing method described in any one of the first aspects. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1A Shown is a schematic diagram of an application scenario of the sparse image file parsing method described in this application.

[0016] Figure 1B Shown are structural diagrams of the client-cloud interaction scenarios in these implementations.

[0017] Figure 2 Shown is a flow chart of the sparse image file parsing method described in an embodiment of the present application.

[0018] Figure 3 Shown is a flow chart of the sparse image file parsing method described in an embodiment of the present application.

[0019] Figure 4 Shown is a flow chart of the sparse image file parsing method described in an embodiment of the present application.

[0020] Figure 5 Shown is a flow chart of the sparse image file parsing method described in an embodiment of the present application.

[0021] Figure 6 Shown is a flow chart of the sparse image file parsing method described in an embodiment of the present application.

[0022] Figure 7 Shown is a schematic diagram of a sparse image file parsing method described in an embodiment of the present application.

[0023] Figure 8 Shown is a structural schematic diagram of the sparse image file parsing system described in an embodiment of the present application.

[0024] Fig. 9 Shown is a schematic diagram of the structure of an electronic device described in an embodiment of the present application.

[0025] Component number description

[0026] 1 Sparse image file parsing device

[0027] 11 File storage

[0028] 12 Local Processor

[0029] 13 Data storage

[0030] 2-end-cloud interactive system

[0031] 20 Terminal

[0032] 21 Cloud Server

[0033] 100 Sparse Image File Parsing System

[0034] 110 File header parsing module

[0035] 120 Header information reading module

[0036] 130 Mirror offset acquisition module

[0037] 140 Actual data acquisition module

[0038] 900 Electronic equipment

[0039] 910 Memory

[0040] 920 processor

[0041] 930 Display

[0042] Steps S11 to S14

[0043] Steps S121 to S123

[0044] Steps S131 to S132

[0045] Steps S141 to S144 DETAILED DESCRIPTION

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

[0047] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present application, and thus the drawings only show components related to the present application rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed at will, and the component layout may also be more complicated.

[0048] In order to clearly describe the technical solution of the embodiment of the present application, the terms involved in the present application are first defined:

[0049] Sparse Image File: is a disk image file format under MacOS system. It is a special disk image file that allows dynamic growth when used, which means that it only takes up the space required for actual storage instead of pre-allocating the entire space. This file format is often used to create virtual disks, backup and store large amounts of data while saving disk space.

[0050] Hdiutil tool: A command line tool in MacOS system for operating disk image files (DiskImage). It provides the functions of creating, mounting, unmounting, converting, compressing and verifying disk image files. Disk image files usually exist in .dmg, .img or .iso formats and are often used for software distribution and backup.

[0051] Header data: The header data of a sparse image file contains important information that describes the entire image file. This includes file identification information, size and capacity information, data structure information, metadata and mapping information, checksum and integrity information. The size and capacity information includes the total size and block size. The total size is used to express the logical size of the entire sparse image file. The block size is used to express the size of the allocated and managed data blocks, which is generally the basic unit of the file system. The data structure information includes the stripe size and the number of sectors. The sparse image file is divided into several stripes, and the size of each stripe is fixed, which helps the file system manage the allocation and recovery of disk space. The number of sectors is the total number of sectors contained in the entire image file, which is used to locate the position of the data block.

[0052] Image offset: is the location where the data in the disk image file starts. Since sparse image files only occupy actual data blocks and may have some internal management structures, the image offset usually refers to the offset from the beginning of the file to the starting location where the data is actually stored. This offset can be used to calculate the actual location of the data in the image file, thereby efficiently reading or writing data.

[0053] Cache table: The cache table is an internal data structure in the sparse image file that is used to track which parts of the image file are actually present and which parts are unallocated. It records the "sparse" state of the file, that is, which data blocks are allocated and which data blocks are empty.

[0054] Sparse image files usually refer to a disk image file format under the MacOS system. It is a special disk image file that allows dynamic growth when used, which means that it only takes up the space required for actual storage instead of pre-allocating the entire space. As users add data to the image, its size increases, taking up only as much disk space as the data is stored in it. The FileVault feature in the MacOS system version uses encrypted sparse image files to protect the user's home directory. Unlike full image files, which take up as much actual space as the actual disk space they represent, sparse image files only take up as much actual disk space as the actual disk space they represent. The data contained in it is up to the maximum capacity allocated during creation. In the field of digital forensics, computers are usually imaged for extraction. In order to quickly extract a large number of disks, hdiutil is generally used to extract the computer using a sparse image. Processing sparse image files afterwards is a critical task. Due to the requirements for product security, there is no official open file format documentation about this sparse image file, and it is necessary to study the image and make inferences. In the process of digital forensic analysis, sparse image files are usually required to be fully and accurately analyzed. Therefore, accurate and fast parsing of sparse image files is crucial.

[0055] At least for the above-mentioned problem, an embodiment of the present application provides a sparse image file parsing method, the sparse image file parsing method comprising: obtaining header data of the sparse image file according to the sparse image file to determine whether the sparse image file is legally read, if the reading fails, closing the sparse image file, if the reading is successful, parsing the header data; judging whether the header data includes header information according to the parsed result of the header data, if so, reading the header information; obtaining the image offset of the sparse image file according to the header information and storing it in a cache table; parsing the fields of the cache table and reading the actual data blocks of the sparse image file.

[0056] In the embodiment of the present application, the header data of the sparse image file is obtained, and it is determined whether it is legally read. If the reading is successful, the header data is parsed to determine whether the header information is included according to the parsing result of the header data. If the header information is included, the mirror offset of the sparse image file is obtained according to the header information and stored in a cache table, and the fields of the cache table are parsed and the actual data blocks of the sparse image file are read. The sparse image file parsing method can improve the accuracy and integrity of data recovery and analysis, and avoid data omissions or errors caused by blank data blocks.

[0057] Figure 1A The diagram shows an application scenario of the sparse image file parsing method described in the present application. The sparse image file parsing device 1 can be used to implement the sparse image file parsing method provided in the embodiment of the present application, but the application scenario of the sparse image file parsing method provided in the embodiment of the present application is not limited to Figure 1A The sparse image file parsing device 1 shown. Figure 1A As shown, the sparse image file parsing device 1 includes a file storage 11, a local processor 12 and a data storage 13. The sparse image file parsing method provided in the embodiment of the present application can be applied to the local processor 12.

[0058] in, Figure 1A The local processor 12 in the embodiment may be a local processor or a local processor cluster composed of multiple local processors or a cloud computing center, etc., which is not limited to the specifics herein. Figure 1A Only one file storage 11, one local processor 12 and one data storage 13 are shown, but it should be understood that Figure 1A The examples are only used to understand the present solution, and the specific numbers of local processors 12 and data storage devices 13 should be flexibly determined based on actual conditions.

[0059] In some other implementations, the sparse image file parsing device 1 may not include the data storage device 13, but only include a local processor 12 with a storage function and a file storage device 11. The sparse image file parsing method provided in the embodiment of the present application can be applied to the local processor 12. The local processor 12 with a storage function may include a tablet computer, a laptop computer, a PDA, a mobile phone, a personal computer (PC for short), and a voice interaction device, etc., which are not limited here.

[0060] In still other implementations, the sparse image file parsing method described in this application may be applied to a terminal-cloud interaction scenario. Figure 1B The following is a schematic diagram of the structure of the client-cloud interaction scenario in these implementations. Figure 1BAs shown, the terminal-cloud interaction system 2 includes a terminal 20 and a cloud server 21. The terminal 20 and the cloud server 21 can communicate with each other, and the communication method is not limited to wired or wireless.

[0061] Among them, the terminal 20 can be mobile or fixed, for example, the terminal 20 can be a wireless terminal or a wired terminal. The wireless terminal can refer to a device with wireless transceiver function, which can be deployed indoors, outdoors and in a workroom. The terminal 20 can be a mobile phone, a tablet computer, a laptop computer, etc., which is not limited here. The cloud server 21 can include one or more servers, or one or more processing nodes, or one or more virtual machines running on the server. The cloud server 21 can also be called a server cluster, a management platform, a data processing center, etc., which is not limited in the embodiments of the present application.

[0062] The technical solutions in the embodiments of the present application will be described in detail below in conjunction with the drawings in the embodiments of the present application.

[0063] The following embodiments of the present application provide a sparse image file parsing method. For example, the method can be Figure 1A The local processor 12 shown or Figure 1B It is implemented by the cloud server 21 shown. Figure 2 The flowchart of the sparse image file parsing method described in the embodiment of the present application is shown as follows: Figure 2 As shown, the sparse image file parsing method includes steps S11 to S14.

[0064] Step S11, obtaining header data of the sparse image file according to the sparse image file to determine whether the sparse image file is legally read, if the reading fails, closing the sparse image file, if the reading is successful, parsing the header data.

[0065] The sparse image file is a disk image file used on the MacOS system, including actual data blocks with valid data and blank data blocks with only blanks. In some possible implementations, the Dmg image is also a format of a disk image file. The disk image file is essentially a raw disk image, containing complete raw data blocks, and adding some metadata, and one or two layers can be selected to provide compression and encryption. In the command line tool hdiutil, CUDIFEncoding and CEncryptedEncoding are encoding types related to disk image files of the MacOS system. The CUDIFEncoding encoding type indicates that the disk image file has been compressed to reduce its storage size. Using this encoding type can reduce the file size while maintaining the integrity of the original data. The CEncryptedEncoding encoding type is to ensure that the content of the disk image file is encrypted, and the data therein can only be accessed by providing the correct password. Using this encoding type can protect sensitive data and prevent unauthorized access. Sparse images can be regarded as a kind of "compression" of Dmg images. For example, for the compression of some all-zero bytes, assuming that there are consecutive 0000, it is written as 40 in the sparse image file, which means that there are 4 zeros, and storage space is saved by compression.

[0066] In some possible implementations, if the header of the sparse image file starts with "sprs", i.e., 0x73, 0x70, 0x72, 0x73, it means that the sparse image file is legally read; if it does not start with the above bytes, it means that the sparse image file is not legally read.

[0067] Step S12: determining whether the header data includes header information according to the parsing result of the header data, and if so, reading the header information.

[0068] Optionally, in the initial stage, the basic structure of the sparse image file is determined and the parsing process is initialized by reading header information of the sparse image file, wherein the header information includes parameters such as a file signature, a number of sectors, and a band size.

[0069] Step S13, obtaining the image offset of the sparse image file according to the header information and storing it in a cache table.

[0070] The mirror offset refers to the location where the data in the disk image file starts. Since sparse image files only occupy actual data blocks and may have some internal management structures, the "mirror offset" usually refers to the offset from the beginning of the file to the starting location where the data is actually stored. This offset can be used to calculate the actual location of the data in the image file, thereby efficiently reading or writing data.

[0071] The cache table is an internal data structure in a sparse image file that is used to track which parts of the image file actually exist and which parts are unallocated. It records the "sparse" status of the file, that is, which data blocks are allocated and which data blocks are empty. The main functions of the cache table include: Mapping management: Maintaining the mapping relationship between data blocks in the file and physical storage space. Space optimization: Allocating only the space actually needed, thereby saving disk space. Efficiency improvement: Improve the efficiency of read and write operations because the system only needs to pay attention to the data blocks that actually exist. When creating and managing sparse image files, the cache table helps the operating system and tools to efficiently process data in the disk image, and makes the operation of sparse image files more flexible and space-saving.

[0072] Step S14, parsing the fields of the cache table and reading the actual data blocks of the sparse image file.

[0073] The actual data blocks of the sparse image file are opposite to the blank data blocks, and refer to the valid data in the sparse image file.

[0074] In some possible implementations, the header data of the sparse image file is obtained according to the sparse image file, and the header data includes parameters such as file signature, number of sectors and band size. It is judged whether the sparse image file is legally read according to the header data. If the reading fails, the sparse image file is closed. If the reading succeeds, the header data is parsed. For the header of each sparse image file, the header data is parsed according to a predetermined data structure to obtain the parsing result of the header data. It is judged whether the header data includes header information according to the parsing result of the header data. If not, the sparse image file is closed. If so, the header information is read. The image offset of the sparse image file is obtained according to the header information and stored in the cache table. The fields of the cache table are parsed and the actual data blocks of the sparse image file are read.

[0075] In some other possible implementations, a sparse image file of MacOS is obtained, and the header data of the sparse image file is obtained according to the sparse image file, wherein the header data includes parameters such as file signature, number of sectors and band size. If the first 4 bytes of the header data start with "sprs", i.e., 0x73, 0x70, 0x72, 0x73, it means that the sparse image file is legally read. If the read is successful, the header data is parsed. If the read fails, the sparse image file is closed. The sparse image file consists of multiple sprs bytes + data, for example, sprs+data+data+sprs+data…+sprs+data. The header data of the sparse image file is parsed to obtain the parsing result of the header data. According to the parsing result of the header data, it is determined whether the header data includes header information. If not, the sparse image file is closed. If so, the header information is read. The header data of the sparse image file includes header information, such as the beginning of the data and the specific location of the data corresponding to the uncompressed image. If a sparse image file includes multiple sprs header data, each header data has corresponding header information. After parsing a header data, the acquired information needs to be retained, and the image offset of the sparse image file is acquired according to the header information and stored in a cache table. The cache table is used to store the parsed information and then read the data. Optionally, the data storage method is not limited to the form of a cache table, and other data storage methods can also be used. The parsing operation of the sparse image file is completed until the header information included in all the header data of the sparse image file is parsed and stored. Parse the fields of the cache table and obtain the actual data blocks of the sparse image file according to the position information corresponding to the fields of the cache table obtained by parsing.

[0076] In the embodiment of the present application, the header data of the sparse image file is obtained, and it is determined whether it is legally read. If the reading is successful, the header data is parsed to determine whether the header information is included according to the parsing result of the header data. If the header information is included, the mirror offset of the sparse image file is obtained according to the header information and stored in a cache table, and the fields of the cache table are parsed and the actual data blocks of the sparse image file are read. The sparse image file parsing method can improve the accuracy and integrity of data recovery and analysis, and avoid data omissions or errors caused by blank data blocks.

[0077] In one embodiment of the present application, parsing the header data includes: parsing the header information using a function to obtain parameters and a basic structure of the header data, wherein the parameters of the header data include the number of sectors and the size of a stripe. Optionally, the number of sectors is a basic unit of disk storage, typically 512 bytes, and a stripe is a logical storage unit in a sparse image file, including a number of sectors.

[0078] In some possible implementations, the field of digital forensics requires parsing and analyzing sparse image files, the header data of which contains multiple key parameters that help define the structure and management of the image file. The number of sectors and the stripe size have a direct impact on the read and write operations and space management of sparse image files. The number of sectors represents the total number of logical sectors used in the disk image file. Each sector is the basic unit of data on the disk, usually 512 bytes or 4096 bytes. The number of sectors is used to determine the overall size of the disk image and how the data is organized. The number of sectors multiplied by the number of bytes per sector (e.g., 512 bytes) gives the total size of the disk image. In addition, the actual location of the data in the disk image file can be calculated by the number of sectors. The stripe size refers to the size of each "strip" or "block" in the sparse image file. The stripe is an important concept in the sparse image file, which helps manage the data blocks in the image file. The size of the stripe affects the performance and space management of the image file: larger stripes can reduce management overhead because each stripe contains more data blocks. However, too large a stripe size will result in wasted space, because even if only one byte is used, it will occupy the entire stripe space. The size of the stripe affects the efficiency of reading and writing data. An appropriate stripe size can optimize performance and avoid frequent disk access operations.

[0079] Figure 3 The flowchart of the sparse image file parsing method described in the embodiment of the present application is shown as follows: Figure 3 As shown, the step S12 includes steps S121 to S123.

[0080] Step S121: determining whether the header data includes the header information according to the parsing result of the header data.

[0081] Step S122: when the header data includes the header information, read the header information and detect whether the header data is valid.

[0082] Step S123, judging whether the header data is valid according to the detection result of the header data, and if so, confirming that the header data includes the header information.

[0083] In some possible implementations, it is determined whether the header data includes the header information according to the parsing result of the header data, and the header information is the next header byte contained in the header data. If it does not exist, the sparse image file is closed and the parsing process is terminated. If the next header byte exists, the header information is read and the header data is detected to be valid. It is determined whether the header data is valid according to the detection result of the header data, and if not, the sparse image file is closed and the parsing process is terminated. If it is valid, the table parsing and data reading steps are entered.

[0084] In some other possible implementations, the sparse image file is composed of multiple sprs bytes + data, for example, sprs + data + data + sprs + data ... + sprs + data. The header data of the sparse image file is parsed to obtain the parsing result of the header data. According to the parsing result of the header data, it is judged whether the header data includes header information. If not, the sparse image file is closed. If so, the header information is read. The header data of the sparse image file includes header information, such as the beginning of the data and the specific position of the data corresponding to the uncompressed image. If a sparse image file includes multiple sprs header data, each header data has corresponding header information. The header information is the next header byte contained in the header data. If it does not exist, the sparse image file is closed and the parsing process is terminated. If the next header byte exists, the header information is read and the header data is detected whether it is valid. According to the detection result of the header data, it is judged whether the header data is valid. If not, the sparse image file is closed and the parsing process is terminated. If valid, enter the table parsing and data reading steps. Figure 4 The flowchart of the sparse image file parsing method described in the embodiment of the present application is shown as follows: Figure 4 As shown, the step S13 includes steps S131 to S132.

[0085] Step S131, parsing the header information to obtain data corresponding to the header information.

[0086] Step S132: Analyze and process the data corresponding to the header information to obtain the fields and the image offset of the sparse image file, and store the fields and the image offset in the cache table.

[0087] In some possible implementations, the header information is parsed to obtain data corresponding to the header information. The data corresponding to the header information is used for calculation and analysis to obtain a real mirror offset as the mirror offset of the sparse mirror file. The data corresponding to the header information is parsed using a function according to a preset data structure to obtain a field of the sparse mirror file, and the field and the mirror offset are stored in the cache table.

[0088] Figure 5 The flowchart of the sparse image file parsing method described in the embodiment of the present application is shown as follows: Figure 5 As shown, the step S14 includes steps S141 to S142.

[0089] Step S141, using a function to parse each field of the cache table according to a preset data structure.

[0090] Step S142: reading the actual data blocks containing actual data in the sparse image file according to the fields of the cache table.

[0091] In some possible implementations, a function is used to parse each field of the cache table according to a preset data structure. The actual data blocks of the sparse image file containing actual data are read according to each field of the cache table. Optionally, recording and managing the actual data blocks containing actual data can save storage space and improve the efficiency of data reading.

[0092] In some other possible implementations, the actual data block containing the actual data in the sparse image file is read according to the fields of the cache table to read the decompressed data of a sparse image file, and the decompressed sparse image file is also a complete image in logic. The position of the data in the sparse image file can be determined by calculation using the fields of the cache table obtained by parsing, and the position and length of the data in the sparse image can be restored according to the formula to obtain the actual data block containing the actual data, but the present application is not limited to this.

[0093] Figure 6 The flowchart of the sparse image file parsing method described in the embodiment of the present application is shown as follows: Figure 6 As shown, the step S14 also includes steps S143 to S144.

[0094] Step S143: Acquire mapping information of the sparse image file according to the image offset of the cache table.

[0095] Step S144: using the mapping information to read data at a specified location of the sparse image file.

[0096] In some possible implementations, actual data blocks are read from the sparse image file, and business information of the sparse image file is obtained according to the image offset. The data at a specified position of the sparse image file is accurately read using the mapping information.

[0097] In some other possible implementations, during the parsing process of the sparse image file, in order to ensure the integrity and consistency of the data with the original image, data recovery and reconstruction operations are performed when necessary, but the present application is not limited thereto.

[0098] In one embodiment of the present application, the sparse image file parsing method further includes: judging whether the header data includes the next header information according to the parsing result of the header data; if not, closing the sparse image file; if so, reading the next header information to parse the sparse image file.

[0099] In some possible implementations, Figure 7 The diagram shows a sparse image file parsing method according to an embodiment of the present application. Figure 7 As shown, according to the sparse image file, the header data of the sparse image file is obtained, and the header data includes parameters such as file signature, number of sectors and band size. According to the header data, it is judged whether the sparse image file is legally read. If the reading fails, the sparse image file is closed. If the reading is successful, the header data is parsed. For the header of each sparse image file, the header data is parsed according to a predetermined data structure to obtain the parsing result of the header data. According to the parsing result of the header data, it is judged whether the header data includes header information. If not, the sparse image file is closed. If so, the header information is read. According to the header information, the image offset of the sparse image file is obtained and stored in the cache table. The fields of the cache table are parsed and the actual data blocks of the sparse image file are read. According to the parsing result of the header data, it is cyclically judged whether the header data includes the next header information. If not, the sparse image file is closed and the parsing operation is stopped. If the next header information is included, the next header information is read to obtain the image offset of the sparse image file and store it in the cache table, and the fields of the cache table are parsed and the actual data blocks of the sparse image file are read to fill the image information. The parsing operation is stopped until the header data does not include the next header information, the sparse image file is closed, and related resources are released.

[0100] Figure 8 The structure diagram of the sparse image file parsing system described in the embodiment of the present application is shown as follows: Figure 8As shown, the sparse image file parsing system 100 includes a file header parsing module 110 , a header information reading module 120 , an image offset obtaining module 130 and an actual data obtaining module 140 .

[0101] The file header parsing module 110 is used to obtain the header data of the sparse image file according to the sparse image file to determine whether the image file is legally read. If the reading fails, the sparse image file is closed. If the reading is successful, the header data is parsed.

[0102] The header information reading module 120 is used to determine whether the header data includes header information according to the parsing result of the header data, and if so, read the header information.

[0103] The image offset acquisition module 130 is used to acquire the image offset of the sparse image file according to the header information and store it in a cache table.

[0104] The actual data acquisition module 140 is used to parse the fields of the cache table and read the actual data blocks of the sparse image file.

[0105] In some possible implementations, the file header parsing module 110 is used to obtain the header data of the sparse image file according to the sparse image file, and the header data includes parameters such as file signature, number of sectors and band size. According to the header data, it is judged whether the sparse image file is legally read. If the reading fails, the sparse image file is closed. If the reading is successful, the header data is parsed. The header information reading module 120 is used to parse the header data according to the predetermined data structure for the header of each sparse image file to obtain the parsing result of the header data. According to the parsing result of the header data, it is judged whether the header data includes header information. If not, the sparse image file is closed. If so, the header information is read. The mirror offset acquisition module 130 is used to obtain the mirror offset of the sparse image file according to the header information and store it in the cache table. The actual data acquisition module 140 is used to parse the fields of the cache table and read the actual data blocks of the sparse image file.

[0106] In an embodiment of the present application, the file header parsing module 110 is used to obtain the header data of the sparse mirror file and determine whether it is legal to read. If the read is successful, the header data is parsed. The header information reading module 120 is used to determine whether the header information is included according to the parsing result of the header data, if the header information is included. The mirror offset acquisition module 130 is used to obtain the mirror offset of the sparse mirror file according to the header information and store it in the cache table, and the actual data acquisition module 140 is used to parse the fields of the cache table and read the actual data blocks of the sparse mirror file. The sparse mirror file parsing system 100 can improve the accuracy and completeness of data recovery and analysis, and avoid data omissions or errors caused by blank data blocks.

[0107] In the several embodiments provided in the present application, it should be understood that the disclosed system, device or method can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of modules / units is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or units can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules or units, which can be electrical, mechanical or other forms.

[0108] The modules / units described as separate components may or may not be physically separated, and the components displayed as modules / units may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules / units may be selected according to actual needs to achieve the purpose of the embodiments of the present application. For example, the functional modules / units in the various embodiments of the present application may be integrated into one processing module, or each module / unit may exist physically separately, or two or more modules / units may be integrated into one module / unit.

[0109] Those of ordinary skill in the art should further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0110] An embodiment of the present application also provides an electronic device. Fig. 9 The structure diagram of the electronic device described in the embodiment of the present application is shown. Fig. 9 As shown, in this embodiment, the electronic device 900 includes a memory 910 and a processor 920 .

[0111] The memory 910 is used to store computer programs; preferably, the memory 910 includes: ROM, RAM, disk, USB flash drive, memory card or optical disk, etc., various media that can store program codes.

[0112] Specifically, the memory 910 may include a computer system readable medium in the form of a volatile memory, such as a random access memory (RAM) and / or a cache memory. The electronic device 900 may further include other removable / non-removable, volatile / non-volatile computer system storage media. The memory 910 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present application.

[0113] The processor 920 is connected to the memory 910 and is used to execute the computer program stored in the memory 910 so that the electronic device 900 executes the sparse image file parsing method described in any embodiment of the present application.

[0114] Optionally, the processor 920 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0115] Optionally, the electronic device 900 in this embodiment may further include a display 930. The display 930 is communicatively connected to the memory 910 and the processor 920, and is used to display a graphical user interface (GUI) interaction interface related to the sparse image file parsing method described in the embodiment of the present application.

[0116] The embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the sparse image file parsing method described in any embodiment of the present application is implemented.

[0117] The descriptions of the processes or structures corresponding to the above-mentioned figures have different emphases. For parts that are not described in detail in a certain process or structure, please refer to the relevant descriptions of other processes or structures.

[0118] The above embodiments are merely illustrative of the principles and effects of the present application and are not intended to limit the present application. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed in the present application shall still be covered by the claims of the present application.

Claims

1. A sparse image file parsing method, characterized in that: include: Obtaining header data of the sparse image file according to the sparse image file to determine whether the sparse image file is legally read, if the reading fails, closing the sparse image file, if the reading succeeds, parsing the header data; Determine whether the header data includes header information according to the parsing result of the header data, and if so, read the header information; Obtaining the image offset of the sparse image file according to the header information and storing it in a cache table; The fields of the cache table are parsed and actual data blocks of the sparse image file are read.

2. The sparse image file parsing method according to claim 1, characterized in that: Parsing the header data includes: The header information is parsed using a function to obtain parameters and a basic structure of the header data, wherein the parameters of the header data include the number of sectors and the size of the band.

3. The sparse image file parsing method according to claim 1, characterized in that: Judging whether the header data includes header information according to the parsing result of the header data includes: Determining whether the header data includes the header information according to the parsing result of the header data; When the header data includes the header information, reading the header information and detecting whether the header data is valid; Whether the header data is valid is determined according to the detection result of the header data, and if so, it is confirmed that the header data includes the header information.

4. The sparse image file parsing method according to claim 1, characterized in that: Acquiring the image offset of the sparse image file according to the header information and storing it in the cache table includes: Parsing the header information to obtain data corresponding to the header information; The data corresponding to the header information is analyzed and processed to obtain the fields and the mirror offset of the sparse mirror file, and the fields and the mirror offset are stored in the cache table.

5. The sparse image file parsing method according to claim 1, characterized in that: Parsing the fields of the cache table and reading the actual data blocks of the sparse image file includes: Utilize a function to parse each field of the cache table according to a preset data structure; The actual data blocks containing actual data in the sparse mirror file are read according to the fields of the cache table.

6. The sparse image file parsing method according to claim 5, characterized in that: Also includes: Acquire mapping information of the sparse image file according to the image offset of the cache table; The data at the specified position of the sparse image file is read using the mapping information.

7. The sparse image file parsing method according to claim 1, characterized in that: Also includes: According to the parsing result of the header data, it is determined whether the header data includes the next header information. If not, the sparse image file is closed. If yes, the next header information is read to parse the sparse image file.

8. A sparse image file parsing system, characterized in that: include: A file header parsing module, used for obtaining header data of the sparse image file according to the sparse image file to determine whether the image file is legally read, and if the reading fails, closing the sparse image file, and if the reading succeeds, parsing the header data; A header information reading module, used for judging whether the header data includes header information according to the parsing result of the header data, and if so, reading the header information; An image offset acquisition module, used to acquire the image offset of the sparse image file according to the header information and store it in a cache table; The actual data acquisition module is used to parse the fields of the cache table and read the actual data blocks of the sparse image file.

9. An electronic device, characterized in that: The electronic device comprises: Memory for storing computer programs; A processor, wherein the processor is used to execute the computer program stored in the memory so that the electronic device executes the sparse image file parsing method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the sparse image file parsing method described in any one of claims 1 to 7 is implemented.