在用户空间从程序调用内核模块函数 [英] call a kernel module function from program at user space

查看:356
本文介绍了在用户空间从程序调用内核模块函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个内核模块及其上的一些功能.现在,我需要在用户空间中开发一个程序,并调用内核模块中的某些函数.

I developed a kernel module and some functions on it. Now i need to develop a program in the user space and call some functions which are in the kernel module.

我还需要在用户空间访问程序的内核模块中的某些全局变量.

I also need to access some global variable that are in the kernel module on my program at the user space.

推荐答案

关于linux-kernel模块和用户空间程序交互的完整概述, http://wiki.tldp.org/kernel_user_space_howto "内核空间,用户空间接口",作者:Ariane Keller(来自2008年9月28日, 2.6内核;唯一的主要新方法是 relayfs )

There is complete overview of linux-kernel module and user-space program interacting http://wiki.tldp.org/kernel_user_space_howto "Kernel Space, User Space Interfaces" by Ariane Keller (it is from 2008-09-28, but about 2.6 kernels; only major new way is relayfs)

没有列出从用户空间到内核空间的普通函数调用,仅列出syscall(添加新的syscall并不容易)和upcall(反向调用).

No ordinary function call from user space to kernel space is listed, only syscall (adding new syscall is not easy) and upcall (call in inverse direction).

最简单的接口之一是ioctl;但是在创建procfs,sysfs或类似文件之前,您不能开始使用ioctl.

One of easiest interface is ioctl; but you can't start to use ioctl before creating procfs, sysfs or similiar file.

其他是sysctl;但是sysctl更适合读写全局变量. (很难通过sysctl接口传递几个参数).

Other is sysctl; but sysctl is more eligible to reading/writing to global variable. (It is hard to pass several parameters via sysctl interface).

这篇关于在用户空间从程序调用内核模块函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆