List my Staging Drivers
Hi, How do I list where are the modules that I'm using inside kernel ? Goal: find drivers that I could start improving ( understand, develop, test , submit ) How : If my machine uses a driver, I can read the code, modify and test in my machine So, if I'm able to see where is located the source for a driver that my machine uses, I can modify and test. Ideas ? Thanks -- Lucas Tanure +55 (19) 988176559
In data martedì 9/12/2014 18:45:59, Lucas Tanure ha scritto:
Hi,
How do I list where are the modules that I'm using inside kernel ?
Goal: find drivers that I could start improving ( understand, develop, test , submit ) How : If my machine uses a driver, I can read the code, modify and test in my machine
So, if I'm able to see where is located the source for a driver that my machine uses, I can modify and test.
Ideas ?
Thanks
'lsmod' and 'lspci -k' show your loaded modules and which module is handling a device. 'find /lib/modules/$(uname -r)/kernel $module_name' show you where the module is located; /lib/modules/<kernel_version>/kernel folder tree is equal to the source tree. Dave
Hi Lucas, Please find my response inline.
Goal: find drivers that I could start improving ( understand, develop, test , submit ) How : If my machine uses a driver, I can read the code, modify and test in my machine
Suppose you want to improve/change a basic driver you are using for example XFS filesystem. /lib/modules/<kernel_version>/points to the location of the source code On my Ubuntu 14.04 machine, ssinha@ssinha-Latitude-E6440:~$ ls -l /lib/modules/`uname -r`/ total 3852 lrwxrwxrwx 1 root root 40 Sep 23 04:03 build -> /usr/src/linux-headers-3.13.0-37-generic so the location of the source code is /usr/src/linux-headers-3.13.0-37-generic. Now go to the fs folder here to get the source code of xfs. ssinha@ssinha-Latitude-E6440:~$ ls -l /usr/src/linux-headers-3.13.0-37-generic/fs/xfs total 8 -rw-r--r-- 1 root root 3839 Jan 20 2014 Kconfig -rw-r--r-- 1 root root 3027 Jan 20 2014 Makefile Now what I find is that I have only headers not the entire source code. So the distros don't generally ship with the entire source code. You can get the source code of your running kernel by either the source packages(kernel-src-rpms or kernel-src-deb) of the distros or you can get tar ball of your running kernel from the kernel.org.
So, if I'm able to see where is located the source for a driver that my machine uses, I can modify and test.
Now when you have the source code, change the driver, make sure its enabled in the kernel .config driver, build the entire kernel and boot into your modified kernel. (If your driver is standalone and not dependent on other drivers, you can build its seprately and insmod it without having to build the entire kernel tree.) Hope that helps. Regards, Saket Sinha On Wed, Dec 10, 2014 at 2:23 AM, Davide Gianforte <davide@gengisdave.org> wrote:
In data martedì 9/12/2014 18:45:59, Lucas Tanure ha scritto:
Hi,
How do I list where are the modules that I'm using inside kernel ?
Goal: find drivers that I could start improving ( understand, develop, test , submit ) How : If my machine uses a driver, I can read the code, modify and test in my machine
So, if I'm able to see where is located the source for a driver that my machine uses, I can modify and test.
Ideas ?
Thanks
'lsmod' and 'lspci -k' show your loaded modules and which module is handling a device.
'find /lib/modules/$(uname -r)/kernel $module_name' show you where the module is located; /lib/modules/<kernel_version>/kernel folder tree is equal to the source tree.
Dave
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On Tue, Dec 9, 2014 at 7:19 PM, Saket Sinha <saket.sinha89@gmail.com> wrote:
Hi Lucas,
Please find my response inline.
Goal: find drivers that I could start improving ( understand, develop, test , submit ) How : If my machine uses a driver, I can read the code, modify and test in my machine
Suppose you want to improve/change a basic driver you are using for example XFS filesystem.
/lib/modules/<kernel_version>/points to the location of the source code
On my Ubuntu 14.04 machine,
ssinha@ssinha-Latitude-E6440:~$ ls -l /lib/modules/`uname -r`/ total 3852 lrwxrwxrwx 1 root root 40 Sep 23 04:03 build -> /usr/src/linux-headers-3.13.0-37-generic
so the location of the source code is /usr/src/linux-headers-3.13.0-37-generic.
Now go to the fs folder here to get the source code of xfs. ssinha@ssinha-Latitude-E6440:~$ ls -l /usr/src/linux-headers-3.13.0-37-generic/fs/xfs total 8 -rw-r--r-- 1 root root 3839 Jan 20 2014 Kconfig -rw-r--r-- 1 root root 3027 Jan 20 2014 Makefile
Now what I find is that I have only headers not the entire source code.
So the distros don't generally ship with the entire source code. You can get the source code of your running kernel by either the source packages(kernel-src-rpms or kernel-src-deb) of the distros or you can get tar ball of your running kernel from the kernel.org.
So, if I'm able to see where is located the source for a driver that my machine uses, I can modify and test.
Now when you have the source code, change the driver, make sure its enabled in the kernel .config driver, build the entire kernel and boot into your modified kernel. (If your driver is standalone and not dependent on other drivers, you can build its seprately and insmod it without having to build the entire kernel tree.)
Hope that helps.
Regards, Saket Sinha
On Wed, Dec 10, 2014 at 2:23 AM, Davide Gianforte <davide@gengisdave.org> wrote:
In data martedì 9/12/2014 18:45:59, Lucas Tanure ha scritto:
Hi,
How do I list where are the modules that I'm using inside kernel ?
Goal: find drivers that I could start improving ( understand, develop, test , submit ) How : If my machine uses a driver, I can read the code, modify and test in my machine
So, if I'm able to see where is located the source for a driver that my machine uses, I can modify and test.
Ideas ?
Thanks
'lsmod' and 'lspci -k' show your loaded modules and which module is handling a device.
'find /lib/modules/$(uname -r)/kernel $module_name' show you where the module is located; /lib/modules/<kernel_version>/kernel folder tree is equal to the source tree.
Dave
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi, Thanks for the reply. But, actually, I found one solution, just like what Davide explained. tanure@archDesk ~ $ modinfo ehci_hcd filename: /lib/modules/3.18.0-next-20141209-ARCH/kernel/drivers/usb/host/ehci-hcd.ko license: GPL author: David Brownell description: USB 2.0 'Enhanced' Host Controller (EHCI) Driver depends: usbcore intree: Y vermagic: 3.18.0-next-20141209-ARCH SMP preempt mod_unload modversions parm: log2_irq_thresh:log2 IRQ latency, 1-64 microframes (int) parm: park:park setting; 1-3 back-to-back async packets (uint) parm: ignore_oc:ignore bogus hardware overcurrent indications (bool) With modinfo I can locate the path "drivers/usb/host/ehci-hcd.ko" and this is my /workspace/linux-next/drivers/usb/host/ehci*. This is similar what you guys talked. Many thanks guys -- Lucas Tanure +55 (19) 988176559
On Tue, Dec 9, 2014 at 8:42 PM, Lucas Tanure <tanure@linux.com> wrote:
On Tue, Dec 9, 2014 at 7:19 PM, Saket Sinha <saket.sinha89@gmail.com> wrote:
Hi Lucas,
Please find my response inline.
Goal: find drivers that I could start improving ( understand, develop, test , submit ) How : If my machine uses a driver, I can read the code, modify and test in my machine
Suppose you want to improve/change a basic driver you are using for example XFS filesystem.
/lib/modules/<kernel_version>/points to the location of the source code
On my Ubuntu 14.04 machine,
ssinha@ssinha-Latitude-E6440:~$ ls -l /lib/modules/`uname -r`/ total 3852 lrwxrwxrwx 1 root root 40 Sep 23 04:03 build -> /usr/src/linux-headers-3.13.0-37-generic
so the location of the source code is /usr/src/linux-headers-3.13.0-37-generic.
Now go to the fs folder here to get the source code of xfs. ssinha@ssinha-Latitude-E6440:~$ ls -l /usr/src/linux-headers-3.13.0-37-generic/fs/xfs total 8 -rw-r--r-- 1 root root 3839 Jan 20 2014 Kconfig -rw-r--r-- 1 root root 3027 Jan 20 2014 Makefile
Now what I find is that I have only headers not the entire source code.
So the distros don't generally ship with the entire source code. You can get the source code of your running kernel by either the source packages(kernel-src-rpms or kernel-src-deb) of the distros or you can get tar ball of your running kernel from the kernel.org.
So, if I'm able to see where is located the source for a driver that my machine uses, I can modify and test.
Now when you have the source code, change the driver, make sure its enabled in the kernel .config driver, build the entire kernel and boot into your modified kernel. (If your driver is standalone and not dependent on other drivers, you can build its seprately and insmod it without having to build the entire kernel tree.)
Hope that helps.
Regards, Saket Sinha
On Wed, Dec 10, 2014 at 2:23 AM, Davide Gianforte <davide@gengisdave.org> wrote:
In data martedì 9/12/2014 18:45:59, Lucas Tanure ha scritto:
Hi,
How do I list where are the modules that I'm using inside kernel ?
Goal: find drivers that I could start improving ( understand, develop, test , submit ) How : If my machine uses a driver, I can read the code, modify and test in my machine
So, if I'm able to see where is located the source for a driver that my machine uses, I can modify and test.
Ideas ?
Thanks
'lsmod' and 'lspci -k' show your loaded modules and which module is handling a device.
'find /lib/modules/$(uname -r)/kernel $module_name' show you where the module is located; /lib/modules/<kernel_version>/kernel folder tree is equal to the source tree.
Dave
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi,
Thanks for the reply. But, actually, I found one solution, just like what Davide explained.
tanure@archDesk ~ $ modinfo ehci_hcd filename: /lib/modules/3.18.0-next-20141209-ARCH/kernel/drivers/usb/host/ehci-hcd.ko license: GPL author: David Brownell description: USB 2.0 'Enhanced' Host Controller (EHCI) Driver depends: usbcore intree: Y vermagic: 3.18.0-next-20141209-ARCH SMP preempt mod_unload modversions parm: log2_irq_thresh:log2 IRQ latency, 1-64 microframes (int) parm: park:park setting; 1-3 back-to-back async packets (uint) parm: ignore_oc:ignore bogus hardware overcurrent indications (bool)
With modinfo I can locate the path "drivers/usb/host/ehci-hcd.ko" and this is my /workspace/linux-next/drivers/usb/host/ehci*. This is similar what you guys talked.
Many thanks guys
-- Lucas Tanure +55 (19) 988176559
Hi, This command: $ lsmod | grep -Eo '^[^ ]+' | sed 1d | xargs modinfo | grep filename Shows me where is the code that I'm using. So, I can start with these source codes. Thanks -- Lucas Tanure +55 (19) 988176559
On Tue, 09 Dec 2014 22:18:48 -0200, Lucas Tanure said:
This command:
$ lsmod | grep -Eo '^[^ ]+' | sed 1d | xargs modinfo | grep filename
Note that only finds stuff that's been built with CONFIG_FOOMOD=m, Modules that were built into the kernel with =y won't show on an lsmod. On my laptop at the moment: % lsmod | wc -l 34 % ls /sys/module | wc -l 129 Quite obviously, relying on lsmod isn't going to help. So you really want something like: % ls /sys/module | xargs modinfo 2> /dev/null | grep filename % echo the following are built-in; echo `ls /sys/module | xargs modinfo 2>&1 > /dev/null | awk '{print $4}'` The following *seems* to work. I admit I haven't tested it against a distro kernel where the build/ and source/ symlinks may point different places, etc etc... find /lib/modules/`uname -r`/build/ `ls /sys/module | xargs modinfo 2>&1 > /dev/null | awk '{print " -name " $4".o -o"} END {print "-name null"}'` (And even the 129 entries in /sys/module doesn't cover the whole story. find /lib/modules/3.18.0-next-20141208/build/ -name '*.o' | wc -l 4257 zgrep =y /proc/config.gz | wc -l 1072 So there's *lots* more chunks of code that are builtin as options that simply don't identify as "modules". At that point, it's time to re-ask what question you *really* wanted answered. "Find drivers that I'm using" is *not* the same thing as "what modules do I have"....
On Tue, Dec 9, 2014 at 11:50 PM, <Valdis.Kletnieks@vt.edu> wrote:
On Tue, 09 Dec 2014 22:18:48 -0200, Lucas Tanure said:
This command:
$ lsmod | grep -Eo '^[^ ]+' | sed 1d | xargs modinfo | grep filename
Note that only finds stuff that's been built with CONFIG_FOOMOD=m, Modules that were built into the kernel with =y won't show on an lsmod. On my laptop at the moment:
% lsmod | wc -l 34 % ls /sys/module | wc -l 129
Quite obviously, relying on lsmod isn't going to help.
So you really want something like:
% ls /sys/module | xargs modinfo 2> /dev/null | grep filename % echo the following are built-in; echo `ls /sys/module | xargs modinfo 2>&1 > /dev/null | awk '{print $4}'`
The following *seems* to work. I admit I haven't tested it against a distro kernel where the build/ and source/ symlinks may point different places, etc etc...
find /lib/modules/`uname -r`/build/ `ls /sys/module | xargs modinfo 2>&1 > /dev/null | awk '{print " -name " $4".o -o"} END {print "-name null"}'`
(And even the 129 entries in /sys/module doesn't cover the whole story.
find /lib/modules/3.18.0-next-20141208/build/ -name '*.o' | wc -l 4257 zgrep =y /proc/config.gz | wc -l 1072
So there's *lots* more chunks of code that are builtin as options that simply don't identify as "modules". At that point, it's time to re-ask what question you *really* wanted answered. "Find drivers that I'm using" is *not* the same thing as "what modules do I have"....
Hi, I'm interested only in drivers that my machine uses, just because I can test it. lsmod seems a good start. In /sys/modules I can find more drivers to work too. With : $ ls -l /sys/module/ | awk '{print $9}' | xargs modinfo > /dev/null I can find drivers that are not modules. And for these I will need to lookup for the source inside kernel. Thanks -- Lucas Tanure +55 (19) 988176559
participants (5)
-
Bjørn Mork -
Davide Gianforte -
Lucas Tanure -
Saket Sinha -
Valdis.Kletnieks@vt.edu