Method and device for writing upgrade package image, computer device and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-15
- Publication Date
- 2026-08-11
AI Technical Summary
这种强绑定外部元数据的方式缺少对镜像内容本身的真实性校验,无法在写入前确认镜像的实际格式是否与声明一致
[0014]本发明公开的升级包镜像写入方法、装置、计算机设备及存储介质,对升级包文件进行解析,得到待写入镜像文件和多个镜像条目的目标写入对象;根据所述待写入镜像文件进行镜像内容识别,得到各所述镜像条目分别对应的目标镜像类型;针对各所述镜像条目,根据所述镜像条目的目标镜像类型和所述镜像条目的目标写入对象确定写入路径,根据所述写入路径对所述待写入镜像文件进行镜像写入,得到单次写入存储区域信息和单次写入操作结果;对所述单次写入存储区域信息进行可挂载验证,得到挂载验证结果;根据所述单次写入操作结果和所述挂载验证结果进行镜像写入调整。这样,对升级包文件中的镜像进行内容级识别,而非仅依赖文件名,判定镜像类型,并据此自动匹配正确写入路径,从而避免镜像类型与写入目标不匹配导致的升级后挂载失败;同时,可挂载验证前置拦截不可用镜像,防止系统启动异常,自适应调整写入策略,降低人工干预需求,缩短升级耗时。
Smart Images

Figure CN122547281A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image writing technology, and in particular to an upgrade package image writing method, apparatus, computer device, and storage medium. Background Technology
[0002] Existing over-the-air (OTA) upgrade processes typically rely on field descriptions in the upgrade script and naming conventions for image files to identify the image type and target write location. This method, which strongly binds to external metadata, lacks verification of the image content itself and cannot confirm whether the actual format of the image matches the declaration before writing. If the script is misconfigured or the image file is accidentally replaced, it can easily lead to type misjudgment, partition write errors, or even device bricking, reducing the robustness and security of the upgrade system. Summary of the Invention
[0003] In view of this, the purpose of the present invention is to overcome the shortcomings of the prior art and provide an upgrade package image writing method, apparatus, computer device and storage medium.
[0004] This invention provides the following technical solution: In a first aspect, the present invention provides a method for writing an upgrade package image, the method comprising: The upgrade package file is parsed to obtain the target write objects for the image file to be written and multiple image entries; Based on the image file to be written, the image content is identified to obtain the target image type corresponding to each image entry; For each of the aforementioned image entries, a write path is determined based on the target image type and the target write object of the image entry. The image file to be written is then written according to the write path to obtain single write storage area information and single write operation results. The mountability verification is performed on the single-write storage area information to obtain the mount verification result. The image write adjustment is performed based on the results of the single write operation and the mount verification results.
[0005] In an optional implementation, the step of adjusting the image write based on the write operation result and the mount verification result includes: Based on the result of the single write operation, determine whether it is necessary to automatically switch the write path, and obtain the first determination result; If the first judgment result is not to automatically switch the write path, then the step of parsing the upgrade package file to obtain the image file to be written and the list of changed storage blocks is executed again. Based on the mount verification results, determine whether the image write error is unrecoverable, and obtain a second judgment result; If the second determination result indicates whether the image write error is unrecoverable, then the step of parsing the upgrade package file to obtain the image file to be written and the list of changed storage blocks is re-executed.
[0006] In an optional implementation, the method further includes: After the image content has been written, the target write object of each image entry is mounted and verified to obtain the mount verification result. Obtain the upgrade log file during the image content writing process, and determine whether the writing status of each image entry contains the correct keyword based on the upgrade log file to obtain the keyword verification result; An upgrade result report is generated based on the write operation result, the mount verification result, and the keyword verification result.
[0007] In an optional implementation, before determining the write path based on the target image type and the target write object of the image entry, the following steps are included: Based on the upgrade package file, storage block change information is obtained. Based on the storage block change information, the target write object of each of the image entries is range-checked to obtain the range check result. The target write object of each of the aforementioned mirror entries is corrected based on the range verification results.
[0008] In an optional implementation, obtaining storage block change information based on the upgrade package file includes: Extract the new version number from the upgrade package file; Obtain the old version number, and generate an upgrade version difference table based on the old version number and the new version number; The storage block change information is determined based on the upgrade version difference table.
[0009] In an optional implementation, determining the write path based on the target image type and the target write object of the image entry includes: If the target image type is a container image, the write path is determined based on the partition-level write path and the target write object of each image entry; If the target image type is a file system image, the write path is determined based on the volume-level update path and the target write object of each image entry.
[0010] In an optional implementation, the step of identifying the image content based on the image file to be written, and obtaining the target image type corresponding to each image entry, includes: For each of the aforementioned image entries, the image type identifier of the image entry is obtained based on the image file to be written; The structure of the image file to be written is identified based on the image type identifier to obtain the keyword identification result of the image entry; The matching result is obtained by matching the keyword recognition result with the type of the target writing object; If the matching result is a match, then the image type identifier is used as the target image type of the image entry; If the matching result is a mismatch, then the type of the target object is used as the target image type of the image entry.
[0011] Secondly, the present invention provides an upgrade package image writing device, the device comprising: The parsing module is used to parse the upgrade package file to obtain the target write object of the image file to be written and multiple image entries; The identification module is used to identify the image content based on the image file to be written, and to obtain the target image type corresponding to each image entry. The writing module is used to determine the writing path for each of the image entries based on the target image type and the target writing object of the image entry, and to perform image writing on the image file to be written according to the writing path, so as to obtain single write storage area information and single write operation result. The verification module is used to perform mountability verification on the single-write storage area information and obtain the mountability verification result. The adjustment module is used to adjust the image write based on the result of the single write operation and the mount verification result.
[0012] Thirdly, the present invention provides a computer device including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, it implements the upgrade package image writing method as described in any of the foregoing embodiments.
[0013] Fourthly, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the upgrade package image writing method as described in any of the foregoing embodiments.
[0014] This invention discloses an upgrade package image writing method, apparatus, computer device, and storage medium. The method involves parsing an upgrade package file to obtain an image file to be written and multiple target write objects for image entries; identifying the image content of the image file to be written to obtain the target image type corresponding to each image entry; determining a write path for each image entry based on its target image type and target write object; writing the image file to be written according to the write path to obtain single-write storage area information and a single-write operation result; verifying the mountability of the single-write storage area information to obtain a mount verification result; and adjusting the image writing based on the single-write operation result and the mount verification result. This approach performs content-level identification of the images in the upgrade package file, rather than relying solely on the filename, to determine the image type and automatically match the correct write path, thus avoiding mount failures after the upgrade due to mismatches between the image type and the write target. Simultaneously, the mountability verification intercepts unusable images beforehand, preventing system startup anomalies, adaptively adjusting the write strategy, reducing the need for manual intervention, and shortening the upgrade time. Attached Figure Description
[0015] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope of protection of the present invention. In the various drawings, similar components are numbered similarly.
[0016] Figure 1 A flowchart of the upgrade package image writing method proposed in this embodiment is shown; Figure 2 This illustration shows another flowchart of the upgrade package image writing method proposed in this embodiment; Figure 3 This illustration shows another flowchart of the upgrade package image writing method proposed in this embodiment; Figure 4 This diagram illustrates another process flow of the upgrade package image writing device proposed in this embodiment.
[0017] Explanation of reference numerals in the attached diagram: 400 - Upgrade package image writing device; 401 - Parsing module; 402 - Identification module; 403 - Writing module; 404 - Verification module; 405 - Adjustment module. Detailed Implementation
[0018] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0019] The components of the embodiments of the invention described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0020] In the following, the terms “comprising,” “having,” and their cognates, which may be used in various embodiments of the invention, are intended only to indicate a particular feature, number, step, operation, element, component, or combination thereof, and should not be construed as excluding, firstly, the presence of one or more other features, numbers, steps, operations, elements, components, or combinations thereof, or adding the possibility of one or more features, numbers, steps, operations, elements, components, or combinations thereof.
[0021] Furthermore, the terms "first," "second," and "third" are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.
[0022] Unless otherwise specified, all terms used herein (including technical and scientific terms) shall have the same meaning as commonly understood by one of ordinary skill in the art to which the various embodiments of the invention pertain. Terms (such as those defined in commonly used dictionaries) shall be interpreted as having the same meaning as in their contextual meaning in the relevant technical field and shall not be interpreted as having an idealized or overly formal meaning, unless clearly defined in the various embodiments of the invention.
[0023] Example 1 This disclosure provides a method for writing an upgrade package image.
[0024] Please see Figure 1 The upgrade package image writing method includes steps S101 to S105, and each step is described in detail below.
[0025] Step S101: Parse the upgrade package file to obtain the target write objects for the image file to be written and multiple image entries.
[0026] In this embodiment, by structured parsing of the OTA upgrade package file, the original image file to be written and the target write objects (such as ` / dev / block / mmcblk0p2` or ` / dev / mapper / system`) corresponding to each image entry (such as boot, rootfs, vendor, etc.) are accurately separated. This fundamentally avoids the risk of "mismatch between image content and target device type" caused by traditional OTA relying on hard-coded paths or filename matching in scripts, and significantly improves the certainty and traceability of the writing intent.
[0027] Step S102: Based on the image file to be written, the image content is identified to obtain the target image type corresponding to each image entry.
[0028] In this embodiment, the image content is identified based on the image file to be written, and the target image type corresponding to each image entry is obtained. This reduces the strong dependence on the description file, reduces human configuration errors, and ensures the security and success rate of the write operation.
[0029] It should be noted that in OTA upgrade packages, different image entries usually correspond to different target write objects (such as different partitions or logical volumes). Therefore, the required image types (such as container UBI images or file system ext4 images) may be different and must be identified and matched separately.
[0030] In one specific embodiment, step S102 includes: for each of the image entries, obtaining the image type identifier of the image entry based on the image file to be written; performing structural recognition on the image file to be written based on the image type identifier to obtain the keyword recognition result of the image entry; matching the keyword recognition result with the type of the target writing object to obtain a matching result; if the matching result is a match, then using the image type identifier as the target image type of the image entry; if the matching result is a mismatch, then using the type of the target writing object as the target image type of the image entry.
[0031] In this embodiment, for each image entry, the magic number field in the image header is read to obtain the image type identifier of the image entry. For example, if the magic number field "UBI!" in the image header is used as the image type identifier, it is determined to be an image of type UBI; if the magic number field "UBIFS!" in the image header is used as the image type identifier, it is determined to be an image of type UBIFS.
[0032] Furthermore, based on the image type identifier, the structure of the image file is identified, keywords are extracted, and the keyword identification results of the image entries are obtained. For example, for an image with the image type identifier "UBI!", "UBI#" is read; for an image with the image type identifier "UBIFS!", "UBIFS!" is read.
[0033] Furthermore, the keyword recognition result is matched with the type of the target written object. If they match, the image type identifier is used as the target image type of the image entry; otherwise, the type of the target written object is used as the target image type of the image entry.
[0034] For example, if the target write object is the partition " / dev / mtd1" and the image corresponding to the keyword recognition result is of type UBIFS, the image type identifier is used as the target image type, and the image needs to be converted to the UBI format suitable for the partition " / dev / mtd1" in the future; or, if the target write object is the volume "my_volume" and the image corresponding to the keyword recognition result is of type ext4, the image type identifier is used as the target image type, and the image needs to be written directly to the volume "my_volume" in the future.
[0035] Understandably, by matching the identification results with the target write type and blocking or correcting according to the strategy when there is a discrepancy, precise control over the upgrade process is achieved, avoiding the problem of mount failure after upgrade due to mismatch between image type and write target.
[0036] Step S103: For each of the image entries, determine the write path according to the target image type and the target write object of the image entry, and perform image writing on the image file to be written according to the write path to obtain single write storage area information and single write operation result.
[0037] In this embodiment, the write path is jointly determined by the target image type and the target write object to achieve semantic adaptation (such as container images taking partition-level atomic write and file system images taking volume-level verification write), avoiding mount failure caused by type mismatch; the single storage area information and single write operation result (success or failure, reason for failure, etc.) after each image write operation are generated synchronously, providing accurate basis for subsequent mountability verification, error location and intelligent adjustment, significantly improving write reliability, security and process observability.
[0038] In one specific embodiment, step S103 includes: if the target image type is a container image, then the write path is determined according to the partition-level write path and the target write object of each image entry; if the target image type is a file system image, then the write path is determined according to the volume-level update path and the target write object of each image entry.
[0039] In this embodiment, if the target image type is a container image, the write path type is a partition-level write path, for example, writing the image to the " / dev / mtd1" partition; the destination of the write path is the target write object of each image entry.
[0040] If the target image type is a file system image, then the write path type is a volume-level update path. For example, when writing the image to the "my_volume" volume, the destination of the write path is the target write object of each image entry.
[0041] As an example, the "dd" command is used to write an image to a partition or volume: "dd if= / dev / stdin of= / dev / mtd1 bs=1024 seek=1024", where "my_volume" is mounted at " / mnt / my_volume", then the image will be written to the " / mnt / my_volume" directory.
[0042] Understandably, by reading the image header and key offsets, container-type and file system-type images can be accurately identified, effectively handling UBI / UBIFS mixed scenarios, solving the incompatibility problem of different types of images in existing technologies, improving the success rate and stability of upgrades, and effectively preventing anomalies caused to the system after harmful images are packaged.
[0043] In one specific embodiment, before step S103, the process includes: obtaining storage block change information based on the upgrade package file; performing range verification on the target write objects of each of the image entries based on the storage block change information to obtain range verification results; and correcting the target write objects of each of the image entries based on the range verification results.
[0044] In this embodiment, by identifying the actual range of storage blocks changed in the upgrade package file, storage block change information is obtained. Then, the storage block change information is used to perform address boundary verification and out-of-bounds correction on the target write objects of each image entry. This effectively prevents cross-partition overwriting or accidental erasure of critical areas (such as GPT header and bootloader) caused by version mismatch, script misconfiguration or firmware compatibility issues, thus ensuring the security of storage space and the certainty of upgrade operations from the source.
[0045] In one specific embodiment, obtaining storage block change information based on the upgrade package file includes: extracting a new version number from the upgrade package file; obtaining an old version number; generating an upgrade version difference table based on the old version number and the new version number; and determining the storage block change information based on the upgrade version difference table.
[0046] In this embodiment, the new version information is obtained by parsing the new version number corresponding to the upgrade package file. For example, if the new version number is "1.2.3", it means that the software version contained in this upgrade package file is "1.2.3".
[0047] Furthermore, based on the new version number and the old version number of the software running on the terminal device, an upgrade version difference table is obtained. For example, if the new version number is "1.2.3" and the old version number is "1.1.9", then the upgrade version difference table contains the difference information from "1.1.9" to "1.2.3".
[0048] Furthermore, based on the version difference table, it is determined which storage blocks in the terminal device's memory will have their storage contents changed during this upgrade process, thus obtaining storage block change information. For example, if the upgrade version difference table indicates that the new version "1.2.3" adds two new functional modules compared to the older version "1.1.9", which are stored in storage blocks 0x10000-0x20000 and 0x30000-0x40000 respectively, then it is determined that the storage contents of these two storage blocks will change.
[0049] Step S104: Perform mountability verification on the single-write storage area information to obtain the mountability verification result.
[0050] In this embodiment, the mountability of the single-write storage area information is verified to obtain the mountability verification result. For example, to verify whether the partition " / dev / mtd1" in the single-write storage area information is mountable: "mount -t ubifs / dev / mtd1 / mnt / ubifs", or to verify whether the single-write storage area information verification volume "my_volume" is mountable: "mount -t ext4 / dev / sda1 / mnt / ext4".
[0051] Step S105: Adjust the image write based on the result of the single write operation and the mount verification result.
[0052] In this embodiment, the mirror write adjustment is performed based on the result of a single write operation and the mount verification result, thereby achieving real-time correction.
[0053] Please see Figure 2 In one specific embodiment, step S105 includes steps S1051 to S1054, and each step is described in detail below.
[0054] Step S1051: Determine whether the write path needs to be automatically switched based on the result of the single write operation, and obtain the first determination result.
[0055] In this embodiment, a first determination result is obtained by determining whether to automatically switch the write path based on the result of a single write operation. For example, if the result of a single write operation is a write failure, and two attempts have been made without success, the automatic write path switching flag is set to "false" as the first determination result; if the result of a single write operation is a write success, the automatic write path switching flag is set to "true" as the first determination result.
[0056] Step S1052: If the first judgment result is not automatic switching of the write path, then the step of parsing the upgrade package file to obtain the image file to be written and the list of changed storage blocks is executed again. In this embodiment, if the automatic write path switching flag is "false", the process returns to step S101 to reselect the write path. Conversely, if the automatic write path switching flag is "true", step S301 is executed.
[0057] Step S1053: Determine whether the image write error is unrecoverable based on the mount verification result, and obtain the second judgment result.
[0058] In this embodiment, a second determination result is obtained by determining whether the image write error is unrecoverable based on the mount verification result. For example, if the mount verification result reflects that a disk error was found during the write process, causing the write to be unable to continue, then the second determination result is whether the image write error is unrecoverable.
[0059] Step S1054: If the second judgment result is whether the image write error is unrecoverable, then the step of parsing the upgrade package file to obtain the image file to be written and the list of changed storage blocks is executed again.
[0060] In this embodiment, if the second determination result is that the image write error is unrecoverable, then the process returns to step S101 to reselect the write path. Conversely, if the second determination result is that the image write error is recoverable, then step S301 is executed.
[0061] Please see Figure 3 In one specific embodiment, the method further includes steps S301 to S303, which are described in detail below.
[0062] Step S301: Perform mount verification on the target write object of each image entry after the image content has been written, and obtain the mount verification result.
[0063] In this embodiment, the target write object of all image entries after the image content is written is mounted and verified to obtain the mounting verification result. After all writing steps are completed, a final and overall acceptance check is performed.
[0064] For example, to verify whether a partition can be mounted for writing to a partition, use the command: "mount -t ubifs / dev / mtd1 / mnt / ubifs"; to verify whether a volume can be mounted for writing to a volume, use the command: "mount -t ext4 / dev / sda1 / mnt / ext4".
[0065] Step S302: Obtain the upgrade log file during the image content writing process, and determine whether the writing status of each image entry contains the correct keyword based on the upgrade log file to obtain the keyword verification result.
[0066] In this embodiment, the upgrade log file during the image content writing process is obtained, and the write status of each image entry is determined based on the upgrade log file to determine whether it contains the correct keyword, thereby obtaining the keyword verification result and checking whether the keyword is correct.
[0067] For example, the upgrade log file records the write status of each image entry, including the keywords "success" or "failed", and verifies whether these keywords are correct.
[0068] Step S303: Generate an upgrade result report based on the write operation result, the mount verification result, and the keyword verification result.
[0069] In this embodiment, an upgrade result report is generated based on the write operation result, mount verification result, and keyword verification result. For example, if all image entries are written successfully and both volume mount verification and keyword verification pass, an "upgrade successful" message is reported; if a write failure or verification failure occurs, the corresponding error information is reported.
[0070] It should be noted that this embodiment supports other image types such as ext4 / squashfs, offering good scalability and meeting the diverse needs of future firmware upgrades. Furthermore, by outputting diagnostic error codes and mismatches, this embodiment improves the maintainability and operability of the system, facilitating rapid problem location and resolution. In addition, it can seamlessly integrate with existing OTA execution entry points.
[0071] The upgrade package image writing method proposed in this embodiment parses the upgrade package file to obtain the image file to be written and the target write objects of multiple image entries; it identifies the image content based on the image file to be written to obtain the target image type corresponding to each image entry; for each image entry, it determines the write path based on the target image type and the target write object of the image entry, and performs image writing on the image file to be written according to the write path to obtain single write storage area information and single write operation result; it performs mountability verification on the single write storage area information to obtain the mountability verification result; and it adjusts the image writing based on the single write operation result and the mountability verification result. In this way, it performs content-level identification of the images in the upgrade package file, rather than relying solely on the filename, to determine the image type and automatically match the correct write path, thereby avoiding mount failure after the upgrade due to mismatch between the image type and the write target; at the same time, the mountability verification intercepts unusable images beforehand to prevent abnormal system startup, adaptively adjusts the write strategy, reduces the need for manual intervention, and shortens the upgrade time.
[0072] Example 2 Furthermore, this disclosure provides an upgrade package image writing device 400, please refer to [link to relevant documentation]. Figure 4 The device includes: The parsing module 401 is used to parse the upgrade package file to obtain the target write object of the image file to be written and multiple image entries; The identification module 402 is used to identify the image content based on the image file to be written, and obtain the target image type corresponding to each image entry; The writing module 403 is used to determine the writing path for each of the image entries based on the target image type and the target writing object of the image entry, and to perform image writing on the image file to be written based on the writing path, so as to obtain single write storage area information and single write operation result. Verification module 404 is used to perform mountability verification on the single-write storage area information and obtain the mountability verification result. The adjustment module 405 is used to perform image write adjustment based on the result of the single write operation and the mount verification result.
[0073] In an optional implementation, the adjustment module 405 is further configured to determine whether automatic switching of the write path is required based on the result of the single write operation, and obtain a first determination result; if the first determination result is not automatic switching of the write path, then the step of parsing the upgrade package file to obtain the image file to be written and the list of changed storage blocks is re-executed; the image write error is determined to be unrecoverable based on the mount verification result, and a second determination result is obtained; if the second determination result is whether the image write error is unrecoverable, then the step of parsing the upgrade package file to obtain the image file to be written and the list of changed storage blocks is re-executed.
[0074] In an optional embodiment, the apparatus further includes: The verification module is used to perform mount verification on the target write object of each image entry after the image content is written, and obtain the mount verification result; obtain the upgrade log file during the image content writing process, and determine whether the writing status of each image entry contains the correct keyword based on the upgrade log file, and obtain the keyword verification result; generate an upgrade result report based on the writing operation result, the mount verification result and the keyword verification result.
[0075] In an optional implementation, the writing module 403 is further configured to obtain storage block change information based on the upgrade package file, perform range verification on the target write object of each of the mirror entries based on the storage block change information, obtain range verification results, and correct the target write object of each of the mirror entries based on the range verification results.
[0076] In an optional implementation, the writing module 403 is further configured to extract a new version number from the upgrade package file; obtain an old version number; generate an upgrade version difference table based on the old version number and the new version number; and determine the storage block change information based on the upgrade version difference table.
[0077] In an optional implementation, the writing module 403 is further configured to determine the writing path based on the partition-level writing path and the target writing object of each image entry if the target image type is a container image; and to determine the writing path based on the volume-level update path and the target writing object of each image entry if the target image type is a file system image.
[0078] In an optional implementation, the identification module 402 is further configured to, for each of the image entries, obtain the image type identifier of the image entry based on the image file to be written; perform structural identification on the image file to be written based on the image type identifier to obtain the keyword identification result of the image entry; match the keyword identification result with the type of the target writing object to obtain a matching result; if the matching result is a match, then the image type identifier is used as the target image type of the image entry; if the matching result is a mismatch, then the type of the target writing object is used as the target image type of the image entry.
[0079] The apparatus provided in this embodiment can perform the steps of the upgrade package image writing method provided in Embodiment 1. To avoid repetition, it will not be described again.
[0080] The upgrade package image writing device proposed in this embodiment parses the upgrade package file to obtain the image file to be written and the target writing objects of multiple image entries; it identifies the image content based on the image file to be written to obtain the target image type corresponding to each image entry; for each image entry, it determines the writing path based on the target image type and the target writing object of the image entry, and performs image writing on the image file to be written according to the writing path to obtain single-write storage area information and single-write operation result; it performs mountability verification on the single-write storage area information to obtain the mountability verification result; and it adjusts the image writing based on the single-write operation result and the mountability verification result. In this way, it performs content-level identification of the images in the upgrade package file, rather than relying solely on the filename, to determine the image type and automatically match the correct writing path, thereby avoiding mounting failure after the upgrade due to mismatch between the image type and the writing target; at the same time, the mountability verification intercepts unusable images beforehand to prevent abnormal system startup, adaptively adjusts the writing strategy, reduces the need for manual intervention, and shortens the upgrade time.
[0081] Example 3 Furthermore, this disclosure provides a computer device including a memory and a processor. The memory stores a computer program, which, when executed by the processor, implements the upgrade package image writing method described in Embodiment 1.
[0082] The device provided in this embodiment can perform the steps of the upgrade package image writing method provided in Embodiment 1. To avoid repetition, the steps will not be repeated.
[0083] Example 4 This disclosure provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the upgrade package image writing method described in Embodiment 1.
[0084] In this embodiment, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.
[0085] The computer-readable storage medium provided in this embodiment can implement the upgrade package image writing method provided in Embodiment 1. To avoid repetition, it will not be described again here.
[0086] In all examples shown and described herein, any specific values should be interpreted as merely exemplary and not as limitations; therefore, other examples of exemplary embodiments may have different values.
[0087] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0088] The above-described embodiments are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention.
Claims
1. An upgrade package mirror write method, characterized by, The method includes: The upgrade package file is parsed to obtain the target write objects for the image file to be written and multiple image entries; Based on the image file to be written, the image content is identified to obtain the target image type corresponding to each image entry; For each of the aforementioned image entries, a write path is determined based on the target image type and the target write object of the image entry. The image file to be written is then written according to the write path to obtain single write storage area information and single write operation results. The mountability verification is performed on the single-write storage area information to obtain the mount verification result. The image write adjustment is performed based on the results of the single write operation and the mount verification results.
2. The upgrade package mirror writing method according to claim 1, wherein The step of adjusting the image write based on the write operation result and the mount verification result includes: Based on the result of the single write operation, determine whether it is necessary to automatically switch the write path, and obtain the first determination result; If the first judgment result is not to automatically switch the write path, then the step of parsing the upgrade package file to obtain the image file to be written and the list of changed storage blocks is executed again. Based on the mount verification results, determine whether the image write error is unrecoverable, and obtain a second judgment result; If the second determination result indicates whether the image write error is unrecoverable, then the step of parsing the upgrade package file to obtain the image file to be written and the list of changed storage blocks is re-executed.
3. The upgrade package mirror writing method of claim 1, wherein, The method further includes: After the image content has been written, the target write object of each image entry is mounted and verified to obtain the mount verification result. Obtain the upgrade log file during the image content writing process, and determine whether the writing status of each image entry contains the correct keyword based on the upgrade log file to obtain the keyword verification result; An upgrade result report is generated based on the write operation result, the mount verification result, and the keyword verification result.
4. The upgrade package mirror writing method of claim 1, wherein, Before determining the write path based on the target image type and the target write object of the image entry, the process includes: Based on the upgrade package file, storage block change information is obtained. Based on the storage block change information, the target write object of each of the image entries is range-checked to obtain the range check result. The target write object of each of the aforementioned mirror entries is corrected based on the range verification results.
5. The upgrade package mirror writing method according to claim 4, wherein The step of obtaining storage block change information based on the upgrade package file includes: Extract the new version number from the upgrade package file; Obtain the old version number, and generate an upgrade version difference table based on the old version number and the new version number; The storage block change information is determined based on the upgrade version difference table.
6. The upgrade package mirror writing method of claim 1, wherein, The step of determining the write path based on the target image type and the target write object of the image entry includes: If the target image type is a container image, the write path is determined based on the partition-level write path and the target write object of each image entry; If the target image type is a file system image, the write path is determined based on the volume-level update path and the target write object of each image entry.
7. The upgrade package mirror writing method of claim 1, wherein, The step of identifying the target image type based on the image file to be written includes: For each of the aforementioned image entries, the image type identifier of the image entry is obtained based on the image file to be written; The structure of the image file to be written is identified based on the image type identifier to obtain the keyword identification result of the image entry; The matching result is obtained by matching the keyword recognition result with the type of the target writing object; If the matching result is a match, then the image type identifier is used as the target image type of the image entry; If the matching result is a mismatch, then the type of the target object is used as the target image type of the image entry.
8. An upgrade package image writing device, characterized in that, The device includes: The parsing module is used to parse the upgrade package file to obtain the target write object of the image file to be written and multiple image entries; The identification module is used to identify the image content based on the image file to be written, and to obtain the target image type corresponding to each image entry. The writing module is used to determine the writing path for each of the image entries based on the target image type and the target writing object of the image entry, and to perform image writing on the image file to be written according to the writing path, so as to obtain single write storage area information and single write operation result. The verification module is used to perform mountability verification on the single-write storage area information and obtain the mountability verification result. The adjustment module is used to adjust the image write based on the result of the single write operation and the mount verification result.
9. A computer device, comprising: It includes a memory and a processor, the memory storing a computer program that, when executed by the processor, implements the upgrade package image writing method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the upgrade package image writing method as described in any one of claims 1 to 7.