call_usermodehelper()函数简介
来源:互联网 发布:聊天表情制作软件 编辑:程序博客网 时间:2024/05/05 17:46
call_usermodehelper()用来让内核空间的驱动程序启用用户空间的若干应用程序,
如:/sbin/hotplug、/bin/gliethttp_hello等,它的函数原型如下:
static inline int call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait);
path --- 用户空间所要启用的应用程序路径,如:"/sbin/hotplug",那么hotplug应用程序就会被内核加载启用
argv --- 传递给启用了的用户空间应用程序的参数argv
envp --- 传递给启用了的用户空间应用程序的环境变量envp,类似int main(int argc, char *_argv[])模式
wait --- 调用call_usermodehelper的内核程序是否等到被exec的用户空间应用程序,如:"/sbin/hotplug"退出后,才继续执行.
call_usermodehelper()执行之后会在工作队列khelper_wq中加入一个工作线程__call_usermodehelper,这个工作队列上的线程运行之后,会根据wait的类型,调用kernel_thread启用相应类型的线程wait_for_helper()或者____call_usermodehelper(),之所以调用kernel_thread生成新的线程,目的在于让并行运行实现最大化,充分利用cpu.
部分代码如下:
if (wait == UMH_WAIT_PROC || wait == UMH_NO_WAIT)
pid = kernel_thread(wait_for_helper, sub_info,
CLONE_FS | CLONE_FILES | SIGCHLD);
else
pid = kernel_thread(____call_usermodehelper, sub_info,
CLONE_VFORK | SIGCHLD);
线程wait_for_helper()或者____call_usermodehelper()最终调用kernel_execve()启动用户空间的应用程序,并把参数传给该应用程序,如:"/sbin/hotplug",由此可知call_usermodehelper()是内核驱动程序向外界应用程序程序传递内核信息的好手段,但是因为内核驱动会产生相当多的hotplug事件,所以后来就使用"/sbin/udevsend"临时代替,到了2.6.15内核之后,高效的netlink广播接口开始被采用,逐渐取代"/sbin/hotplug"和"/sbin/udevsend"的部分角色,成为一个新亮点,悄悄地登上了历史舞台(注:以上是在分析解读usb驱动模型kobject、kset等时的副产品,由于其自身存在着若干复杂性因素,详细深入分析还有待时间做进一步消化--gliethttp)
如:/sbin/hotplug、/bin/gliethttp_hello等,它的函数原型如下:
static inline int call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait);
path --- 用户空间所要启用的应用程序路径,如:"/sbin/hotplug",那么hotplug应用程序就会被内核加载启用
argv --- 传递给启用了的用户空间应用程序的参数argv
envp --- 传递给启用了的用户空间应用程序的环境变量envp,类似int main(int argc, char *_argv[])模式
wait --- 调用call_usermodehelper的内核程序是否等到被exec的用户空间应用程序,如:"/sbin/hotplug"退出后,才继续执行.
call_usermodehelper()执行之后会在工作队列khelper_wq中加入一个工作线程__call_usermodehelper,这个工作队列上的线程运行之后,会根据wait的类型,调用kernel_thread启用相应类型的线程wait_for_helper()或者____call_usermodehelper(),之所以调用kernel_thread生成新的线程,目的在于让并行运行实现最大化,充分利用cpu.
部分代码如下:
if (wait == UMH_WAIT_PROC || wait == UMH_NO_WAIT)
pid = kernel_thread(wait_for_helper, sub_info,
CLONE_FS | CLONE_FILES | SIGCHLD);
else
pid = kernel_thread(____call_usermodehelper, sub_info,
CLONE_VFORK | SIGCHLD);
线程wait_for_helper()或者____call_usermodehelper()最终调用kernel_execve()启动用户空间的应用程序,并把参数传给该应用程序,如:"/sbin/hotplug",由此可知call_usermodehelper()是内核驱动程序向外界应用程序程序传递内核信息的好手段,但是因为内核驱动会产生相当多的hotplug事件,所以后来就使用"/sbin/udevsend"临时代替,到了2.6.15内核之后,高效的netlink广播接口开始被采用,逐渐取代"/sbin/hotplug"和"/sbin/udevsend"的部分角色,成为一个新亮点,悄悄地登上了历史舞台(注:以上是在分析解读usb驱动模型kobject、kset等时的副产品,由于其自身存在着若干复杂性因素,详细深入分析还有待时间做进一步消化--gliethttp)
- call_usermodehelper()函数简介
- call_usermodehelper函数
- Linux call_usermodehelper()
- call_usermodehelper使用实例
- 函数简介
- 函数简介
- 函数简介
- hotplug启动过程之call_usermodehelper分析
- Linux驱动层调用应用层程序--call_usermodehelper()
- 函数简介 函数名称: strrchr
- winsock 函数简介
- windows API函数简介
- 函数简介(C)
- Winsock 函数简介
- [转帖]winsock函数简介
- WIN32 API函数简介
- Winsock 函数简介
- getopt()函数简介
- JDBC连接MySQL程序_by 老大&stone
- Windows系统常见中文字体英文名称
- “Microsoft Exchange Server 计算机不可用。原因可能是网络出现问题,或者是 Microsoft Exchange Server 正处于停机维护阶段。”的解决办法
- JavaScript征途
- 天龙八部中的扫地僧的真实身份
- call_usermodehelper()函数简介
- 1915 Knight Moves 广搜
- usaco——clocks
- word 2003 中生存目录的一种方法
- 《Head First 设计模式》代码之PHP版
- 一部电脑,玩转sql server多机连接.
- 划过时代黑暗天幕的两颗彗星
- windows下wireshark插件开发之源码编译
- 阳历、阴历、农历