System access method, device, electronic device and storage medium
Through the combination of a general programming interface and a driver adaptation module, the driver adaptation between different Linux system versions is achieved, which solves the driver development complexity and kernel stability problems caused by changes in the kernel programming interface, and improves the driver adaptation Efficiency and stability of distribution.
Patent Information
- Application Number
- CN202011560230.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-25
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2040-12-25
AI Technical Summary
In the prior art, changes in the Linux system version lead to changes in the kernel programming interface and symbols, which leads to the driver need to adapt to different versions, which increases the workload of driver development, and forcibly binding symbol pointers may cause kernel crashes and the kernel cannot be implemented. Common access to structure member variables.
Provide a driver adapter device and method, write a driver through a general programming interface, convert access requests into target access requests that are adapted to different system versions, and load the drivers into the system through a driver loader. In kernel space, preset conversion programs are used to implement the conversion between the general programming interface and the kernel programming interface.
It implements a general driver that can be adapted to different versions of Linux systems, reducing the cost and time of driver development, avoiding the risk of kernel crashes, and improving the adaptation efficiency of drivers.
Smart Images

Figure CN114691198B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer systems, and in particular to a system access method, device, electronic equipment and storage medium. Background Art
[0002] For computer systems such as Linux systems, as the system version changes, the programming interface and kernel symbols provided by its kernel are also constantly changing. In order to ensure the adaptation of the driver, the kernel adds a version control mechanism, so that the compiled driver needs to fully match the current kernel version before it is allowed to be loaded and used, and: different Linux versions need to write corresponding driver adaptations, resulting in a large workload for driver development. In the prior art, although the kernel symbols that access kernel resources in the driver can be defined as pointers, and these pointers are re-pointed to the real kernel symbols when the driver is initialized, if the definition of the kernel symbol changes and the symbol pointer is forcibly bound, it will cause the kernel to crash. In addition, the scheme cannot achieve universal access to the member variables of the kernel structure. Summary of the invention
[0003] In view of the problems in the prior art, embodiments of the present invention provide a system access method, device, electronic device and storage medium.
[0004] Specifically, the embodiment of the present invention provides the following technical solutions:
[0005] In a first aspect, an embodiment of the present invention provides a drive adapter device, comprising:
[0006] A driver interaction interface, used to receive an access request for accessing system resources sent by a driver, and forward a target execution result to the driver, wherein the driver is written using a general programming interface and is pre-loaded into the system;
[0007] A driver adaptation module, configured to convert the access request into a target access request adapted to the system version based on the system version of the system, and convert an execution result of the system processing the target access request into the target execution result adapted to the driver program;
[0008] The system interaction interface is used to forward the target access request to the system and receive the execution result of the system processing the target access request.
[0009] Furthermore, the drive adaptation module is specifically used to:
[0010] According to the system version, a target conversion program is called from preset conversion programs corresponding to multiple system versions one by one, so as to realize the conversion of the access request from the general programming interface used by the driving system to the programming interface provided by the kernel of the system through the target conversion program.
[0011] In a second aspect, an embodiment of the present invention provides a method for accessing a system, including:
[0012] Receiving an access request for accessing a system resource sent by a driver, wherein the driver is written using a universal programming interface and is pre-loaded into the system;
[0013] Based on the system version of the system, converting the access request into a target access request adapted to the system version, and forwarding the target access request to the system;
[0014] An execution result of the system processing the target access request is received, the execution result is converted into a target execution result adapted to the driver, and the target execution result is forwarded to the driver.
[0015] Furthermore, before receiving the access request for accessing the system resources sent by the driver, the method further includes the step of loading the driver into the system, which specifically includes:
[0016] When it is determined that the driver is valid, the driver is loaded into the system and a code area and a data area of the driver are laid out in the kernel space of the system;
[0017] The code and data of the driver are loaded into the code area and the data area respectively, and the universal programming interface used by the driver is linked and adapted so that the driver can access the system resources through the universal programming interface used by the driver.
[0018] Furthermore, before the driver is loaded into the system, the method further includes:
[0019] The driver program is compiled to obtain a driver program file so as to load the driver program file into the kernel space of the system.
[0020] Further, the converting the access request into a target access request adapted to the system version based on the system version of the system includes:
[0021] According to the system version, a target conversion program is called from preset conversion programs corresponding to multiple system versions one by one, so as to realize the conversion of the access request from the general programming interface used by the driving system to the programming interface provided by the kernel of the system through the target conversion program.
[0022] Furthermore, it also includes:
[0023] Obtain programming interfaces provided by the kernels of multiple system versions;
[0024] The general programming interface is generated based on the programming interfaces provided by the kernels of the systems of the multiple system versions, and the conversion program between the general programming interface and the programming interface is one-to-one corresponding.
[0025] Furthermore, the system is a Linux system.
[0026] In a third aspect, an embodiment of the present invention further provides a system access device, including:
[0027] A driver loader, used for loading a driver into the system;
[0028] An adapter is used to receive an access request for accessing system resources sent by the driver, and based on the system version of the system, convert the access request into a target access request adapted to the system version, and forward the target access request to the system, and receive an execution result of the system processing the target access request, and convert the execution result into a target execution result adapted to the driver, and forward the target execution result to the driver.
[0029] In a fourth aspect, an embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the system access method described in the first aspect are implemented.
[0030] In a fifth aspect, an embodiment of the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the system access method as described in the first aspect.
[0031] In a sixth aspect, an embodiment of the present invention further provides a computer program product, the computer program product comprising a computer program, which, when executed by a processor, implements the steps of the system access method as described in the first aspect.
[0032] It can be seen from the above technical solution that the system access method, device, electronic device and storage medium provided in the embodiments of the present invention can, after writing a universal driver program using a unified universal programming interface, enable the universal driver program to be loaded and adapted to different versions of systems for use through a pre-set set of adaptation processes. There is no need to write multiple adapted drivers for different versions of systems, thereby reducing the development cost of the driver program and saving the development time of the driver program. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] 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.
[0034] Figure 1 A flowchart of a method for accessing a system provided by an embodiment of the present invention;
[0035] Figure 2 A flowchart of a driver loading method for accessing a system provided by an embodiment of the present invention;
[0036] Figure 3 A flowchart of a driver accessing a system kernel resource of a system access method provided by an embodiment of the present invention;
[0037] Figure 4 A communication interaction diagram of a method for accessing a system provided by an embodiment of the present invention;
[0038] Figure 5 A structural block diagram of an access device of a system provided by an embodiment of the present invention;
[0039] Figure 6 A structural block diagram of a drive adapter device provided by an embodiment of the present invention;
[0040] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0041] 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.
[0042] Figure 1 FIG. 1 is a flow chart showing a method for accessing a system provided by an embodiment of the present invention. Figure 1 As shown, the system access method provided by the embodiment of the present invention includes the following steps:
[0043] Step 101: Receive an access request for accessing system resources sent by a driver, wherein the driver is written through a universal programming interface and pre-loaded into the system. In one embodiment of the present invention, step 101 can be performed by a pre-designed driver adapter (referred to as the adapter), wherein the driver adapter is a unified resource access interface provided to the driver, and can handle the differences between different system versions, and use resource forwarding to ensure that the driver itself is universal.
[0044] In a specific example of the present invention, the driver is written using a pre-provided universal programming interface, and the universal programming interface can be pre-defined. Taking the Linux system as an example, generally speaking, different versions of the Linux system have different programming interfaces and kernel symbols provided by the system kernel. Therefore, the differences in programming interfaces and kernel symbols of different versions of Linux can be analyzed and sorted out, and then, based on the differences in programming interfaces and kernel symbols of different versions of Linux, a set of unified universal programming interfaces can be abstracted and defined. In this way, the driver program of the Linux system can be written based on this set of unified universal programming interfaces, that is, for different versions of the Linux system, the kernel resources of the system can be accessed through the driver program written by this set of unified universal programming interfaces.
[0045] In the prior art, due to the differences in programming interfaces provided by the system kernels of different versions of Linux systems, it is necessary to write drivers based on the programming interfaces provided by the system kernels of different versions of Linux systems. When there are many versions of Linux systems, it is necessary to write many drivers, which obviously has high resource and labor costs. However, in the embodiments of the invention, there is no need to pay attention to the version of the Linux system, and it is only necessary to write a driver through a set of unified general programming interfaces provided, thereby significantly improving resource and labor costs.
[0046] As a specific example, a driver needs to be loaded into the system. Also taking the Linux system as an example, in the prior art, since different versions of Linux systems use different drivers, the system kernel adds a version control mechanism, so that the compiled driver file needs to match the current system kernel version before it is allowed to be loaded and used, resulting in a large workload for driver development and adaptation. In this application, different from the loading method in the prior art, a driver can be loaded into the system kernel of different versions of Linux systems through a set of loading processes.
[0047] Specifically, if Figure 2 As shown, before receiving the access request for accessing system resources sent by the driver, the step of loading the driver into the system is included, specifically including: when it is determined that the driver is valid, loading the driver into the system and laying out the code area and data area of the driver in the kernel space of the system; loading the code and data of the driver into the code area and the data area respectively, and linking and adapting the universal programming interface used by the driver, so that the driver can access the system resources through the universal programming interface used by the driver. In other words, the loading process includes several steps, wherein step 1: judging whether the driver file is valid, if it is invalid, refusing to load, if it is valid, continuing the following process; step 2: loading the driver into the system according to the format of the driver file and laying out the code area and data area of the driver file in the system kernel space; step 3: linking the programming interface used in the driver file to the adapter, so that the driver file can call the system's resource access request through the adapter; step 4: calling the initialization function of the driver file, so that the driver file starts working.
[0048] In the above example, the loading of the driver program file may be performed by a preset driver loader.
[0049] In the above description, the driver program file is obtained by compiling the driver program. Therefore, in a specific example of the present invention, before loading the driver program into the system, it also includes: compiling the driver program to obtain the driver program file so as to load the driver program file into the kernel space of the system. The compilation work can be performed by a pre-set driver compilation system, that is, the driver compilation system can compile the driver program written using the general programming interface into a driver program file that can be loaded by the driver loader.
[0050] Step 102: Based on the system version of the system, convert the access request into a target access request adapted to the system version, and forward the target access request to the system.
[0051] Specifically, according to the system version, a target conversion program is called from the preset conversion programs corresponding to multiple system versions one by one, so as to realize the conversion of the access request from the general programming interface used by the driving system to the programming interface provided by the kernel of the system through the target conversion program. That is, the driver adapter can call the target conversion program from the preset conversion programs corresponding to multiple system versions one by one according to the system version, so as to realize the conversion of the access request from the general programming interface used by the driving system to the programming interface provided by the kernel of the system through the target conversion program.
[0052] The driver adapter needs to be designed in advance. Specifically, the programming interfaces provided by the kernels of the systems of multiple system versions can be obtained in advance; then, based on the programming interfaces provided by the kernels of the systems of the multiple system versions, the general programming interface is generated, and the conversion program between the general programming interface and the programming interface is one-to-one corresponding, thereby obtaining the driver adapter. Taking the Linux system as an example, assuming that there are 5 versions of the Linux system, the kernel of Linux system version 1 provides programming interface 1 for the driver program, the kernel of Linux system version 2 provides programming interface 2 for the driver program, the kernel of Linux system version 3 provides programming interface 3 for the driver program, the kernel of Linux system version 4 provides programming interface 4 for the driver program, and the kernel of Linux system version 5 provides programming interface 5 for the driver program. The programming interfaces corresponding to these 5 versions can be collected, and then, the programming interfaces corresponding to these 5 versions are respectively converted to the general programming interface and encapsulated into 5 conversion programs. Furthermore, based on the system version of the system, the access request can be converted into a target access request adapted to the system version, and the target access request can be forwarded to the system. For example: the detected Linux system version is Linux system version 1. At this time, the conversion program corresponding to Linux system version 1 can be called to realize the conversion between the general programming interface used by the driver and the programming interface provided by the kernel of Linux system version 1. Similarly, other versions of Linux systems only need to call the corresponding conversion program.
[0053] Step 103: receiving the execution result of the system processing the target access request, converting the execution result into a target execution result adapted to the driver, and forwarding the target execution result to the driver.
[0054] Specifically, if Figure 3As shown, the driver uses a universal driver request to access Linux kernel resources and submits an access request to the adapter; after receiving the request, the adapter converts the requested kernel resources into a resource format available to the current Linux version, and calls the Linux kernel function to complete the request forwarding process; the Linux kernel processes the request and returns the result of the resource request to the adapter; the adapter converts the result into a resource format recognizable by a universal driver and transfers it to the universal driver. As a result, only one driver needs to be written to adapt to multiple versions of Linux systems.
[0055] According to the system access method of the embodiment of the present invention, after a universal driver is written using a unified universal programming interface, a pre-set set of adaptation processes can be used to enable the universal driver to be loaded and adapted for use in systems of different versions. There is no need to write multiple adapted drivers for systems of different versions, thereby reducing the development cost of the driver and saving the development time of the driver.
[0056] In the above description, the communication relationship between the driver adapter, driver, driver loader and Linux kernel is as follows: Figure 4 As shown, namely: analyze and organize the differences between different Linux versions and abstract a unified driver development interface (i.e., universal programming interface), so that the written driver no longer relies on the unique programming interface of each Linux version; implement a driver compilation system to generate driver program files; implement the conversion relationship between the defined universal programming interface and the unique programming interface of different Linux versions on different Linux versions, and implement a driver adapter; implement a driver loader to load the driver program into the kernel; write the driver program using the universal programming interface; use the driver compilation system to compile the driver program into a driver program file; use the driver loader to load the driver program file into the Linux kernel space and link it to the driver adapter, so that the universal driver program can be loaded and adapted to different versions of the system through a pre-set set of adaptation processes, thereby improving the development efficiency of the driver program.
[0057] Figure 5 FIG. 1 is a schematic diagram showing the structure of an access device of a system provided by an embodiment of the present invention. Figure 5 As shown, the access device of the system provided in this embodiment includes: a driver loader 510 and an adapter 520, wherein:
[0058] A driver loader 510, used to load a driver into the system;
[0059] Adapter 520 is used to receive an access request for accessing system resources sent by the driver, and based on the system version of the system, convert the access request into a target access request adapted to the system version, and forward the target access request to the system, and receive the execution result of the system processing the target access request, and convert the execution result into a target execution result adapted to the driver, and forward the target execution result to the driver.
[0060] Based on the contents of the above embodiments, in this embodiment, the driver loader is used to, before receiving an access request for accessing system resources sent by a driver program, determine that the driver program is valid, load the driver program into the system and layout the code area and data area of the driver program in the kernel space of the system; load the code and data of the driver program into the code area and the data area respectively, and link and adapt the universal programming interface used by the driver program so that the driver program can access the system resources through the universal programming interface used by the driver program.
[0061] Based on the contents of the above embodiments, in this embodiment, it also includes: driving the compiler ( Figure 5 (not shown), the driver compiler is used to compile the driver program before the driver loader 510 loads the driver program into the system to obtain the driver program file so as to load the driver program file into the kernel space of the system.
[0062] Based on the contents of the above embodiments, in this embodiment, the adapter 520 is used to: call the target conversion program from the preset conversion programs corresponding to multiple system versions according to the system version, so as to realize the conversion of the access request from the general programming interface used by the driving system to the programming interface provided by the kernel of the system through the target conversion program.
[0063] Based on the contents of the above embodiments, in this embodiment, the adapter 520 is used to: obtain the programming interface provided by the kernel of the system of multiple system versions; generate the general programming interface based on the programming interface provided by the kernel of the system of the multiple system versions, and the conversion program between the general programming interface and the programming interface is one-to-one corresponding.
[0064] Based on the contents of the above embodiments, in this embodiment, the system is a Linux system.
[0065] According to the access device of the system of the embodiment of the present invention, after a universal driver is written using a unified universal programming interface, a pre-set adaptation process can be used to enable the universal driver to be loaded and adapted for use in systems of different versions. There is no need to write multiple adapted drivers for systems of different versions, thereby reducing the development cost of the driver and saving the development time of the driver.
[0066] Since the system access device provided in the embodiment of the present invention can be used to execute the system access method described in the above embodiment, its working principle and beneficial effects are similar, so they will not be described in detail here. For specific contents, please refer to the introduction of the above embodiment.
[0067] In this embodiment, it should be noted that the various modules in the device of the embodiment of the present invention can be integrated into one or deployed separately. The above modules can be combined into one module or further divided into multiple sub-modules.
[0068] like Figure 6 , which is a structural block diagram of a driver adapter device according to an embodiment of the present invention. The driver adapter device comprises: a driver program interaction interface 610, a driver adaptation module 620 and a system interaction interface 630, wherein:
[0069] A driver interaction interface 610, for receiving an access request for accessing system resources sent by a driver, and forwarding a target execution result to the driver, wherein the driver is written using a general programming interface and is pre-loaded into the system;
[0070] A driver adaptation module 620, configured to convert the access request into a target access request adapted to the system version based on the system version of the system, and convert the execution result of the system processing the target access request into the target execution result adapted to the driver;
[0071] The system interaction interface 630 is used to forward the target access request to the system and receive the execution result of the system processing the target access request.
[0072] In one embodiment of the present invention, the driver adaptation module 620 is specifically used to: call a target conversion program from preset conversion programs corresponding to multiple system versions according to the system version, so as to realize the conversion of the access request from the general programming interface used by the driver system to the programming interface provided by the kernel of the system through the target conversion program.
[0073] In the above embodiment, the specific function of the drive adapter device is similar to the function of the adapter 520 in the above embodiment. For the specific implementation process, please refer to the description of the adapter 520.
[0074] Based on the same inventive concept, another embodiment of the present invention provides an electronic device, see Figure 7 , the electronic device specifically includes the following contents: a processor 701, a memory 702, a communication interface 703 and a communication bus 704;
[0075] The processor 701, the memory 702, and the communication interface 703 communicate with each other via the communication bus 704;
[0076] The processor 701 is used to call the computer program in the memory 702, and when the processor executes the computer program, all steps of the access method of the above-mentioned system are implemented. For example, when the processor executes the computer program, the following process is implemented: receiving an access request for accessing system resources sent by a driver, wherein the driver is written through a universal programming interface and the driver is pre-loaded into the system; based on the system version of the system, converting the access request into a target access request adapted to the system version, and forwarding the target access request to the system; receiving the execution result of the system processing the target access request, and converting the execution result into a target execution result adapted to the driver, and forwarding the target execution result to the driver.
[0077] It can be understood that the detailed functions and extended functions that can be executed by the computer program can refer to the description of the above embodiments.
[0078] Based on the same inventive concept, another embodiment of the present invention provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, all steps of the access method of the above-mentioned system are implemented. For example, when the processor executes the computer program, the following process is implemented: receiving an access request for accessing system resources sent by a driver, wherein the driver is written through a general programming interface and is pre-loaded into the system; based on the system version of the system, converting the access request into a target access request adapted to the system version, and forwarding the target access request to the system; receiving the execution result of the system processing the target access request, and converting the execution result into a target execution result adapted to the driver, and forwarding the target execution result to the driver.
[0079] It can be understood that the detailed functions and extended functions that can be executed by the computer program can refer to the description of the above embodiments.
[0080] Based on the same inventive concept, another embodiment of the present invention provides a computer program product, which includes a computer program, which implements all steps of the access method of the above-mentioned system when executed by a processor. For example, when the processor executes the computer program, it implements the following process: receiving an access request for accessing system resources sent by a driver, wherein the driver is written through a general programming interface and is pre-loaded into the system; based on the system version of the system, converting the access request into a target access request adapted to the system version, and forwarding the target access request to the system; receiving the execution result of the system processing the target access request, and converting the execution result into a target execution result adapted to the driver, and forwarding the target execution result to the driver.
[0081] It can be understood that the detailed functions and extended functions that can be executed by the computer program can refer to the description of the above embodiments.
[0082] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when 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, which is stored in a storage medium and includes 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: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0083] 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 embodiments of the present invention. Those of ordinary skill in the art may understand and implement them without creative effort.
[0084] 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, 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 computer-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 traffic audit method described in each embodiment or some parts of the embodiment.
[0085] In addition, in the present invention, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0086] In addition, in the present invention, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0087] 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 drive adapter device, characterized in that: include: A driver interaction interface, used to receive an access request for accessing system resources sent by a driver, and forward a target execution result to the driver, wherein the driver is written through a general programming interface and the driver is pre-loaded into the system; A driver adaptation module, configured to convert the access request into a target access request adapted to the system version based on the system version of the system, and convert the execution result of the system processing the target access request into the target execution result adapted to the driver, wherein the converting of the access request into the target access request adapted to the system version based on the system version of the system includes: The method further comprises: calling a target conversion program from a preset conversion program corresponding to a plurality of system versions according to the system version, so as to realize the conversion of the access request from the universal programming interface used by the driver to the programming interface provided by the kernel of the system through the target conversion program, and further comprising: Obtain programming interfaces provided by the kernels of multiple system versions; Based on the programming interfaces provided by the kernels of the systems of the multiple system versions, the general programming interface is generated, and the conversion program between the general programming interface and the programming interface is in one-to-one correspondence, wherein the general programming interface is abstracted and defined based on the differences between the programming interfaces and kernel symbols of different versions of the operating system; The system interaction interface is used to forward the target access request to the system and receive the execution result of the system processing the target access request.
2. A method for accessing a system, characterized in that: include: Receiving an access request for accessing a system resource sent by a driver, wherein the driver is written using a universal programming interface and is pre-loaded into the system; Based on the system version of the system, converting the access request into a target access request adapted to the system version, and forwarding the target access request to the system; Receiving an execution result of the system processing the target access request, converting the execution result into a target execution result adapted to the driver, and forwarding the target execution result to the driver, wherein converting the access request into a target access request adapted to the system version based on the system version of the system includes: According to the system version, a target conversion program is called from conversion programs preset one-to-one corresponding to a plurality of system versions, so as to realize conversion of the access request from the general programming interface used by the driver to the programming interface provided by the kernel of the system through the target conversion program, and the method further includes: Obtain programming interfaces provided by the kernels of multiple system versions; The general programming interface is generated based on the programming interface provided by the kernel of the system of the multiple system versions, and the conversion program between the general programming interface and the programming interface is one-to-one corresponding, wherein the general programming interface is abstracted and defined based on the differences between the programming interfaces and kernel symbols of different versions of the operating system.
3. The method for accessing the system according to claim 2, characterized in that: Before receiving the access request for accessing the system resources sent by the driver, the method further includes the step of loading the driver into the system, specifically including: When it is determined that the driver is valid, the driver is loaded into the system and a code area and a data area of the driver are laid out in the kernel space of the system; The code and data of the driver are loaded into the code area and the data area respectively, and the universal programming interface used by the driver is linked and adapted so that the driver can access the system resources through the universal programming interface used by the driver.
4. A system access device, characterized in that: The device is used to implement the system access method described in any one of claims 2 to 3, and the device includes: A driver loader, used for loading a driver into the system; An adapter is used to receive an access request for accessing system resources sent by the driver, and based on the system version of the system, convert the access request into a target access request adapted to the system version, and forward the target access request to the system, as well as receive an execution result of the system processing the target access request, and convert the execution result into a target execution result adapted to the driver, and forward the target execution result to the driver.
5. 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 system access method according to any one of claims 2 to 3 are implemented.
6. A non-transitory 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 system access method according to any one of claims 2 to 3 are implemented.
7. A computer program product, the computer program product comprising a computer program, characterized in that: When the computer program is executed by a processor, the steps of the system access method according to any one of claims 2 to 3 are implemented.
Citation Information
Patent Citations
Method for multiplexing cross-platform driver based on dynamic binary translation
CN102193788A
Collector development platform
CN110909557A