Driver adaptation method, device and electronic device for operating system kernel upgrade
Before upgrading the operating system kernel, the target file generated by the source code compiled by the driver is added to the system directory, and the core technology leakage problem caused by providing source code in the existing technology is solved, and the kernel and driver adaptation is achieved and technical leakage is avoided.
Patent Information
- Application Number
- CN202010599428.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-28
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2040-06-28
AI Technical Summary
The existing methods can provide the source code of the driver to realize the adaptation of the kernel and driver after the operating system kernel is upgraded, which can easily lead to core technology leakage.
Before upgrading the operating system kernel, add the target file (intermediate file that is not linked) generated by the driver's source code compilation to the system directory, so that the driver file is generated through the target file during kernel upgrade.
By adding compiled intermediate files to the system directory instead of source code, the leakage of core technologies is avoided and the adaptation between the kernel and drivers is achieved.
Smart Images

Figure CN113849202B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer driver adaptation, and in particular to a driver adaptation method, device and electronic equipment for operating system kernel upgrade. Background Art
[0002] After the kernel of the operating system is upgraded, the driver that is compatible with the original kernel of the operating system may not be compatible with the upgraded kernel. Therefore, after the kernel of the operating system is upgraded, it is necessary to recompile and generate a driver that is compatible with the upgraded kernel. Usually, the source code of the driver that is compatible with the upgraded kernel is copied to the system directory of the operating system. During the kernel upgrade process, the source code of the driver is compiled through the DKMS (Dynamic Kernel Module Support) tool to generate a driver that is compatible with the upgraded kernel.
[0003] However, source code is the core technology of an enterprise, and providing source code means that the technology is completely open. Source code is usually the core technology and competitiveness of a software company, and the leakage of source code may cause immeasurable losses to the company.
[0004] It can be seen that the existing method realizes the adaptation of the upgraded kernel and the driver by providing the source code of the driver, which is easy to cause the leakage of core technology. Summary of the invention
[0005] The embodiments of the present invention provide a driver adaptation method, device and electronic device for operating system kernel upgrade, so as to solve the problem that the existing method realizes the adaptation of the kernel and the driver after the upgrade by providing the source code of the driver, which easily causes the leakage of core technology.
[0006] In view of the above technical problems, in a first aspect, an embodiment of the present invention provides a driver adaptation method for operating system kernel upgrade, comprising:
[0007] Obtaining a target file, wherein the target file is an intermediate file generated by compiling the source code of the driver without linking; wherein the driver is adapted to the kernel to be upgraded in the operating system;
[0008] The target file is added to the system directory of the operating system so that when the kernel is upgraded, a driver file of the driver is generated according to the target file; the driver file is an executable file generated by linking the target file.
[0009] Optionally, the adding the target file to the system directory of the operating system so as to generate a driver file of the driver according to the target file when the kernel is upgraded includes:
[0010] The target file is packaged to obtain a preset type file, and a read instruction for reading the target file from the preset type file is generated; the file suffix of the preset type file is different from the file suffix of the target file;
[0011] Adding the preset type file to the system directory of the operating system, and adding the read instruction to a configuration file containing a link instruction in the system directory, so that when the kernel is upgraded, the target file is read according to the read instruction, and the driver file is generated according to the link instruction;
[0012] The link instruction is used to link the target file.
[0013] Optionally, packaging the target file to obtain a preset type file, and generating a read instruction for reading the target file from the preset type file includes:
[0014] The target file is packaged and compressed, the compressed file is used as the preset type file, and a read instruction is generated for decompressing the preset type file and reading the target file from the decompressed file.
[0015] Optionally, it also includes:
[0016] A deletion instruction is added to the configuration file, and the deletion instruction is used to delete the driver file of the original driver that is not compatible with the operating system after the linking of the target file is completed.
[0017] Optionally, it also includes:
[0018] Adding driver information of the driver to the configuration file;
[0019] The driver information includes the version number and driver name of the driver.
[0020] Optionally, it also includes:
[0021] After the kernel upgrade is completed, it is determined according to the system log whether the driver is successfully loaded by the kernel. If not, a prompt message indicating that the driver fails to adapt to the kernel is issued.
[0022] Optionally, obtaining the target file includes:
[0023] When the kernel is detected to be upgraded, acquiring the stored target file;
[0024] The target file is generated in advance in a compiling environment created according to the operating system.
[0025] In a second aspect, an embodiment of the present invention provides a driver adaptation device for upgrading an operating system kernel, including:
[0026] An acquisition module, used to acquire a target file, wherein the target file is an intermediate file generated by compiling the source code of the driver without linking; wherein the driver is adapted to the kernel to be upgraded in the operating system;
[0027] An adding module is used to add the target file to the system directory of the operating system so that when the kernel is upgraded, a driver file of the driver is generated according to the target file; the driver file is an executable file generated by linking the target file.
[0028] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the driver adaptation method for upgrading the operating system kernel described above when executing the program.
[0029] In a fourth aspect, an embodiment of the present invention provides a non-transitory readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the driver adaptation method for upgrading the operating system kernel as described in any one of the above items.
[0030] The embodiment of the present invention provides a driver adaptation method, device and electronic device for upgrading the kernel of an operating system. Before upgrading the driver, the target file generated by compiling the source code of the driver and not linking is added to the system directory, so that when the kernel is upgraded, the driver file of the driver is generated by linking the target file. Since what is added to the system directory is the intermediate file generated after compiling the source code, not the source code itself, the leakage of core technology is avoided. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the embodiments of the present invention 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, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0032] Figure 1 It is a flowchart of a driver adaptation method for operating system kernel upgrade provided by an embodiment of the present invention;
[0033] Figure 2 is a structural block diagram of a driver adapter device for operating system kernel upgrade provided by another embodiment of the present invention;
[0034] Figure 3It is a schematic diagram of the physical structure of an electronic device provided by another embodiment of the present invention. DETAILED DESCRIPTION
[0035] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0036] In contrast, the existing implementation of driver adaptation during kernel upgrade generally includes the following process:
[0037] Copy the driver source code to the system directory of the operating system and edit the configuration file dkms.conf;
[0038] Execute the DKMS driver module add command (dkms add) to add the above driver source code to the DKMS driver code management structure; and check its status through the DKMS management module to see that it is in the new status;
[0039] Execute the compiled driver code; compile the driver file according to the driver source code (the Linux kernel driver module files are all ELF format files ending with .ko);
[0040] Check the DKMS management module to see that the status is compiled.
[0041] Execute the DKMS driver module installation and deployment command (dkms install) to install and deploy the driver module file into the current operating system;
[0042] After the operating system restarts, the compiled driver module file will be automatically loaded by the operating system. At this point, the entire driver module has been adapted and deployed using DKMS.
[0043] The above process is implemented by compiling the source code of the driver when the kernel and the driver are adapted through DKMS, which is easy to cause the leakage of core technology. In order to solve this technical problem, the present application provides a driver adaptation method for operating system kernel upgrade, which can be executed by a third-party application that provides a driver for operating system kernel upgrade, or implemented through manual intervention.
[0044] Figure 1 For a flow chart of the driver adaptation method for operating system kernel upgrade provided in this embodiment, see Figure 1 , the method comprising:
[0045] Step 101: Obtain a target file, where the target file is an intermediate file generated by compiling the source code of the driver without linking; wherein the driver is adapted to the kernel to be upgraded in the operating system.
[0046] It should be noted that the process of compiling source code to generate an executable file requires two processes: compilation and linking. Compilation is used to convert source code into binary form, and linking is used to combine the compiled binary file with the components of the operating system. The driver source code can only generate an executable file after compilation and linking. The driver is a binary executable file that can work in the Linux kernel, and its format is ELF.
[0047] The target file can be generated by compiling the source code of the driver in a compilation environment, and the compilation environment is generated according to the operating system. After the target file is generated in the compilation environment, the driver adaptation for the operating system kernel upgrade can be implemented in the following two ways: the first way: the third-party software obtains and stores the target file. When the third-party software is installed in the operating system, if the kernel upgrade of the operating system is detected, the target file is obtained and added to the system directory of the operating system to implement the driver adaptation for the operating system kernel upgrade. The second way: manually copy the target file to the system directory of the operating system to implement the driver adaptation for the operating system kernel upgrade.
[0048] Step 102: Add the target file to the system directory of the operating system, so that when the kernel is upgraded, a driver file of the driver is generated according to the target file; the driver file is an executable file generated by linking the target file.
[0049] It should be noted that in the first manner described above, after obtaining authorization from the operating system developer, the third-party software can execute instructions to copy the target file to the system directory of the operating system when the operating system kernel upgrade is detected. In the second manner described above, after obtaining authorization from the operating system developer, the target file can be manually copied to the system directory of the operating system. This embodiment does not impose specific restrictions on this.
[0050] Taking the process of implementing driver adaptation for Linux kernel upgrade as an example, the target file is a file with the suffix .o generated by compiling the driver source code, and the driver file is a file with the suffix .ko generated by linking the target file. It can be seen that for Linux kernel upgrade, it is only necessary to recompile the driver based on the original logic and store the .o compiled according to the driver source code in the system directory. The original upgrade process is slightly changed and easy to implement.
[0051] Wherein, in the / usr / src directory of the system directory, a directory / usr / src / A named after the driver (assuming the name of the driver is A) is created, and the target file is added to the directory / usr / src / A.
[0052] In the process of kernel upgrade of the operating system, the link process of the target file is realized by DKMS, and then the driver file is generated. In the process of kernel upgrade of the operating system, DKMS (Dynamic Kernel Module Support) is used to maintain the tool of the driver outside the kernel. After the kernel version changes, the original driver module will not be able to adapt to the new kernel. At this time, DKMS can be recompiled to generate a new driver module, and the new driver module can adapt to the new kernel, so as to achieve the adaptation of the kernel and the driver. For the operating system with DKMS installed, when the kernel is upgraded, DKMS will recompile and generate a new driver module. The process of DKMS recompiling and generating a new driver module needs to call the driver-related files stored in the system directory. In the scheme provided in this embodiment, the target file generated by compiling the source code of the driver is stored in the system directory. When the kernel is upgraded, DKMS can directly make the driver and the kernel adapt after the kernel upgrade according to the target file in the system directory. At the same time, the target file is stored in the system directory instead of the source code of the driver, which also avoids the technical leakage caused by the source code.
[0053] This embodiment provides a driver adaptation method for operating system kernel upgrade. Before the driver is upgraded, the target file generated by compiling the source code of the driver but not linking is added to the system directory, so that when the kernel is upgraded, the driver file of the driver is generated by linking the target file. Since what is added to the system directory is the intermediate file generated after the source code is compiled, not the source code itself, the leakage of core technology is avoided.
[0054] Due to the kernel upgrade process, the intermediate files (for example, files with .o as the suffix) generated in the system directory will be cleaned up. In order to ensure that the target files added to the system directory are not cleaned up, further, based on the above embodiment, the target files are added to the system directory of the operating system so that when the kernel is upgraded, the driver file of the driver is generated according to the target files, including:
[0055] The target file is packaged to obtain a preset type file, and a read instruction for reading the target file from the preset type file is generated; the file suffix of the preset type file is different from the file suffix of the target file;
[0056] Adding the preset type file to the system directory of the operating system, and adding the read instruction to a configuration file containing a link instruction in the system directory, so that when the kernel is upgraded, the target file is read according to the read instruction, and the driver file is generated according to the link instruction;
[0057] The link instruction is used to link the target file.
[0058] Among them, the target file is packaged by calling a packaging tool to obtain the preset type file. Because when the kernel is upgraded, the driver-related files stored in the system directory will be cleaned up first, that is, the files related to the original driver will be cleaned up. The files related to the original driver include files with the same format as the above-mentioned target files. Therefore, in order to avoid the files added to the system directory from being cleaned up, the target files need to be packaged into files with a different file format from the original driver-related files. For example, taking the process of implementing driver adaptation for Linux kernel upgrade as an example, the files related to the original driver include files with a suffix of .o. Therefore, in order to avoid the files added to the system directory from being cleaned up, this embodiment packages the files added to the system directory into files without a suffix of .o.
[0059] It is understandable that in order for DKMS to read the target file during the process of recompiling the driver, it is also necessary to add relevant read instructions in the DKMS configuration file (i.e., the dkms.conf file). The read instructions are used to instruct DKMS to read the target file from the packaged preset type file when compiling the driver, so as to achieve adaptation between the kernel and the driver.
[0060] Specifically, during the kernel upgrade process, the intermediate files in the system directory (for example, files with the suffix .o) will be cleaned up. In order to avoid the target files added to the system directory from being cleaned up, this embodiment will package the target files generated according to the source code. The preset file type after packaging does not have the suffix .o, so it will not be cleaned up, thereby successfully adding the target files to the system directory.
[0061] In order to successfully read the target file from the preset type file during the kernel upgrade process, this embodiment adds a read instruction to the configuration file, so that during the kernel upgrade process, the target file is read through the read instruction, thereby realizing the process of linking the target file. For example, for an operating system with DKMS installed, DKMS reads driver-related files in the system directory through the configuration file to achieve the adaptation of the kernel and the driver. The configuration file in DKMS is the dkms.conf file. Therefore, in the solution provided by this embodiment, in order to read the target file added to the system directory and achieve the adaptation of the kernel and the driver, a read instruction can be added to the dkms.conf file. It can be seen that based on the original logic of DKMS for driver compilation, the adaptation of the kernel and the driver based on the target file can be achieved through minor improvements, which is easy to implement.
[0062] The method further includes adding the configuration file to the directory / usr / src / A.
[0063] In the operating system, during the kernel upgrade process, the target file is added to the DKMS driver code management structure through DKMS, and the read instructions and link instructions in the dkms.conf file are executed through DKMS to link each target file to generate a driver file.
[0064] In the process of adding the target file to the system directory, this embodiment packages the target file into a preset type file by packaging. Since the preset type file is not a file with a .o suffix, it can avoid cleaning the target file during the kernel upgrade process. At the same time, by adding a read instruction in the configuration file, the target file is read during the kernel upgrade process.
[0065] In order to save resources occupied by the target file and to more conveniently encapsulate the target file into a file not having a .o suffix, further, on the basis of the above embodiments, the target file is packaged to obtain a preset type file, and a read instruction for reading the target file from the preset type file is generated, including:
[0066] The target file is packaged and compressed, the compressed file is used as the preset type file, and a read instruction is generated for decompressing the preset type file and reading the target file from the decompressed file.
[0067] The tar command is a commonly used decompression and compression command in Linux. In order to facilitate the generation and execution of commands in the compression and decompression process, the preset type file in this embodiment is a file with a .tar suffix. The target file is packaged and compressed by the tar program to obtain the preset type file. It can be seen that since the tar command is a commonly used compression command in Linux, when the preset type file is a file with a .tar suffix, the compression process can be achieved only by calling the tar command, and the implementation method is simple and effective.
[0068] For an operating system with DKMS installed, since the target files in the system directory are compressed using tar, in order to decompress the .tar file, when the preset type file is a compressed file, the read instruction can be tar–xvf A.tar. A is the driver name of the driver. The decompression command also uses the tar command, which matches the above compression command to achieve decompression of the target file.
[0069] This embodiment compresses the target file, which not only saves the resource occupation of the target file, but also packs the target file in a file that does not have a .o suffix in a relatively simple way, thereby avoiding the target file from being cleaned up during the kernel upgrade process.
[0070] Furthermore, based on the above embodiments, it also includes:
[0071] A deletion instruction is added to the configuration file, and the deletion instruction is used to delete the driver file of the original driver that is not compatible with the operating system after the linking of the target file is completed.
[0072] After completing the link to the target file, this embodiment automatically deletes the driver file of the original driver, and there is no need to upgrade the original driver, thus avoiding the workload caused by the upgrade.
[0073] Furthermore, based on the above embodiments, it also includes:
[0074] Adding driver information of the driver to the configuration file;
[0075] The driver information includes the version number and driver name of the driver.
[0076] The driver information may also include driver working path, installation options and other information.
[0077] In order to distinguish different versions of the driver, driver information is set for each driver so that the driver can be found through the driver information.
[0078] This implementation adds driver information to the configuration file to facilitate driver search.
[0079] Furthermore, based on the above embodiments, it also includes:
[0080] After the kernel upgrade is completed, it is determined according to the system log whether the driver is successfully loaded by the kernel. If not, a prompt message indicating that the driver fails to adapt to the kernel is issued.
[0081] These may also include:
[0082] If it is determined according to the system log that the driver is successfully loaded by the kernel, a prompt message indicating that the driver is successfully adapted to the kernel is issued.
[0083] These may also include:
[0084] If the driver fails to adapt to the kernel, the above steps 101 and 102 are executed again.
[0085] This embodiment uses the system log to determine whether the kernel is compatible with the driver after the upgrade, so that timely measures can be taken in the event of adaptation failure.
[0086] It should be noted that when the methods provided in the above embodiments are implemented through manual access, the generated preset type file .tar can be manually copied to the system directory / usr / src / A, and the generated configuration file dkms.conf containing the read instruction tar–xvf A.tar can also be copied to the system directory / usr / src / A.
[0087] When the methods provided in the above embodiments are executed by a third-party application that provides a driver for the operating system kernel upgrade, further, based on the above embodiments, the step of obtaining the target file includes:
[0088] When the kernel is detected to be upgraded, acquiring the stored target file;
[0089] The target file is generated in advance in a compiling environment created according to the operating system.
[0090] Specifically, the third-party application obtains and stores the target file in the compilation environment in advance. When the installed third-party application detects an upgrade to the kernel, it obtains the target file, packages and compresses the target file into a preset type file .tar, adds the preset type file .tar to the system directory / usr / src / A, and also adds the generated configuration file dkms.conf containing the read instruction tar–xvf A.tar to the system directory / usr / src / A.
[0091] This implementation automatically adds the target file to the system directory when a kernel upgrade is detected by a third-party application, so that the driver adapted to the kernel can be loaded after the kernel upgrade.
[0092] Specifically, the process of obtaining the target file and deploying the target file can be achieved through the following steps (assuming the driver name is A):
[0093] (1) Copy the driver code named A to the compilation environment, put it in the compilation directory D, and execute the compilation.
[0094] (2) After the compilation is completed, delete the source code file, the generated driver file A.ko, and the corresponding driver target file A.mod.o; only keep the compiled target file .o.
[0095] (3) Package the target file .o generated in step (3) to generate a compressed package file A.tar.
[0096] (4) Create a file named dkms.conf in directory D and add dkms-related compilation instructions (dkms-related compilation instructions include instructions for reading the target file from the A.tar compressed package file);
[0097] The read instruction is tar–xvf A.tar, which is used to decompress the compressed package file A.tar generated in step (3), thereby releasing the corresponding target file for subsequent compilation and linking.
[0098] (5) Create a directory / usr / src / A named after the driver A in the / usr / src directory of the current operating system, and copy the A.tar and dkms.conf files generated in step (4) to the / usr / src / A directory of the system; you can also set the driver version number, driver name, driver module working path, installation options and other configuration information in the dkms.conf file;
[0099] (6) Execute the relevant instructions of DKMS (add, install, etc.) to add driver A to the driver code management structure of DKMS. The required driver files will be automatically generated when the operating system kernel is upgraded later.
[0100] Step (6) specifically includes:
[0101] Execute the DKMS driver add command (dkms add) to add the driver's target file to the DKMS driver code management structure; and check the driver's status through the DKMS management module to see that it is compiled;
[0102] Execute the DKMS driver module installation and deployment instruction (dkms install) to install and deploy the driver module file into the current operating system; after the operating system restarts, the compiled driver module file will be automatically loaded by the operating system, realizing the process of adaptation and deployment using DKMS.
[0103] In addition, DKMS can also provide the function of building software packages for different platforms. After compilation is completed, it can generate corresponding DEB and RPM software packages according to user needs for user convenience.
[0104] The driver adaptation method for operating system kernel upgrade provided in this embodiment does not provide source code during actual deployment, but only provides the target file generated during the compilation process, thereby effectively avoiding the risk of source code leakage caused by providing source code.
[0105] Figure 2 For a structural block diagram of the driver adapter device for upgrading the operating system kernel provided in this embodiment, see Figure 2 The device includes an acquisition module 201 and an adding module 202, wherein:
[0106] The acquisition module 201 is used to acquire a target file, wherein the target file is an intermediate file generated by compiling the source code of the driver without linking; wherein the driver is adapted to the kernel to be upgraded in the operating system;
[0107] The adding module 202 is used to add the target file to the system directory of the operating system so as to generate a driver file of the driver according to the target file when the kernel is upgraded; the driver file is an executable file generated by linking the target file.
[0108] The driver adaptation device for operating system kernel upgrade provided in this embodiment is applicable to the driver adaptation method for operating system kernel upgrade provided in the above embodiments, which will not be described in detail here.
[0109] This embodiment provides a driver adapter device for upgrading the kernel of an operating system. Before upgrading the driver, the target file generated by compiling the source code of the driver but not linking is added to the system directory, so that when the kernel is upgraded, the driver file of the driver is generated by linking the target file. Since what is added to the system directory is the intermediate file generated after compiling the source code, not the source code itself, the leakage of core technology is avoided.
[0110] Optionally, the adding the target file to the system directory of the operating system so as to generate a driver file of the driver according to the target file when the kernel is upgraded includes:
[0111] The target file is packaged to obtain a preset type file, and a read instruction for reading the target file from the preset type file is generated; the file suffix of the preset type file is different from the file suffix of the target file;
[0112] Adding the preset type file to the system directory of the operating system, and adding the read instruction to a configuration file containing a link instruction in the system directory, so that when the kernel is upgraded, the target file is read according to the read instruction, and the driver file is generated according to the link instruction;
[0113] The link instruction is used to link the target file.
[0114] Optionally, packaging the target file to obtain a preset type file, and generating a read instruction for reading the target file from the preset type file includes:
[0115] The target file is packaged and compressed, the compressed file is used as the preset type file, and a read instruction is generated for decompressing the preset type file and reading the target file from the decompressed file.
[0116] Optionally, it also includes:
[0117] A deletion instruction is added to the configuration file, and the deletion instruction is used to delete the driver file of the original driver that is not compatible with the operating system after the linking of the target file is completed.
[0118] Optionally, it also includes:
[0119] Adding driver information of the driver to the configuration file;
[0120] The driver information includes the version number and driver name of the driver.
[0121] Optionally, it also includes:
[0122] After the kernel upgrade is completed, it is determined according to the system log whether the driver is successfully loaded by the kernel. If not, a prompt message indicating that the driver fails to adapt to the kernel is issued.
[0123] Optionally, obtaining the target file includes:
[0124] When the kernel is detected to be upgraded, acquiring the stored target file;
[0125] The target file is generated in advance in a compiling environment created according to the operating system.
[0126] Figure 3 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 3 As shown, the electronic device may include: a processor (processor) 301, a communication interface (Communications Interface) 302, a memory (memory) 303 and a communication bus 304, wherein the processor 301, the communication interface 302, and the memory 303 complete mutual communication through the communication bus 304. The processor 301 may call the logic instructions in the memory 303 to execute the following method: obtain a target file, wherein the target file is an intermediate file generated by compiling the source code of the driver and not linking; wherein the driver is adapted to the kernel to be upgraded in the operating system; add the target file to the system directory of the operating system, so that when the kernel is upgraded, the driver file of the driver is generated according to the target file; the driver file is an executable file generated by linking the target file.
[0127] In addition, the logic instructions in the above-mentioned memory 303 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0128] Furthermore, an embodiment of the present invention discloses a computer program product, which includes a computer program stored on a non-transitory readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the methods provided by the above-mentioned method embodiments, for example, including: obtaining a target file, the target file is an intermediate file generated by compiling the source code of the driver and not linking; wherein the driver is adapted to the kernel to be upgraded in the operating system; adding the target file to the system directory of the operating system, so as to generate a driver file of the driver according to the target file when the kernel is upgraded; the driver file is an executable file generated by linking the target file.
[0129] On the other hand, an embodiment of the present invention further provides a non-transitory readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the transmission methods provided in the above-mentioned embodiments, for example, including: obtaining a target file, wherein the target file is an intermediate file generated by compiling the source code of the driver and not linking; wherein the driver is adapted to the kernel to be upgraded in the operating system; adding the target file to the system directory of the operating system, so as to generate a driver file of the driver according to the target file when the kernel is upgraded; the driver file is an executable file generated by linking the target file.
[0130] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0131] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0132] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A driver adaptation method for operating system kernel upgrade, characterized in that: Used to compile source code to generate an executable file, including two processes: compiling and linking. The compiling is used to convert the source code into a binary form, and the linking is used to combine the compiled binary file with the components of the operating system; The method comprises: Obtaining a target file, wherein the target file is an intermediate file generated by compiling the source code of the driver without linking; wherein the driver is adapted to the kernel to be upgraded in the operating system; The target file is added to the system directory of the operating system so that when the kernel is upgraded, a driver file of the driver is generated according to the target file; the driver file is an executable file generated by linking the target file.
2. The driver adaptation method for operating system kernel upgrade according to claim 1, characterized in that: The step of adding the target file to the system directory of the operating system so as to generate a driver file of the driver according to the target file when the kernel is upgraded includes: The target file is packaged to obtain a preset type file, and a read instruction for reading the target file from the preset type file is generated; the file suffix of the preset type file is different from the file suffix of the target file; Adding the preset type file to the system directory of the operating system, and adding the read instruction to a configuration file containing a link instruction in the system directory, so that when the kernel is upgraded, the target file is read according to the read instruction, and the driver file is generated according to the link instruction; The link instruction is used to link the target file.
3. The driver adaptation method for operating system kernel upgrade according to claim 2, characterized in that: The step of packaging the target file to obtain a preset type file and generating a read instruction for reading the target file from the preset type file includes: The target file is packaged and compressed, the compressed file is used as the preset type file, and a read instruction is generated for decompressing the preset type file and reading the target file from the decompressed file.
4. The driver adaptation method for operating system kernel upgrade according to claim 2, characterized in that: Also includes: A deletion instruction is added to the configuration file, and the deletion instruction is used to delete the driver file of the original driver that is not compatible with the operating system after the linking of the target file is completed.
5. The driver adaptation method for operating system kernel upgrade according to claim 2, characterized in that: Also includes: Adding driver information of the driver to the configuration file; The driver information includes the version number and driver name of the driver.
6. The driver adaptation method for operating system kernel upgrade according to claim 1, characterized in that: Also includes: After the kernel upgrade is completed, it is determined according to the system log whether the driver is successfully loaded by the kernel. If not, a prompt message indicating that the driver fails to adapt to the kernel is issued.
7. The driver adaptation method for operating system kernel upgrade according to claim 1, characterized in that: The obtaining of the target file comprises: When an upgrade of the kernel is detected, obtaining the stored target file; The target file is generated in advance in a compiling environment created according to the operating system.
8. A driver adapter device for upgrading an operating system kernel, characterized in that: Used to compile source code to generate an executable file, including two processes: compilation and linking. The compilation is used to convert the source code into a binary form, and the linking is used to combine the compiled binary file with the components of the operating system. The device includes: An acquisition module, used to acquire a target file, wherein the target file is an intermediate file generated by compiling the source code of the driver without linking; wherein the driver is adapted to the kernel to be upgraded in the operating system; An adding module is used to add the target file to the system directory of the operating system so that when the kernel is upgraded, a driver file of the driver is generated according to the target file; the driver file is an executable file generated by linking the target file.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the driver adaptation method for upgrading the operating system kernel as described in any one of claims 1 to 7 are implemented.
10. A non-transitory 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 driver adaptation method for upgrading the operating system kernel as described in any one of claims 1 to 7 are implemented.
11. A computer program, characterized in that When the computer program is executed by a processor, the steps of the driver adaptation method for upgrading the operating system kernel as described in any one of claims 1 to 7 are implemented.