如何Linux内核模块可以从C code装? [英] How can Linux kernel modules be loaded from C code?

查看:92
本文介绍了如何Linux内核模块可以从C code装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须同时具有两个外部内核模块和用户空间守护程序的应用程序。我想从守护程序code,C语言编写的,在启动时加载的模块,并卸载​​它们清洁退出。我可以在一个更清洁的方式加载它们比做系统(modprobe的模块); ,并使用相应的卸载它们 rmmod的

I have an application that has both two external kernel modules and a userspace daemon. I want to load the modules from the daemon code, written in C, at startup, and unload them on clean exit. Can I load them in a cleaner way than doing system("modprobe module"); and unload them using the corresponding rmmod?

推荐答案

insmod的/ rmmod的使用功能的init_module delete_module 来做到这一点,这也有一个人为的页面可用。他们都宣称功能为的extern ,而不是包括一个头,但该男子页说,他们应该在< Linux的/ module.h中>

insmod/rmmod use the functions init_module and delete_module to do this, which also have a man-page available. They both declare the functions as extern instead of including a header, but the man-page says they should be in <linux/module.h>.

这篇关于如何Linux内核模块可以从C code装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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