Method and device for determining occupied space of mirror image file, equipment and medium
By obtaining the header information of the Qcow2 image file, determining the basic space amount and data cluster number of a single data cluster, the problem of slow determination of image file size and low accuracy in the prior art is solved, and efficient and accurate space calculation is achieved.
Patent Information
- Application Number
- CN202510538586.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-27
- Publication Date
- 2025-08-19
AI Technical Summary
In the prior art, determining the size of the Qcow2 image file is slower and has low accuracy, especially in the presence of external snapshots.
By obtaining the header information of the target image file, determining the basic space and number of data clusters of a single data cluster, and calculating the space occupied by the target image file, avoiding the long time-consuming reading of the overall image file and the interference of external snapshots.
Improves the efficiency and accuracy of the determination of image file size, avoiding the impact of long-term data reading and external snapshots.
Smart Images

Figure CN120508535A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of virtualization technology, and in particular to a method, apparatus, device, and medium for determining the occupied space of an image file. Background Art
[0002] The QEMUCopy-On-Write version 2 (Qcow2) format is a mainstream virtualization image format used to create and store disk images of virtual machines.
[0003] In the related art, for Qcow2 image files stored in block devices, the image management tool (qemu-img) needs to read the entire Qcow2 image file to obtain the data space usage of the Qcow2 image file. This method is slow and has low accuracy when the Qcow2 image file has external snapshots. Summary of the Invention
[0004] In order to solve the above technical problem or at least partially solve the above technical problem, the present disclosure provides a method, apparatus, device and medium for determining the occupied space of an image file.
[0005] The present disclosure provides a method for determining the occupied space of an image file, including:
[0006] Obtaining header information of a target image file; wherein the format of the target image file is a second-version copy-on-write format;
[0007] Determining a basic amount of space occupied by a single data cluster based on the header information, and determining the number of data clusters occupied by the target image file based on the header information;
[0008] Calculate the target space amount occupied by the target image file according to the basic space amount and the number of data clusters.
[0009] The present disclosure also provides a device for determining the occupied space of an image file, including:
[0010] An acquisition module, configured to acquire header information of a target image file; wherein the format of the target image file is a second-version copy-on-write format;
[0011] a determination module, configured to determine a basic amount of space occupied by a single data cluster based on the header information, and to determine the number of data clusters occupied by the target image file based on the header information;
[0012] The calculation module is used to calculate the target space amount occupied by the target image file according to the basic space amount and the number of data clusters.
[0013] An embodiment of the present disclosure also provides an electronic device, comprising: a processor; a memory for storing instructions executable by the processor; the processor for reading the executable instructions from the memory and executing the instructions to implement the method for determining the occupied space of an image file provided in an embodiment of the present disclosure.
[0014] An embodiment of the present disclosure further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is used to execute the method for determining the occupied space of an image file provided in the embodiment of the present disclosure.
[0015] The technical solution provided by the embodiments of the present disclosure has the following advantages over the prior art: the method for determining the occupied space of an image file provided by the embodiments of the present disclosure includes: obtaining header information of a target image file; wherein the format of the target image file is a second-version copy-on-write format; determining the basic space occupied by a single data cluster based on the header information, and determining the number of data clusters occupied by the data cluster of the target image file based on the header information; and calculating the target space occupied by the target image file based on the basic space amount and the number of data clusters. Using the above technical solution, header information of a target image file in Qcow2 format is obtained, and the basic space occupied by a single data cluster is determined based on the header information, and the number of data clusters occupied by the target image file is determined based on the header information. The target space amount occupied by the target image file is determined based on the basic space amount and the number of data clusters. The target space amount is determined by parsing the header information of the target image file, avoiding the long time required to read the entire target image file, improving the efficiency of determining the target space amount, and avoiding interference of external snapshots in determining the target space amount, thereby improving the accuracy of the target space amount. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0017] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0018] Figure 1 A flowchart of a method for determining the occupied space of an image file provided in an embodiment of the present disclosure;
[0019] Figure 2 A schematic diagram of a process for determining an index item provided in an embodiment of the present disclosure;
[0020] Figure 3 A schematic diagram of the structure of a device for determining the occupied space of an image file provided by an embodiment of the present disclosure;
[0021] Figure 4 A schematic structural diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0022] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features therein can be combined with each other in the absence of conflict.
[0023] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0024] Qcow2 is a disk image format used to create and store virtual machine disk images. It is currently a mainstream virtualization image format. Image management tools can be used to create, convert, and manipulate Qcow2 image files.
[0025] For Qcow2 image files stored in the file system, image management tools can directly read the image size to determine the data space usage of the Qcow2 image file. However, for Qcow2 image files stored in block devices, the data in the Qcow2 image file is divided into blocks, each of which has a default size (for example, 256KB). Each block in the Qcow2 image file is a data cluster. To obtain the size of the Qcow2 image file in the block device, the image management tool must loop through the block device and analyze each data cluster to see if they are occupied. When writing large amounts of data to the Qcow2 image file, the calculation is slow. Furthermore, when data in the Qcow2 image file is encrypted, it must first be decrypted, further slowing the calculation, ranging from several seconds to several minutes. Furthermore, when the Qcow2 image file has external snapshots, the image management tool must calculate the sizes of all external snapshots and output the cumulative size of the external snapshots and the Qcow2 image file size. This result is not the actual Qcow2 image file size. It can be seen that how to quickly and accurately obtain the size of the Qcow2 image file has become a technical problem that needs to be solved urgently.
[0026] In order to solve the above problem, an embodiment of the present disclosure provides a method for determining the occupied space of an image file, which is described below in conjunction with specific embodiments.
[0027] Figure 1 This is a flow chart of a method for determining the occupied space of an image file provided by an embodiment of the present disclosure. The method for determining the occupied space of an image file can be applied to a device for determining the occupied space of an image file. The device for determining the occupied space of an image file can be implemented using software and / or hardware, and the device for determining the occupied space of an image file can generally be integrated into an electronic device. Figure 1 As shown, the method for determining the occupied space of the image file includes:
[0028] Step 101: Obtain header information of a target image file; wherein the format of the target image file is a second-version copy-on-write format.
[0029] The target image file may be an image file whose occupied data space size is to be determined, and the target image file may be an image file stored in a block device and in a Qcow2 format. The header information may be information located at the header of the target image file, and the header information may be used to define global properties, storage structure, etc. of the image file.
[0030] In the embodiment of the present disclosure, the device for determining the occupied space of an image file may obtain a target image file and read data stored in a first data cluster of the target image file to obtain header information of the target image file.
[0031] Step 102: Determine the basic space occupied by a single data cluster based on the header information, and determine the number of data clusters occupied by the target image file based on the header information.
[0032] A data cluster can be the physical storage unit of the target image file in a block device. The base space can represent the data space occupied by a single data cluster, that is, the size of a single data cluster. The target image file can be understood as being distributed across data clusters, with each data cluster storing a portion of the target image file. The number of data clusters can be the number of data clusters storing the target image file within the multiple data clusters.
[0033] In the disclosed embodiment, the apparatus for determining the occupied space of an image file can parse the header information and determine the basic amount of space occupied by a single data cluster storing a portion of the target image file based on the data recorded in the header information. Furthermore, the apparatus can determine the number of data clusters occupied by the target image file based on the data recorded in the header information.
[0034] In some embodiments of the present disclosure, the basic amount of space occupied by a single data cluster is determined based on the header information, including: extracting data from the data cluster space amount (Cluster bits) field in the header information to obtain a first left shift value; and determining the basic space amount (Cluster size) based on the first left shift value and a preset basic value.
[0035] The data cluster space amount field may be a field in the header information that records the size of the data space occupied by a data cluster. Optionally, the data cluster space amount field may represent the number of bits occupied by a data cluster, and the data cluster space amount field may be bytes 20-23 of the header information. The first left shift value may be the data recorded in the data cluster space amount field. The preset base value may be a value on which the left shift calculation is performed, and the preset base value may be 1.
[0036] In this embodiment, the image file occupied space determination device can read the data in the data cluster space amount field in the header information to obtain a first left shift value, and then shift a preset base value leftward by the first left shift value in bits to obtain the base space amount in bits. In the above solution, the data space occupied by a single data cluster is determined based on the header information.
[0037] In some embodiments of the present disclosure, the number of data clusters occupied by the target image file is determined based on the header information, including: determining multiple index items in the index table corresponding to the target image file based on the header information; and counting the number of non-zero items in the index items to obtain the number of data clusters.
[0038] The index table can be used to record the occupancy of data clusters by the target image file. In the Qcow2 format, the index table is divided into multiple index items, that is, an index table can include multiple index items. The index items can be used to record the starting addresses of data clusters used by the target image file. It can be understood that each data cluster corresponds to a starting address, and the index item can record the value of the starting address. If the value of the index item is 0, it means that the data cluster is not used by the target image file; if the value of the index item is non-zero, it means that the starting address of the corresponding data cluster is recorded in the index item, and the data cluster is used by the target image file. The number of data clusters can be the number of data clusters currently used by the target image file.
[0039] In this embodiment, the device for determining the occupied space of an image file can parse the fields related to the index table in the header information, as well as the fields related to the index items. Based on the parsed data, the device determines the index table corresponding to the target image file and the index items in the index table. Furthermore, the device traverses the index items in the index table and counts the number of non-zero index item values to obtain the number of data clusters. Thus, the number of data clusters occupied by the target image file can be quickly and accurately determined based on the header information.
[0040] Figure 2 A schematic diagram of a process for determining an index item provided in an embodiment of the present disclosure is shown in FIG. Figure 2 In some embodiments of the present disclosure, determining multiple index items in the index table corresponding to the target image file based on the header information includes:
[0041] Step 201: Determine the index table location, index table space size, and index item space size in the header information based on a preset field data relationship.
[0042] The field data relationship can be used to record the relationship between a field in the header information and the data recorded in the field. The index table location can be the storage location of the index table, which can be understood as the index table offset. The index table space quantity can be the size of the data space occupied by the index table, that is, the size of the index table. The index item space quantity can be the size of the data space occupied by an index item, that is, the size of the index item. Specifically, the index item space quantity can represent the number of bytes occupied by the index item that records the address of a data cluster.
[0043] In this embodiment, the device for determining the occupied space of the image file can extract data from the fields related to the index table in the header information according to the pre-set field data relationship, and extract data from the fields related to the index items in the header information, and determine the index table position, index table space amount, and index item space amount based on the above two types of data.
[0044] In some embodiments of the present disclosure, the index table position, index table space amount, and index item space amount in the header information are determined based on the pre-set field data relationship, including: determining the index table position based on the data of the index table position (Refcount tableoffset) field in the header information; determining the index table space amount based on the data of the index table space amount (Refcount tableclusters) field in the header information; determining the index item space amount based on the data of the index item space amount (Refcount order) field in the header information.
[0045] The index table location field may be a field in the header information used to record the index table location. The index table location field may be bytes 48-55 of the header information. The index table space quantity field may be a field in the header information used to record the number of data clusters occupied by the index table. The index table space quantity field may be bytes 56-59 of the header information. The index item space quantity field may be a field in the header information used to record the data space occupied by an index item. Specifically, the index item space quantity field may record the number of bytes occupied by an index item. The data cluster space quantity field may be bytes 96-99 of the header information.
[0046] In this embodiment, the image file occupied space determination device can read data from the index table location field in the header information to obtain the index table location; read data from the index table space quantity field in the header information to obtain the index table space quantity; and read data from the index item space quantity field in the header information to determine the index item space quantity based on this data. In this solution, the index table location, index table space quantity, and index item space quantity are efficiently and accurately determined based on the header information.
[0047] In some embodiments of the present disclosure, the index item space amount is determined based on the data of the index item space amount field in the header information, including: extracting the data of the index item space amount field in the header information to obtain a second left shift value; and determining the index item space amount based on the second left shift value and a preset base value.
[0048] The second left shift value may be the content recorded in the index item space amount field.
[0049] In this embodiment, the image file space usage determination device can read the data in the index item space amount field in the header information to obtain the second left shift value, and then shift the preset base value leftward by the first left shift value in bytes to obtain the index item space amount in bytes. In this solution, the data space required to index a data cluster is efficiently and accurately determined based on the header information.
[0050] Step 202: Determine the index table according to the index table position and the index table space amount, and determine multiple index items in the index table according to the index table and the index item space amount.
[0051] In this embodiment, the occupied space of the image file can be determined by locating the address of the index table according to the index table position, and determining the data range of the index table according to the space of the index table to obtain a data table. Furthermore, the index table is divided according to the amount of index item space to determine multiple index items in the index table.
[0052] In the above scheme, the data related to the index table and index items in the header information are extracted based on the field data relationship, and the index table and index items are determined based on this data, which realizes the fast reading and accurate determination of the index items and improves the accuracy of the subsequent determination of the number of data clusters.
[0053] Step 103: Calculate the target space occupied by the target image file according to the basic space amount and the number of data clusters.
[0054] The target space amount may represent the size of the data space occupied by the target image file.
[0055] In the embodiment of the present disclosure, after determining the basic space amount and the number of data clusters, the device for determining the occupied space of the image file may determine the target space amount according to the basic space amount and the number of data clusters.
[0056] In some embodiments of the present disclosure, calculating the target space amount occupied by the target image file according to the basic space amount and the number of data clusters includes: calculating the product of the basic space amount and the number of data clusters to obtain the target space amount.
[0057] In this embodiment, the image file occupied space determination device can multiply the basic space amount and the number of data clusters to obtain the target space amount. Thus, by accumulating the space amount of the target image file occupied by the data clusters, the data space occupied by the target image file is determined.
[0058] The method for determining the occupied space of an image file provided by the embodiment of the present disclosure includes: obtaining header information of a target image file; wherein the format of the target image file is a second-version copy-on-write format; determining the basic space amount occupied by a single data cluster based on the header information, and determining the number of data clusters occupied by the data cluster of the target image file based on the header information; and calculating the target space amount occupied by the target image file based on the basic space amount and the number of data clusters. Using the above technical solution, the header information of the target image file in Qcow2 format is obtained, the basic space amount occupied by a single data cluster is determined based on the header information, and the number of data clusters occupied by the target image file is determined based on the header information. The target space amount occupied by the target image file is determined based on the basic space amount and the number of data clusters. The target space amount is determined by parsing the header information of the target image file, avoiding the long time spent reading the entire target image file, improving the efficiency of determining the target space amount, and avoiding the interference of external snapshots in determining the target space amount, thereby improving the accuracy of the target space amount.
[0059] Next, the method for determining the occupied space of an image file in the embodiment of the present disclosure is further described through a specific example.
[0060] In the header, bytes 0-3 are the magic number field, which can be used to verify the file format. Bytes 4-7 are the version field, bytes 20-23 are the data cluster space field, bytes 48-55 are the index table location field, bytes 56-59 are the index table space field, and bytes 96-99 are the index entry space field.
[0061] First, the image file occupied space determination device can read and parse the header information of the target image file in Qcow2 format, obtain the data of the data cluster space amount field, obtain the first left shift value, and determine the basic space amount representing the data cluster size according to the first left shift value.
[0062] Furthermore, the device for determining the occupied space of the image file can determine the index table position and the index table space amount according to the header information, and then calculate the capacity of the index table according to the index table position and the index table space amount.
[0063] Furthermore, the image file occupied space determination device can determine the index item space amount based on the header information, and determine multiple index items in the index table based on the index table and the index item space amount, wherein the value in the index item is the address of the data cluster in use. Each data cluster has a starting address, and the index item records the value of the starting address. If the value is 0, it indicates that the data cluster is not in use. If the value is non-zero, it indicates that the corresponding starting address exists for the data cluster and the data cluster is in use.
[0064] Furthermore, the entire index table is traversed according to the index item space amount, the number of index items with non-zero values is counted to obtain the number of data clusters, and the target space amount of the target image file is calculated based on the number of data clusters and the basic space amount.
[0065] The method for determining the occupied space of an image file provided by the embodiments of the present disclosure focuses on the header information of the target image file in Qcow2 format and the data clusters of the target image file, and quickly and accurately calculates the data usage of the target image file stored on the block device, that is, the size of the target image file. This method avoids reading all the data of the target image file in sequence when the target image file has a large data volume, and avoids decrypting the target image file before reading the target image file when the target image file is encrypted, thereby improving the efficiency of determining the size of the target image file. In addition, the influence of external snapshots on the calculation of the target image file size is avoided, thereby improving the accuracy of the target space amount.
[0066] Figure 3 This is a schematic diagram of a structure of a device for determining the occupied space of an image file provided by an embodiment of the present disclosure. The device can be implemented by software and / or hardware, and the device can also be integrated into an electronic device. Figure 3 As shown, the device for determining the occupied space of the image file includes:
[0067] The acquisition module 301 is used to obtain header information of the target image file; wherein the format of the target image file is the second version copy-on-write format;
[0068] A determination module 302 is configured to determine a basic amount of space occupied by a single data cluster based on the header information, and to determine the number of data clusters occupied by the target image file based on the header information;
[0069] The calculation module 303 is configured to calculate the target space amount occupied by the target image file according to the basic space amount and the number of data clusters.
[0070] Optionally, determining a basic amount of space occupied by a single data cluster according to the header information includes:
[0071] Extracting data of the data cluster space amount field in the header information to obtain a first left shift value;
[0072] The basic space amount is determined according to the first left shift value and a preset basic value.
[0073] Optionally, determining the number of data clusters of the data clusters occupied by the target image file according to the header information includes:
[0074] Determine, according to the header information, a plurality of index items in the index table corresponding to the target image file;
[0075] The number of non-zero items in the index items is counted to obtain the number of data clusters.
[0076] Optionally, determining a plurality of index items in an index table corresponding to the target image file according to the header information includes:
[0077] Determine the index table location, index table space amount, and index item space amount in the header information according to a preset field data relationship;
[0078] The index table is determined according to the index table position and the index table space amount, and the multiple index items in the index table are determined according to the index table and the index item space amount.
[0079] Optionally, determining the index table position, index table space amount, and index item space amount in the header information according to a preset field data relationship includes:
[0080] The index table position is determined according to the data of the index table position field in the header information; the index table space amount is determined according to the data of the index table space amount field in the header information; and the index item space amount is determined according to the data of the index item space amount field in the header information.
[0081] Optionally, determining the index item space amount according to data in the index item space amount field in the header information includes:
[0082] Extracting data of the index item space amount field in the header information to obtain a second left shift value;
[0083] The index item space amount is determined according to the second left shift value and a preset base value.
[0084] Optionally, the calculation module 303 is used to:
[0085] The target space amount is obtained by multiplying the basic space amount by the number of data clusters.
[0086] It should be noted that Figure 3 The illustrated apparatus for determining the occupied space of an image file can execute the various steps in the above-mentioned method embodiment for determining the occupied space of an image file, and realize the various processes and effects in the above-mentioned method embodiment for determining the occupied space of an image file, which will not be described in detail here.
[0087] Figure 4 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 4 As shown, the electronic device 400 includes one or more processors 401 and a memory 402 .
[0088] The processor 401 may be a central processing unit (CPU) or other forms of processing units having the capability of determining the footprint of an image file and / or the capability of executing instructions, and may control other components in the electronic device 400 to perform desired functions.
[0089] The memory 402 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may, for example, include random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may, for example, include read-only memory (ROM), a hard disk, a flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 401 may run the program instructions to implement the method for determining the occupied space of the image file of the embodiment of the present disclosure described above and / or other desired functions. Various contents such as input signals, signal components, noise components, etc. may also be stored in the computer-readable storage medium.
[0090] In one example, the electronic device 400 may further include an input device 403 and an output device 404 , and these components are interconnected via a bus system and / or other forms of connection mechanisms (not shown).
[0091] In addition, the input device 403 may also include, for example, a keyboard, a mouse, and the like.
[0092] The output device 404 can output various information to the outside, including determined distance information, direction information, etc. The output device 404 can include, for example, a display, a speaker, a printer, a communication network and its connected remote output device, etc.
[0093] Of course, to simplify, Figure 4Only some of the components related to the present disclosure in the electronic device 400 are shown, and components such as buses, input / output interfaces, etc. are omitted. In addition, the electronic device 400 may further include any other appropriate components according to specific application scenarios.
[0094] In addition to the above methods and devices, the embodiments of the present disclosure may also be a computer program product, which includes computer program instructions. When the computer program instructions are executed by a processor, the processor executes the method for determining the occupied space of the image file provided by the embodiments of the present disclosure.
[0095] The computer program product may be written in any combination of one or more programming languages to implement the operations of the disclosed embodiments, including object-oriented programming languages such as Java, C++, and conventional procedural programming languages such as C or similar programming languages. The program code may be executed entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0096] In addition, the embodiment of the present disclosure may also be a computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are executed by a processor, the processor executes the method for determining the occupied space of an image file provided by the embodiment of the present disclosure.
[0097] The computer-readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can, for example, include but is not limited to a system, device or component of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0098] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0099] The foregoing description is intended only to provide specific embodiments of the present disclosure, intended to enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the embodiments described herein, but rather to be construed in the broadest manner consistent with the principles and novel features disclosed herein.
Claims
1. A method for determining the occupied space of an image file, characterized in that: include: Obtaining header information of a target image file; wherein the format of the target image file is a second-version copy-on-write format; Determining a basic amount of space occupied by a single data cluster based on the header information, and determining the number of data clusters occupied by the target image file based on the header information; Calculate the target space amount occupied by the target image file according to the basic space amount and the number of data clusters.
2. The method according to claim 1, characterized in that Determining the basic amount of space occupied by a single data cluster according to the header information includes: Extracting data of the data cluster space amount field in the header information to obtain a first left shift value; The basic space amount is determined according to the first left shift value and a preset basic value.
3. The method according to claim 1, characterized in that The step of determining the number of data clusters occupied by the target image file according to the header information includes: Determine, according to the header information, a plurality of index items in the index table corresponding to the target image file; The number of non-zero items in the index items is counted to obtain the number of data clusters.
4. The method according to claim 3, characterized in that The determining, according to the header information, a plurality of index items in the index table corresponding to the target image file includes: Determine the index table location, index table space amount, and index item space amount in the header information according to a preset field data relationship; The index table is determined according to the index table position and the index table space amount, and the multiple index items in the index table are determined according to the index table and the index item space amount.
5. The method according to claim 4, characterized in that The step of determining the index table position, index table space amount, and index item space amount in the header information based on the preset field data relationship includes: The index table position is determined according to the data of the index table position field in the header information; the index table space amount is determined according to the data of the index table space amount field in the header information; and the index item space amount is determined according to the data of the index item space amount field in the header information.
6. The method according to claim 5, characterized in that The determining the index item space amount according to data in the index item space amount field in the header information includes: Extracting data of the index item space amount field in the header information to obtain a second left shift value; The index item space amount is determined according to the second left shift value and a preset base value.
7. The method according to claim 1, characterized in that The calculating the target space amount occupied by the target image file according to the basic space amount and the number of data clusters includes: The target space amount is obtained by multiplying the basic space amount by the number of data clusters.
8. A device for determining the occupied space of an image file, characterized in that: include: An acquisition module, configured to acquire header information of a target image file; wherein the format of the target image file is a second-version copy-on-write format; a determination module, configured to determine a basic amount of space occupied by a single data cluster based on the header information, and to determine the number of data clusters occupied by the target image file based on the header information; The calculation module is used to calculate the target space amount occupied by the target image file according to the basic space amount and the number of data clusters.
9. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is configured to read the executable instructions from the memory and execute the instructions to implement the method for determining the occupied space of the image file according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The storage medium stores a computer program, and the computer program is used to execute the method for determining the occupied space of an image file according to any one of claims 1 to 7.