Linux驱动层调用应用层程序--call_usermodehelper()
来源:互联网 发布:淘宝小二误判如何申诉 编辑:程序博客网 时间:2024/05/19 00:08
Linux驱动层调用应用层程序–call_usermodehelper()
在驱动层想要调用用户空间程序主要还是通过call_usermodehelper()这一函数,在这里记录一下;
#include<linux/init.h>#include<linux/module.h>#include<linux/moduleparam.h>//#include<linux/config.h>#include<linux/kernel.h>/*printk()*/#include<linux/sched.h>MODULE_LICENSE("GPL");static __init int testDriver1_init(void){ int result=0; char cmdPath[]="/bin/bash"; char* cmdArgv[]={cmdPath, "-c", "/bin/ls >> /tmp/list", NULL}; char* cmdEnvp[]={"HOME=/", "PATH=/sbin:/bin:/usr/bin", NULL}; result=call_usermodehelper(cmdPath,cmdArgv,cmdEnvp,UMH_WAIT_PROC); printk(KERN_DEBUG"testDriver1 _init exec! The result of call_usermodehelper is %d\n",result); //printk(KERN_DEBUG"testDriver1_initexec!Theprocess is \"%s\",pidis %d ,sys_getpid is %d \n",current->comm,current->pid); printk(KERN_DEBUG"testDriver1 _init exec! The process is \"%s\",pid is %d\n",current->comm,current->pid); return result;}static __exit void testDriver1_exit(void){ int result=0; char cmdPath[]="/bin/bash"; char* cmdArgv[]={cmdPath, "-c", "/bin/ls >> /tmp/list", NULL}; char* cmdEnvp[]={"HOME=/","PATH=/sbin:/bin:/usr/bin",NULL}; result=call_usermodehelper(cmdPath,cmdArgv,cmdEnvp,UMH_WAIT_PROC); printk(KERN_DEBUG"testDriver1 _exit exec! The result of call_usermodehelper is %d\n",result); printk(KERN_DEBUG"testDriver1 _exit exec! The process is \"%s\",pid is %d \n",current->comm,current->pid);}module_init(testDriver1_init);module_exit(testDriver1_exit);
对应的Makefile文件
obj-m := testDriver.oKERNEL_DIR := /lib/modules/$(shell uname -r)/buildPWD := $(shell pwd)all: make -C $(KERNEL_DIR) SUBDIRS=$(PWD) modulesclean: rm *.o *.ko
简单记录,以防后面需要。。。
阅读全文
0 0
- Linux驱动层调用应用层程序--call_usermodehelper()
- 应用调用驱动层
- Linux学习:应用层open调用驱动层open过程
- 嵌入式linux FM25L256的驱动(应用层)程序
- 应用层至驱动层的调用情况
- Android 应用层如何调用驱动节点
- 应用层到驱动层
- Linux 网卡驱动学习(六)(应用层、tcp 层、ip 层、设备层和驱动层作用解析)
- Linux 网卡驱动学习(六)(应用层、tcp 层、ip 层、设备层和驱动层作用解析)
- Linux 网卡驱动学习(六)(应用层、tcp 层、ip 层、设备层和驱动层作用解析)
- linux应用层程序makefile示例
- linux硬件驱动层
- Android应用层调用驱动的全过程 精简版
- 应用层open如何调用驱动open函数的?
- 安卓应用层与底层驱动之间的调用
- 应用层 ---> framwork层JNI ---> 驱动c
- 驱动层和应用层进行通信
- 应用层与驱动层通信DeviceIoControl
- MySQL索引原理及慢查询优化
- 从ActiveMQ认识JMS
- XYNUOJ 1096: 习题6-10 字符统计 输出结果为三行分别输出
- 解决nginx的The page you are looking for is temporarily unavailable错误办法
- JavaScript 通常用于操作 HTML 元素
- Linux驱动层调用应用层程序--call_usermodehelper()
- 找错:ZdalRuleCalculateException: 规则引擎计算出错,拆分值=
- vue-cli 使用vue-bus来全局控制
- Angular2是可怕的
- ES2016 新特性:求幂运算符(**)
- 字符串匹配的KMP算法
- 微信小程序配置服务器信息
- HMACSHA1加密
- 浙大版《C语言程序设计(第3版)》题目集前四章总结