insmod 和make module_install

1,insmod是把模块加载进内核,加载之后才能运行;随后mknod 创建文件节点。这样操作后,就可以在应用代码中调用驱动了


2,make modules_install 只是把编译好的模块拷贝到系统目录下(一般是/lib/modules/)。

也可自己指定ko安装路径:

make modules_install INSTALL_MOD_PATH=/home/luther/gliethttp_dir
应用安装指定:
make install DESTDIR= /home/luther/gliethttp_dir
应用安装后,就可以在应用层调用驱动了。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
为下面这段代码写一个makefile文件,#include <linux/init.h> #include <linux/module.h> #include <linux/workqueue.h> #include <linux/sched.h> #include <linux/delay.h> #include <linux/timekeeping.h> MODULE_LICENSE("GPL"); static struct workqueue_struct* workqueue; static struct work_struct work1; static struct delayed_work work2; static int times; module_param(times, int, 5); int get_time(char* buff, int len) { struct timespec64 ts; struct tm tm_res; char time_string[40]; ktime_get_real_ts64(&ts); time64_to_tm(ts.tv_sec, 0, &tm_res); buff=tm_res.tm_year + 1900, tm_res.tm_mon + 1, tm_res.tm_mday,tm_res.tm_hour, tm_res.tm_min, tm_res.tm_sec; return 0; } static void real_time_work(struct work_struct* work) { char buff[40]; get_time(buff, sizeof(buff)); printk(KERN_INFO "%s\n",buff); } static void delayed_work(struct work_struct* work) { char buff[40]; get_time(buff, sizeof(buff)); printk(KERN_INFO "this is a delay work :%s\n", buff); } static int __init module_init(void) { printk(KERN_INFO "Initializing workqueue module.\n"); workqueue = create_workqueue("workqueue"); INIT_WORK(&work1, real_time_work); INIT_DELAYED_WORK(&work2, delayed_work); queue_work(workqueue, &work1); queue_delayed_work(workqueue, &work2, msecs_to_jiffies(10000)); return 0; } static void __exit module_exit(void) { printk(KERN_INFO "Exiting workqueue module.\n"); flush_workqueue(workqueue); destroy_workqueue(workqueue); } module_init(module_init); module_exit(module_exit);要求. 把加载、卸载内核模块以 install/uninstall 写入 Makefile 文件中。
06-09

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值