CN105204937B - Kernel function call method, apparatus and operating system - Google Patents

Kernel function call method, apparatus and operating system Download PDF

Info

Publication number
CN105204937B
CN105204937B CN201510714259.7A CN201510714259A CN105204937B CN 105204937 B CN105204937 B CN 105204937B CN 201510714259 A CN201510714259 A CN 201510714259A CN 105204937 B CN105204937 B CN 105204937B
Authority
CN
China
Prior art keywords
parameter
kernel
function
address
module
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510714259.7A
Other languages
Chinese (zh)
Other versions
CN105204937A (en
Inventor
钟捷群
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhongke Hongqi Beijing Information Technology Co ltd
Original Assignee
Shanghai Feixun Data Communication Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Feixun Data Communication Technology Co Ltd filed Critical Shanghai Feixun Data Communication Technology Co Ltd
Priority to CN201510714259.7A priority Critical patent/CN105204937B/en
Publication of CN105204937A publication Critical patent/CN105204937A/en
Application granted granted Critical
Publication of CN105204937B publication Critical patent/CN105204937B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The present invention discloses a kind of kernel function call method, including step:Obtain kernel function title and parameter input by user;The kernel function title and parameter are parsed in user's space, obtains address and the type of function and parameter, and establish parameter list;Using the parameter list as kernel module parameter, using insmoding, kernel module is added in instruction in systems;The parameter list is parsed in kernel spacing, to obtain respective function address and parameter value;And the function is called according to the function address and parameter value.Invention additionally discloses a kind of kernel function call device and its operating systems.

Description

Kernel function call method, apparatus and operating system
Technical field
The present invention relates to computer operating system more particularly to a kind of kernel function call method, apparatus and operating system.
Background technology
Using in the embedded product of (SuSE) Linux OS, program need to use two spaces when running:User's space and interior Nuclear space.Described two spaces are mutually independent.Kernel operates in kernel spacing, and application program, such as user interface etc., Operate in user's space.When application program needs the service provided using kernel, completed by system calling.
In addition, kernel is usually in some way, such as file (log, message, core dump, proc file, sysfs File etc.) mode, Debugging message is exported to user's space, is debugged when something goes wrong to work as kernel.With file mode Export needs after encoding realization in kernel according to specific file specification, could be exported in system operation or generation problem User's space.The file of different-format needs different standard operations.Therefore, if realizing file export without encoding in advance, It can not then check corresponding kernel tailoring information.
Invention content
In view of this, the present invention provides a kind of kernel function call method, apparatus and operating system, with solve it is above-mentioned at least One technical problem.
The embodiment of the present invention provides a kind of kernel function call method, including step:Obtain kernel function input by user Title and parameter;The kernel function title and parameter are parsed in user's space, obtains address and the type of function and parameter, and Establish parameter list;Using the parameter list as kernel module parameter, using insmoding, kernel mould is added in instruction in systems Block;The parameter list is parsed in kernel spacing, to obtain respective function address and parameter value;And according to the function address The function is called with parameter value.
The embodiment of the present invention also provides a kind of kernel function call device, includes at least:Name acquiring module, for obtaining Kernel function title and parameter input by user;First parsing module is arranged in user's space, for parsing the kernel function Title and parameter, obtain address and the type of function and parameter, and establish parameter list;It insmods, for the parameter List is kernel module parameter, adds kernel module in systems;Second parsing module is arranged in kernel spacing, for parsing The parameter list obtains respective function address and parameter value;And calling module, for according to the function address and parameter Value calls the function.
The embodiment of the present invention also provides a kind of operating system, including user's space and kernel spacing.The user's space is extremely Include less:Name acquiring module, for obtaining kernel function title and parameter input by user;First parsing module, for solving The kernel function title and parameter are analysed, address and the type of function and parameter are obtained, and establishes parameter list;And it is loaded into mould Block, for using the parameter list as kernel module parameter, adding kernel module in systems.The kernel spacing at least wraps It includes:Second parsing module obtains respective function address and parameter value for parsing the parameter list;And calling module, it uses According to the function address and the parameter value calling function.
The kernel function call device and method of the present invention, can be when Debugging message export to user's space, only Kernel is wanted to provide debugging interface function, you can to call the function from user's space, then to execute the function in kernel spacing Debugging message is exported, it is convenient and efficient and versatile.
Description of the drawings
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technology description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments of invention without having to pay creative labor, may be used also for those of ordinary skill in the art With obtain other attached drawings according to these attached drawings.
Fig. 1 is the flow chart of kernel function call method according to the ... of the embodiment of the present invention;
Fig. 2 is the part sub-step flow chart of the step S102 of kernel function call method according to the ... of the embodiment of the present invention;
Fig. 3 is the sub-step flow chart of the step S104 of kernel function call method according to the ... of the embodiment of the present invention;
Fig. 4 is the high-level schematic functional block diagram of kernel function call device according to the ... of the embodiment of the present invention and operating system.
Specific embodiment
Further more detailed description is made to technical scheme of the present invention in the following with reference to the drawings and specific embodiments.Obviously, Described embodiment is only a part of the embodiment of the present invention, instead of all the embodiments.Based on the reality in the present invention Apply example, the every other embodiment that those of ordinary skill in the art are obtained under the premise of not making creative work, all The scope of protection of the invention should be belonged to.
Referring to Fig. 1, it is a kind of kernel function call method that one embodiment of the invention provides.In the present embodiment, institute It states kernel function call method and is applied to (SuSE) Linux OS.It the described method comprises the following steps:
Step S101 obtains kernel function title and parameter input by user.In the present embodiment, function name input by user Claim or parameter at least follows one of following syntax format:
1) function name or name variable [:] [@kernel modules title];
2) with 0x beginning 32 hexadecimal numbers [:];
3) decimal integer [:].
Wherein, character " [] " partly indicates optional part, character ":" indicate to take address of variable as parameter, character "@" it Part afterwards is the corresponding kernel module title in symbol source.In addition, acquiescence takes variate-value as function parameter, when multiple kernels Module is using can further discriminate between identification when identical designation.Function name or variable name are at letter or " _ " beginning. In the present embodiment, 8 parameters are could support up.
Step S102 parses the kernel function title and parameter in user's space, obtain function and parameter address and Type, and establish parameter list.In the present embodiment, the parameter list includes multiple two tuples, and each two tuple includes each The type and address of function or parameter, wherein the type and address are all indicated with 32 signless integers.That is, at this In embodiment, according to the syntax format of step S101, function input by user or parameter are parsed successively.Each function or parameter life At one<Type, address>Two tuples, type and address all indicate that all two tuples form one successively with 32 signless integers A parameter list.
Referring to Fig. 2, more specifically, the step of address and type for obtaining function and parameter includes sub-step:
S102a obtains functional symbol or the corresponding address of pa-rameter symbols.
S102b obtains the address value in two tuples and obtains address in two tuples and is directed toward 32 of core position without symbol Number integer numerical value, to determine type.
S102c, the parameter list generated pass to the kernel module, the member of the array parameter as array parameter Element is 32 signless integers.
In addition, in some embodiments, when function or variable are inputted in the form of symbol (character string), pass through/proc/ Kallsyms files can inquire the corresponding address of the symbol.And in further embodiments, when function or variable with ten into When the form input of number processed, need to be converted into corresponding hexadecimal representation format in computer.It is input by user to be called interior Kernel function is then handled in the way of taking location (namely obtaining the address value in two tuples).
Step S103, using the parameter list as kernel module parameter, using insmod instruction (such as insmod order Enable) kernel module is added in systems.
Step S104 parses the parameter list, to obtain respective function address and parameter value in kernel spacing.
Referring to Fig. 3, step S104 specifically includes sub-step:
Step S104a, from the array parameter transmitted, to parse class in the form of two tuples of containing type and address Type and respective function or argument address;And
Step S104b obtains function address and parameter values successively according to the type.
Step S105 calls the function according to the function address and parameter value.
Step S106 deletes the kernel module at the end of kernel function call in user's space.
It, can be when Debugging message export to user's space, as long as interior using kernel function call method of the present invention Core provides debugging interface function, you can to call the function from user's space, then executes function export in kernel spacing Debugging message, it is convenient and efficient and versatile.
Referring to Fig. 4, the present invention also provides a kind of kernel function call device 100, name acquiring module is included at least 10, the first parsing module 20, insmod the 30, second parsing module 40 and calling module 50.
Specifically, the name acquiring module 10 is for obtaining kernel function title and parameter input by user.Described The setting of one parsing module 20 obtains the ground of function and parameter in user's space for parsing the kernel function title and parameter Location and type, and establish parameter list.It is described to insmod 30 for using the parameter list as kernel module parameter, in system Middle addition kernel module.The setting of second parsing module 40 obtains corresponding in kernel spacing for parsing the parameter list Function address and parameter value.The calling module 50 is used to call the function according to the function address and parameter value.
Using kernel function call device 100 of the present invention, can when Debugging message does not export to user's space, as long as Kernel provides debugging interface function, you can to call the function from user's space, then executes the function in kernel spacing and leads Go out Debugging message, it is convenient and efficient and versatile.
Further referring to Fig. 4, the present invention also provides a kind of operating systems comprising the user's space and kernel are empty Between, the user's space includes at least above-mentioned name acquiring module 10, the first parsing module 20 and insmods 30.It is described Kernel spacing includes at least above-mentioned the second parsing module 40 and calling module 50.In addition, the user's space may also include one A removing module 60, at the end of kernel function call, the kernel module to be deleted in user's space.
It should be noted that the description of the embodiment more than passing through, those skilled in the art can be understood that The present invention can add the mode of required hardware platform to realize by software, naturally it is also possible to all be implemented by hardware.Base In such understanding, technical scheme of the present invention to background technology contribute in whole or in part can be with software product Form embodies, and the computer software product can be stored in a storage medium, such as ROM/RAM, magnetic disc, CD, packet Some instructions are included to use so that a computer equipment (can be personal computer, server or the network equipment etc.) executes Method described in certain parts of each embodiment of the present invention or embodiment.
Above disclosed is only the preferred embodiment in the embodiment of the present invention, cannot limit this hair with this certainly Bright interest field, therefore equivalent changes made in accordance with the claims of the present invention, are still within the scope of the present invention.

Claims (8)

1. a kind of kernel function call method, which is characterized in that including step:
Obtain kernel function title and parameter input by user;
The kernel function title and parameter are parsed in user's space, obtains address and the type of function and parameter, and establish ginseng Ordered series of numbers table;
Using the parameter list as kernel module parameter, using insmoding, kernel module is added in instruction in systems;
The parameter list is parsed in kernel spacing, to obtain respective function address and parameter value;And
The function is called according to the function address and parameter value;
At the end of kernel function call, the kernel module is deleted in user's space.
2. kernel function call method as described in claim 1, which is characterized in that the kernel function call method is applied to (SuSE) Linux OS, the function name input by user or parameter at least follow one of following syntax format:Function name Claim or parameter name [:] [@kernel modules title], with 0x beginning 32 hexadecimal numbers [:], decimal integer [:], In, character " [] " partly indicates optional part, character ":" indicate to take address of variable as parameter, the part after character "@" For the corresponding kernel module title in symbol source.
3. kernel function call method as described in claim 1, which is characterized in that the parameter list includes multiple binary Group, each two tuple include type and the address of each function or parameter, wherein the type and address are all with 32 without symbol Integer representation.
4. kernel function call method as claimed in claim 3, which is characterized in that the address for obtaining function and parameter and The step of type includes:
Obtain functional symbol or the corresponding address of pa-rameter symbols;And
It obtains the address value in two tuples and obtains 32 signless integer numerical value that core position is directed toward in address in two tuples, To determine type.
5. kernel function call method as described in claim 1, which is characterized in that the parameter list generated is joined as array Number passes to the kernel module, and the element of the array parameter is 32 signless integers.
6. kernel function call method as claimed in claim 5, which is characterized in that the parsing parameter list is to obtain The step of respective function address and parameter value includes:
From the array parameter transmitted, by parsed in the form of two tuples of containing type and address type and respective function or Argument address;
Function address and parameter values are obtained successively according to the type.
7. a kind of kernel function call device, which is characterized in that include at least:
Name acquiring module, for obtaining kernel function title and parameter input by user;
First parsing module, setting obtain function and parameter in user's space for parsing the kernel function title and parameter Address and type, and establish parameter list;
It insmods, for using the parameter list as kernel module parameter, adding kernel module in systems;
Second parsing module, setting obtain respective function address and parameter in kernel spacing for parsing the parameter list Value;And
Calling module, for calling the function according to the function address and parameter value;
Removing module, setting is in user's space, at the end of kernel function call, the kernel mould to be deleted in user's space Block.
8. a kind of operating system, including user's space and kernel spacing, which is characterized in that the user's space includes at least:
Name acquiring module, for obtaining kernel function title and parameter input by user;
First parsing module obtains address and the type of function and parameter for parsing the kernel function title and parameter, and Establish parameter list;And
It insmods, for using the parameter list as kernel module parameter, adding kernel module in systems;And
The kernel spacing includes at least:
Second parsing module obtains respective function address and parameter value for parsing the parameter list;And
Calling module, for calling the function according to the function address and parameter value;
The user's space further comprises removing module, at the end of kernel function call, institute to be deleted in user's space State kernel module.
CN201510714259.7A 2015-10-28 2015-10-28 Kernel function call method, apparatus and operating system Active CN105204937B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510714259.7A CN105204937B (en) 2015-10-28 2015-10-28 Kernel function call method, apparatus and operating system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510714259.7A CN105204937B (en) 2015-10-28 2015-10-28 Kernel function call method, apparatus and operating system

Publications (2)

Publication Number Publication Date
CN105204937A CN105204937A (en) 2015-12-30
CN105204937B true CN105204937B (en) 2018-09-28

Family

ID=54952633

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510714259.7A Active CN105204937B (en) 2015-10-28 2015-10-28 Kernel function call method, apparatus and operating system

Country Status (1)

Country Link
CN (1) CN105204937B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109543400B (en) 2017-09-21 2022-08-09 华为技术有限公司 Method and equipment for dynamically managing kernel nodes
CN107770261A (en) * 2017-10-13 2018-03-06 郑州云海信息技术有限公司 A kind of computational methods and relevant apparatus based on distributed memory system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6895576B2 (en) * 2001-10-18 2005-05-17 Hewlett-Packard Development Company, L.P. Method and system for device driver and operating system debugging of portable computers
CN1722100A (en) * 2004-07-13 2006-01-18 鸿富锦精密工业(深圳)有限公司 memory test system and method
CN102467447A (en) * 2010-11-16 2012-05-23 鸿富锦精密工业(深圳)有限公司 Driver debugging system and method
CN104050080A (en) * 2014-06-09 2014-09-17 汉柏科技有限公司 Method and system for debugging linux kernel in user mode

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6895576B2 (en) * 2001-10-18 2005-05-17 Hewlett-Packard Development Company, L.P. Method and system for device driver and operating system debugging of portable computers
CN1722100A (en) * 2004-07-13 2006-01-18 鸿富锦精密工业(深圳)有限公司 memory test system and method
CN102467447A (en) * 2010-11-16 2012-05-23 鸿富锦精密工业(深圳)有限公司 Driver debugging system and method
CN104050080A (en) * 2014-06-09 2014-09-17 汉柏科技有限公司 Method and system for debugging linux kernel in user mode

Also Published As

Publication number Publication date
CN105204937A (en) 2015-12-30

Similar Documents

Publication Publication Date Title
US10142106B2 (en) System and method for securing sensitive data
CN105512029B (en) A kind of method, server and system for testing intelligent terminal
CN111176976B (en) Test data generation method and device, storage medium and electronic device
US20160179495A1 (en) Device and method for packaging application
CN104090946B (en) The method and device of information is added in application installation package
CN105095367B (en) A kind of acquisition method and device of client data
CN110188135B (en) File generation method and equipment
CN104184814A (en) Method and system for generating and compounding embedded firmware differential upgrading file
JP2019510315A (en) Application updating method and apparatus for mobile terminal
CN106547576A (en) The acquisition methods and device of configuration file
CN108647032B (en) Application loading method and device, computer device and computer readable storage medium
CN112052013A (en) Software package generation method and device, storage medium and electronic device
CN105204937B (en) Kernel function call method, apparatus and operating system
CN110532182B (en) Automatic testing method and device for virtualization platform
CN108595178B (en) Hook-based data acquisition method, device and equipment
CN110019012B (en) Data preprocessing method, data preprocessing device and computer-readable storage medium
CN103139298B (en) Method for transmitting network data and device
CN113031944B (en) Business opening device and method based on template
CN109068286B (en) Information analysis method, medium and equipment
CN104965719B (en) Using installation file generation method and device
CN105243022B (en) The performance data analysis method and device of host application software system
CN110084005A (en) A kind of processing method and processing device of code
KR20170101693A (en) Apparatus and method for analyzing android application, and computer-readable medium storing program for method thereof
CN111142859A (en) Script generation method and device, electronic equipment and storage medium
CN110647546A (en) Third-party rule engine generation method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20201209

Address after: 313028 Industrial Park, balidian Town, Huzhou City, Zhejiang Province

Patentee after: HUZHOU FENGYUAN AGRICULTURAL EQUIPMENT MANUFACTURE Co.,Ltd.

Address before: 201616 No. 3666 Sixian Road, Songjiang District, Shanghai

Patentee before: Phicomm (Shanghai) Co.,Ltd.

TR01 Transfer of patent right
PE01 Entry into force of the registration of the contract for pledge of patent right
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: Kernel function calling method, device and operating system

Effective date of registration: 20211203

Granted publication date: 20180928

Pledgee: Zhejiang Tailong Commercial Bank Co.,Ltd. Huzhou Branch

Pledgor: HUZHOU FENGYUAN AGRICULTURAL EQUIPMENT MANUFACTURE Co.,Ltd.

Registration number: Y2021330002446

PC01 Cancellation of the registration of the contract for pledge of patent right
PC01 Cancellation of the registration of the contract for pledge of patent right

Date of cancellation: 20230811

Granted publication date: 20180928

Pledgee: Zhejiang Tailong Commercial Bank Co.,Ltd. Huzhou Branch

Pledgor: HUZHOU FENGYUAN AGRICULTURAL EQUIPMENT MANUFACTURE Co.,Ltd.

Registration number: Y2021330002446

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20240122

Address after: Room 03, 3rd Floor, Building 3, Yard A2, West Third Ring North Road, Haidian District, Beijing, 100080

Patentee after: Zhongke Hongqi (Beijing) Information Technology Co.,Ltd.

Country or region after: China

Address before: 313028 Industrial Park, balidian Town, Huzhou City, Zhejiang Province

Patentee before: HUZHOU FENGYUAN AGRICULTURAL EQUIPMENT MANUFACTURE Co.,Ltd.

Country or region before: China