Operating system startup exception processing method, device and equipment, medium and program

By hashing the external initramfs file when the operating system is started and determining the cause of decompression failure based on the hash value, the problem of fast positioning of the external initramfs file failure when the operating system is started is solved, and processing efficiency and system reliability are improved.

CN119690733AActive Publication Date: 2025-03-25KYLIN CORP

Patent Information

Application Number
CN202510213090.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-26
Publication Date
2025-03-25
Estimated Expiration
2045-02-26

AI Technical Summary

Technical Problem

During the operating system startup process, when the external initramfs file decompression fails, it is difficult for the existing technology to quickly and accurately locate the causes of the abnormality, resulting in inefficient processing, complex system maintenance, and affecting normal operation and user experience.

Method used

When the operating system is started, the external initramfs file is loaded through the boot loader and the hash check function is executed to obtain the hash value of the file. After decompression fails, determine the cause of decompression failure based on the comparison result of the hash value and the expected hash value, and report the problem to the corresponding processing object.

Benefits of technology

Quickly locate the cause of decompression failure through hash verification, avoiding the dependence of manual troubleshooting, improving the accuracy and efficiency of problem handling, and reducing system downtime and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119690733A_ABST
    Figure CN119690733A_ABST
Patent Text Reader

Abstract

The invention relates to an operating system startup exception processing method and device, equipment, a medium and a program. The method comprises the steps that when an operating system is started, a loading program is guided to load an external initramfs file into a memory, and an initial address of the external initramfs file is transmitted to a kernel of the operating system; performing Hash verification on the external initramfs file by executing the Hash verification function to obtain a Hash value of the external initramfs file; the operating system kernel decompresses the external initramfs file into a root file system according to the initial address; and when it is determined that the external initramfs file cannot be normally decompressed, determining a decompression failure reason according to a comparison result of the hash value of the external initramfs file and an expected hash value. And reporting the decompression failure problem to the corresponding processing object according to the decompression failure reason. By adopting the method, the decompression failure reason can be quickly and accurately positioned, the decompression failure problem can be pointedly processed, and resource waste is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an operating system startup exception processing method, device, equipment, medium and program. Background Art

[0002] The external Initramfs file system is an initial RAM file system that is used as a temporary carrier of the root file system during the boot process of the operating system. In domestic operating systems, the operating system kernel boot process relies on the external initramfs file to load necessary drivers and perform initialization operations. The decompression of the external initramfs file is a key step in the boot process, but during the loading process, the decompression may fail due to various reasons, thus affecting the normal boot of the system.

[0003] The existing exception handling mechanism usually relies on various human resources to check one by one after discovering that the external initramfs file decompression fails. Since the root cause of the exception is difficult to quickly determine, the allocation and handling of the exception is inefficient, which not only prolongs the time to solve the problem, but also increases the complexity of system maintenance, thus affecting the normal operation of the system and user experience. In addition, the current system relies too much on restarting the system after the external initramfs file decompression fails, and lacks an automated recovery mechanism. This not only leads to longer system downtime, but also increases maintenance costs.

[0004] Therefore, when the decompression of the external initramfs file fails, how to quickly and accurately locate the cause of the exception, assign the decompression failure problem to a reasonable processing object, and enhance the system's recovery capability through an effective recovery mechanism has become a technical problem that needs to be solved urgently. Summary of the invention

[0005] Based on this, it is necessary to provide an operating system startup exception handling method for the above technical problems, so as to quickly and accurately locate the cause of the compression failure when the compression of the external initramfs file fails.

[0006] In a first aspect, the present invention provides a method for handling an operating system startup exception, the method comprising: When the operating system starts, the boot loader loads the external initramfs file into the memory and passes the starting address of the external initramfs file to the operating system kernel; By executing the hash verification function, the external initramfs file is hash-verified to obtain the hash value of the external initramfs file; The operating system kernel decompresses the external initramfs file into the root file system according to the starting address; When it is determined that the external initramfs file cannot be decompressed normally, the reason for the decompression failure is determined based on the comparison result between the hash value of the external initramfs file and the expected hash value; According to the decompression failure reason, the decompression failure problem is reported to the corresponding processing object.

[0007] In one embodiment, the hash verification function includes a first processing function, a second processing function and a third processing function; performing a hash verification on the external initramfs file through the hash verification function to obtain a hash value of the external initramfs file includes: By executing the first processing function, a hash transformation object is created; the hash transformation object includes a calculation-related function and metadata; By executing the second processing function, a hash descriptor structure is created, and the hash descriptor structure is bound to the hash transformation object; By executing the third processing function, in the hash descriptor structure, the metadata and the external initramfs file data are input into the calculation related function to calculate the hash value of the external initramfs file; After the computation is complete, the hash transform object and hash descriptor structure are released.

[0008] In one embodiment, determining that an external initramfs file cannot be decompressed normally includes: Before the operating system kernel decompresses the external initramfs file for the first time, the number of decompressions recorded in the decompression counter is initialized to 0, and the number of decompressions recorded is increased by 1 each time the operating system kernel decompresses the external initramfs file; When the operating system kernel fails to decompress the external initramfs file, it is determined whether the external initramfs file cannot be decompressed normally according to the relationship between the recorded decompression times and the preset decompression times.

[0009] In one embodiment, determining whether the external initramfs file cannot be decompressed normally according to the relationship between the recorded decompression times and the preset decompression times includes: If the recorded decompression times are less than the preset decompression times, the external initramfs file is decompressed again; If the recorded decompression times are equal to the preset decompression times, it is determined that the external initramfs file cannot be decompressed normally.

[0010] In one embodiment, determining the reason for the decompression failure based on a comparison result between a hash value of the external initramfs file and an expected hash value includes: If the hash value of the external initramfs file is inconsistent with the expected hash value, it is determined that the decompression failure is caused by the corruption of the external initramfs file; If the hash value of the external nitramfs file is consistent with the expected hash value, it is determined that the cause of the decompression failure is an abnormality in the operating system kernel startup process.

[0011] In one embodiment, according to the decompression failure reason, reporting the decompression failure problem to the corresponding processing object includes: If it is determined that the decompression failure is caused by the damage of the external initramfs file, the decompression failure problem is reported to the first processing object; If it is determined that the decompression failure is caused by an abnormal operating system kernel startup process, the decompression failure problem is reported to the second processing object.

[0012] In a second aspect, the present invention further provides an operating system startup exception handling device, the device comprising: A loading module is used for the boot loader to load the external initramfs file into the memory when the operating system starts, and pass the starting address of the external initramfs file to the operating system kernel; A hash check module is used to perform a hash check on an external initramfs file by executing a hash check function to obtain a hash value of the external initramfs file; The decompression module is used by the operating system kernel to decompress the external initramfs file into the root file system according to the starting address; A determination module, used for determining the reason for the decompression failure according to the comparison result between the hash value of the external initramfs file and the expected hash value after determining that the external initramfs file cannot be decompressed normally; The reporting module is used to report the decompression failure problem to the corresponding processing object according to the decompression failure reason.

[0013] In a third aspect, the present invention further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented: When the operating system starts, the boot loader loads the external initramfs file into the memory and passes the starting address of the external initramfs file to the operating system kernel; By executing the hash verification function, the external initramfs file is hash-verified to obtain the hash value of the external initramfs file; The operating system kernel decompresses the external initramfs file into the root file system according to the starting address; When it is determined that the external initramfs file cannot be decompressed normally, the reason for the decompression failure is determined based on the comparison result between the hash value of the external initramfs file and the expected hash value; According to the decompression failure reason, the decompression failure problem is reported to the corresponding processing object.

[0014] In a fourth aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the following steps are implemented: When the operating system starts, the boot loader loads the external initramfs file into the memory and passes the starting address of the external initramfs file to the operating system kernel; By executing the hash verification function, the external initramfs file is hash-verified to obtain the hash value of the external initramfs file; The operating system kernel decompresses the external initramfs file into the root file system according to the starting address; When it is determined that the external initramfs file cannot be decompressed normally, the reason for the decompression failure is determined based on the comparison result between the hash value of the external initramfs file and the expected hash value; According to the decompression failure reason, the decompression failure problem is reported to the corresponding processing object.

[0015] In a fifth aspect, the present invention further provides a computer program product, comprising a computer program, which implements the following steps when executed by a processor: When the operating system starts, the boot loader loads the external initramfs file into the memory and passes the starting address of the external initramfs file to the operating system kernel; By executing the hash verification function, the external initramfs file is hash-verified to obtain the hash value of the external initramfs file; The operating system kernel decompresses the external initramfs file into the root file system according to the starting address; When it is determined that the external initramfs file cannot be decompressed normally, the reason for the decompression failure is determined based on the comparison result between the hash value of the external initramfs file and the expected hash value; According to the decompression failure reason, the decompression failure problem is reported to the corresponding processing object.

[0016] The above-mentioned operating system startup exception processing method, device, equipment, medium and program, when the operating system starts, the boot loader loads the external initramfs file into the memory, and passes the starting address of the external initramfs file to the operating system kernel; by executing the hash verification function, the external initramfs file is hash-verified to obtain the hash value of the external initramfs file, so that the hash value is subsequently used as the basis for determining the reason for the decompression failure; the operating system kernel decompresses the external initramfs file into the root file system according to the starting address; when it is determined that the external initramfs file cannot be decompressed normally, the reason for the decompression failure is determined according to the comparison result of the hash value of the external initramfs file and the expected hash value, which replaces the method of manually troubleshooting the reason for the decompression failure and can quickly and accurately locate the reason for the decompression failure; according to the reason for the decompression failure, the decompression failure problem is reported to the corresponding processing object, so as to deal with the decompression failure problem in a targeted manner and avoid resource waste. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or related technologies, the drawings required for use in the embodiments of the present invention or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 The figure is a flowchart of an operating system startup exception handling method in one embodiment. DETAILED DESCRIPTION

[0019] The technical scheme in the embodiment of the present invention is described clearly and completely below in conjunction with the accompanying drawings in the embodiment of the present invention. In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention can also be implemented in other ways different from those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present invention, so the present invention is not limited by the specific embodiments disclosed below.

[0020] In an alternative embodiment, if Figure 1 As shown, a method for handling operating system startup exceptions is provided. In this embodiment, the method includes the following steps: S110, when the operating system starts, the boot loader loads the external initramfs file into the memory, and passes the starting address of the external initramfs file to the operating system kernel.

[0021] The operating system may be a Linux operating system, etc. The loader may be a BIOS (Basic Input / Output System), etc. The starting address of the external initramfs file may be allocated according to the configuration and startup conditions of the operating system.

[0022] S120, performing hash verification on the external initramfs file by executing a hash verification function to obtain a hash value of the external initramfs file.

[0023] The hash value is also called a hash value, which refers to a unique value obtained by calculating the data. The hash check function can be understood as a function used to obtain the hash value of an external initramfs file. Optionally, the hash check function can include a first processing function, a second processing function, and a third processing function. The first processing function can use the crypto_alloc_shash function; the second processing function can use the kzalloc function; and the third processing function can use the crypto_shash_digest function.

[0024] In an optional embodiment, the method for obtaining the hash value of the external initramfs file may include the following steps: S121, creating a hash transformation object by executing a first processing function; The hash transformation object can be understood as an abstract object of the hash algorithm. The hash transformation object can include calculation-related functions and metadata. Further, the calculation-related function can be understood as a function used for hash value calculation, such as SHA-1 (Secure Hash Algorithm 1, etc.). The metadata can be understood as parameters involved in calculating the hash value.

[0025] S122: Create a hash descriptor structure by executing the second processing function, and bind the hash descriptor structure to the hash transformation object.

[0026] The hash descriptor structure can be understood as a temporary workspace for hash calculation. In the hash descriptor structure, context information of the hash calculation can be saved.

[0027] S123, by executing the third processing function, in the hash descriptor structure, the metadata and the external initramfs file data are input into a calculation related function to calculate the hash value of the external initramfs file.

[0028] Exemplarily, the external initramfs file data in the memory may be loaded through the third processing function, and the metadata and the external initramfs file data may be input as parameters into a calculation-related function, thereby calculating the hash value of the external initramfs file.

[0029] S124: After the calculation is completed, the hash transformation object and the hash descriptor structure are released.

[0030] It will be appreciated that by releasing the hash transform object and the hash descriptor structure, memory leaks can be prevented.

[0031] S130, the operating system kernel decompresses the external initramfs file into the root file system according to the starting address.

[0032] The root file system can be understood as the file system that is first mounted when the operating system is started, and the root file system can provide the basic environment required for the operation of the operating system. Optionally, the root file system can be a Rootfs system, which can include core components and user space programs required when the operating system is started.

[0033] S140, when it is determined that the external initramfs file cannot be decompressed normally, determine the reason for the decompression failure according to a comparison result between the hash value of the external initramfs file and the expected hash value.

[0034] The expected hash value may be understood as a reference value of the hash value of the external initramfs file.

[0035] In an optional embodiment, the method for determining whether the external initramfs file cannot be decompressed normally may include the following steps: S141, before the operating system kernel decompresses the external initramfs file for the first time, the number of decompressions recorded in the decompression counter is initialized to 0, and the number of decompressions recorded is increased by 1 each time the operating system kernel decompresses the external initramfs file.

[0036] The decompression counter may be understood as a counter built into the operating system, and is used to record the number of times the operating system kernel decompresses the external initramfs file during a single operating system startup process.

[0037] S142, when the operating system kernel fails to decompress the external initramfs file, determine whether the external initramfs file cannot be decompressed normally according to the relationship between the recorded decompression times and the preset decompression times.

[0038] The preset decompression times may be understood as the upper limit of the number of times the operating system decompresses the external initramfs file.

[0039] Optionally, if the recorded decompression times are less than the preset decompression times, the external initramfs file is decompressed again; if the recorded decompression times are equal to the preset decompression times, it is determined that the external initramfs file cannot be decompressed normally.

[0040] It is understandable that re-decompressing external files is more efficient than restarting the system. However, when the number of recorded decompression times is equal to the preset number of decompression times, it means that the problem of failure to decompress the external initramfs file cannot be solved by re-decompression, so it can be determined that the external initramfs file cannot be decompressed normally.

[0041] In another optional embodiment, if the hash value of the external initramfs file is inconsistent with the expected hash value, it is determined that the cause of the decompression failure is that the external initramfs file is damaged; if the hash value of the external initramfs file is consistent with the expected hash value, it is determined that the cause of the decompression failure is that the operating system kernel startup process is abnormal.

[0042] It is understandable that, since the hash values ​​calculated for the same data are the same, when the hash value of the external initramfs file is inconsistent with the expected hash value, it means that the data file data of the external initramfs file has changed before decompression, so it can be determined that the reason for the decompression failure is that the external initramfs file is damaged. Exemplarily, when the BIOS loads the external file into the memory, the external initramfs file is damaged. In contrast, when the hash value of the external initramfs file is consistent with the expected hash value, it means that the external initramfs file is not damaged before decompression, that is, the decompression failure has nothing to do with the external initramfs file itself, so it can be determined that the reason for the decompression failure is the abnormal kernel startup process.

[0043] S150: Report the decompression failure problem to a corresponding processing object according to the decompression failure reason.

[0044] Optionally, the processing object can be a pre-set processing program or a processing person. For example, for the scenario where the processing object is a processing person, the following logic can be used to report the decompression failure problem: If it is determined that the decompression failure is caused by the damage of the external initramfs file, the decompression failure problem is reported to the first processing object; If it is determined that the decompression failure is caused by an abnormal operating system kernel startup process, the decompression failure problem is reported to the second processing object.

[0045] The first processing object may be a firmware engineer, and the second processing object may be an operating system kernel engineer. By reporting the decompression failure problems caused by different decompression failure reasons to the appropriate processing object, the efficiency of solving the decompression failure problem can be improved and resource waste can be avoided.

[0046] In this embodiment, when the operating system starts, the boot loader loads the external initramfs file into the memory, and passes the starting address of the external initramfs file to the operating system kernel; by executing the hash verification function, the external initramfs file is hash-verified to obtain the hash value of the external initramfs file, so that the hash value is subsequently used as the basis for determining the cause of the decompression failure; the operating system kernel decompresses the external initramfs file into the root file system according to the starting address; when it is determined that the external initramfs file cannot be decompressed normally, the cause of the decompression failure is determined according to the comparison result between the hash value of the external initramfs file and the expected hash value, which replaces the method of manually troubleshooting the cause of the decompression failure and can quickly and accurately locate the cause of the decompression failure; according to the cause of the decompression failure, the decompression failure problem is reported to the corresponding processing object, so as to deal with the decompression failure problem in a targeted manner and avoid waste of resources.

[0047] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0048] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of the present invention.

[0049] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the present invention. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the attached claims.

Claims

1. A method for handling an operating system startup exception, characterized in that: The method comprises: When the operating system starts, the boot loader loads the external initramfs file into the memory and passes the starting address of the external initramfs file to the operating system kernel; By executing the hash verification function, the external initramfs file is hash-verified to obtain the hash value of the external initramfs file; The operating system kernel decompresses the external initramfs file into the root file system according to the starting address; When it is determined that the external initramfs file cannot be decompressed normally, the reason for the decompression failure is determined based on the comparison result between the hash value of the external initramfs file and the expected hash value; According to the decompression failure reason, the decompression failure problem is reported to the corresponding processing object.

2. The method according to claim 1, characterized in that The hash check function includes a first processing function, a second processing function and a third processing function; the method of performing a hash check on the external initramfs file by executing the hash check function to obtain a hash value of the external initramfs file includes: By executing the first processing function, a hash transformation object is created; the hash transformation object includes a calculation-related function and metadata; By executing the second processing function, a hash descriptor structure is created, and the hash descriptor structure is bound to the hash transformation object; By executing the third processing function, in the hash descriptor structure, the metadata and the external initramfs file data are input into the calculation related function to calculate the hash value of the external initramfs file; After the computation is complete, the hash transform object and hash descriptor structure are released.

3. The method according to claim 1, characterized in that The determination that the external initramfs file cannot be decompressed normally includes: Before the operating system kernel decompresses the external initramfs file for the first time, the number of decompressions recorded in the decompression counter is initialized to 0, and the number of decompressions recorded is increased by 1 each time the operating system kernel decompresses the external initramfs file; When the operating system kernel fails to decompress the external initramfs file, it is determined whether the external initramfs file cannot be decompressed normally according to the relationship between the recorded decompression times and the preset decompression times.

4. The method according to claim 3, characterized in that The step of determining whether the external initramfs file cannot be decompressed normally according to the relationship between the recorded decompression times and the preset decompression times includes: If the recorded decompression times are less than the preset decompression times, the external initramfs file is decompressed again; If the recorded decompression times are equal to the preset decompression times, it is determined that the external initramfs file cannot be decompressed normally.

5. The method according to claim 1, characterized in that Determining the reason for the decompression failure according to the comparison result of the hash value of the external initramfs file and the expected hash value includes: If the hash value of the external initramfs file is inconsistent with the expected hash value, it is determined that the decompression failure is caused by the corruption of the external initramfs file; If the hash value of the external initramfs file is consistent with the expected hash value, the decompression failure is determined to be caused by an abnormal operating system kernel startup process.

6. The method according to claim 5, characterized in that The step of reporting the decompression failure problem to a corresponding processing object according to the decompression failure reason includes: If it is determined that the decompression failure is caused by the damage of the external initramfs file, the decompression failure problem is reported to the first processing object; If it is determined that the reason for the decompression failure is that the operating system kernel startup process is abnormal, the decompression failure problem is reported to the second processing object.

7. An operating system startup exception handling device, characterized in that: The device comprises: A loading module is used for the boot loader to load the external initramfs file into the memory when the operating system starts, and pass the starting address of the external initramfs file to the operating system kernel; A hash check module is used to perform a hash check on an external initramfs file by executing a hash check function to obtain a hash value of the external initramfs file; A decompression module is used for the operating system kernel to decompress the external initramfs file into the root file system according to the starting address; A determination module, used for determining the reason for the decompression failure according to the comparison result between the hash value of the external initramfs file and the expected hash value after determining that the external initramfs file cannot be decompressed normally; The reporting module is used to report the decompression failure problem to the corresponding processing object according to the decompression failure reason.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Disk data protection method and system and related components

    CN110188555A

  • Offline authentication system and method thereof

    CN110324315A

  • Security analysis method for firmware of embedded equipment

    CN111428233A

  • Loading method and device of virtual machine monitor and electronic equipment

    CN111966470A

  • Fast and safe starting method, device and equipment based on heterogeneous multi-core system and medium

    CN118626155A

Cited By

  • Method and equipment for detecting and repairing glibc damage in Linux system

    CN121807612A

  • Method and device for detecting and repairing glibc corruption in a linux system

    CN121807612B

  • Abnormal startup processing method and apparatus for operating system, and device, medium and program

    WO2026179338A1