简体   繁体   English

修改Linux内核中的现有模块

[英]Modifying an existing module in linux kernel

I am using g_file_storage as driver on my embedded linux to pose it as mass storage for any usb host.I have done that well!! 我在embedded linux上使用g_file_storage作为驱动程序,将其作为任何USB主机的大容量存储。我做得很好!

Now I need to do more .... is to capture eject event on usb device ..which is a functionality not given by g_file_storage till now. 现在,我需要做的更多..是捕获USB设备上的弹出事件..到目前为止, g_file_storage没有提供此功能。

I have got this function fsg_suspend() in g_file_storage driver ...Its is the routine that gets called when a Windows USB host does "Safely remove hardware" ..... 我在g_file_storage driver程序中获得了此function fsg_suspend() ...这是Windows USB主机执行"Safely remove hardware"时所调用的例程...

i am thinking of adding a simple printk to send simple message in /var/log/message in fsg_suspend function which i will watch from user space on BeagleBoard ..... 我正在考虑添加一个简单的printk以在fsg_suspend函数的/var/log/message中发送简单消息,我将从BeagleBoard用户空间中进行监视.....

but im into a very basic kernel programming doubt ...if you can help me out .... 但是我对一个非常基本的内核编程感到怀疑...是否可以帮助我....

i have written simple kernel modules ..which is lets say module.c file an i use simple make command to compile it then modprobe/insmod to insert it and then i use it ...... this is about a module totally written by me. 我已经写了简单的内核模块..这可以说是module.c文件,我使用简单的make命令对其进行编译,然后使用modprobe/insmod插入它,然后再使用它…… 这是关于完全编写的模块由我。

and

i have also configured a module as option M in config file while recompiling kernel .. then i do make , make modules , make modules_install , make_install then we use modprobe to use that particular feature ..pl Correct me if i am wrong .... 我还在重新编译内核时在配置文件中将模块配置为选项M。然后我进行make,make modules,make modules_installmake_install然后我们使用modprobe使用该特定功能..pl如果我错了,请纠正我... 。

But here this module is a kernel module , if i make a change to it , Then ........ 但是这里这个模块是一个内核模块,如果我对其进行更改,那么........

can i just recompile it using its makefile ...and do modprobe ...? 我可以使用它的makefile重新编译它吗,并且可以做modprobe ...? but this Makefile doesnt seem to support this idea .. 但是这个Makefile似乎不支持这个想法。

will it interfere with already present copy of this module in running kernel ? 它会干扰正在运行的内核中该模块的现有副本吗? Or will i have to recompile kernel? 还是我必须重新编译内核?

I don't understand most of the first half of the query. 我不太了解查询的前半部分。 The question is tagged Linux and kernel, so why is there so much about Windows? 问题被标记为Linux和内核,那么为什么Windows有那么多?

If I understand correctly, you'll have to disable the existing device driver. 如果我理解正确,则必须禁用现有的设备驱动程序。 The most straightforward means is to rebuild the kernel without it. 最直接的方法是在没有内核的情况下重建内核。 Then use the insmod and rmmod commands to load and unload the new driver. 然后使用insmodrmmod命令加载和卸载新的驱动程序。

I can't tell from the details you've provided, but maybe there is a way for the new driver to coexist alongside the old one. 我无法从您提供的详细信息中看出来,但是也许新的驱动程序可以与旧的驱动程序共存。 If it does not need an IRQ, or it can use a separate one, then you can create new device nodes and use it independently of the existing driver. 如果不需要IRQ,或者可以使用单独的IRQ,则可以创建新的设备节点并独立于现有驱动程序使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM