kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* List my Staging Drivers
@ 2014-12-09 20:45 Lucas Tanure
  2014-12-09 20:53 ` Davide Gianforte
  2014-12-09 21:04 ` Bjørn Mork
  0 siblings, 2 replies; 8+ messages in thread
From: Lucas Tanure @ 2014-12-09 20:45 UTC (permalink / raw)
  To: kernelnewbies

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* List my Staging Drivers
  2014-12-09 20:45 List my Staging Drivers Lucas Tanure
@ 2014-12-09 20:53 ` Davide Gianforte
  2014-12-09 21:19   ` Saket Sinha
  2014-12-09 21:04 ` Bjørn Mork
  1 sibling, 1 reply; 8+ messages in thread
From: Davide Gianforte @ 2014-12-09 20:53 UTC (permalink / raw)
  To: kernelnewbies

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* List my Staging Drivers
  2014-12-09 20:45 List my Staging Drivers Lucas Tanure
  2014-12-09 20:53 ` Davide Gianforte
@ 2014-12-09 21:04 ` Bjørn Mork
  1 sibling, 0 replies; 8+ messages in thread
From: Bjørn Mork @ 2014-12-09 21:04 UTC (permalink / raw)
  To: kernelnewbies

Lucas Tanure <tanure@linux.com> writes:

> How do I list where are the modules that I'm using inside kernel ?

 lsmod

The actual drivers you are using:

 ls -l /sys/bus/*/devices/*/driver

Or look at the output of lsusb, lspci etc.


Bj?rn

^ permalink raw reply	[flat|nested] 8+ messages in thread

* List my Staging Drivers
  2014-12-09 20:53 ` Davide Gianforte
@ 2014-12-09 21:19   ` Saket Sinha
  2014-12-09 22:42     ` Lucas Tanure
  0 siblings, 1 reply; 8+ messages in thread
From: Saket Sinha @ 2014-12-09 21:19 UTC (permalink / raw)
  To: kernelnewbies

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 at 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 at 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 at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 8+ messages in thread

* List my Staging Drivers
  2014-12-09 21:19   ` Saket Sinha
@ 2014-12-09 22:42     ` Lucas Tanure
  2014-12-10  0:18       ` Lucas Tanure
  0 siblings, 1 reply; 8+ messages in thread
From: Lucas Tanure @ 2014-12-09 22:42 UTC (permalink / raw)
  To: 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 at 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 at 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 at 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 at 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* List my Staging Drivers
  2014-12-09 22:42     ` Lucas Tanure
@ 2014-12-10  0:18       ` Lucas Tanure
  2014-12-10  1:50         ` Valdis.Kletnieks at vt.edu
  0 siblings, 1 reply; 8+ messages in thread
From: Lucas Tanure @ 2014-12-10  0:18 UTC (permalink / raw)
  To: kernelnewbies

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 at 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 at 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 at 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 at 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* List my Staging Drivers
  2014-12-10  0:18       ` Lucas Tanure
@ 2014-12-10  1:50         ` Valdis.Kletnieks at vt.edu
  2014-12-10 13:21           ` Lucas Tanure
  0 siblings, 1 reply; 8+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2014-12-10  1:50 UTC (permalink / raw)
  To: kernelnewbies

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"....


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20141209/abfc9ed0/attachment.bin 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* List my Staging Drivers
  2014-12-10  1:50         ` Valdis.Kletnieks at vt.edu
@ 2014-12-10 13:21           ` Lucas Tanure
  0 siblings, 0 replies; 8+ messages in thread
From: Lucas Tanure @ 2014-12-10 13:21 UTC (permalink / raw)
  To: kernelnewbies

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-12-10 13:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-09 20:45 List my Staging Drivers Lucas Tanure
2014-12-09 20:53 ` Davide Gianforte
2014-12-09 21:19   ` Saket Sinha
2014-12-09 22:42     ` Lucas Tanure
2014-12-10  0:18       ` Lucas Tanure
2014-12-10  1:50         ` Valdis.Kletnieks at vt.edu
2014-12-10 13:21           ` Lucas Tanure
2014-12-09 21:04 ` Bjørn Mork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).