Bug 118661 - kmod : why does modinfo not report built-in modules - please can it be made to do so ?
Summary: kmod : why does modinfo not report built-in modules - please can it be made t...
Status: NEW
Alias: None
Product: Tools
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Tools.Other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-21 17:37 UTC by Jason Vas Dias
Modified: 2016-06-30 10:55 UTC (History)
1 user (show)

See Also:
Kernel Version: all
Subsystem:
Regression: No
Bisected commit-id:


Attachments
patch against kmod v22 tools/modinfo.c (1.03 KB, text/plain)
2016-05-21 18:29 UTC, Jason Vas Dias
Details
patch against kmod v22 tools/modinfo.c (1.18 KB, application/octet-stream)
2016-05-21 18:53 UTC, Jason Vas Dias
Details
patch against kmod v22 tools/modinfo.c (2.78 KB, text/plain)
2016-05-21 20:11 UTC, Jason Vas Dias
Details
patch against kmod v22 tools/modinfo.c (3.91 KB, text/plain)
2016-05-21 20:49 UTC, Jason Vas Dias
Details

Description Jason Vas Dias 2016-05-21 17:37:10 UTC
I believe the choice of whether to make a module built-in to the
kernel or not should be up to the user via KConfig / 'make *config'.

But because modinfo (alias kmod these days) only interrogates LOADED
modules, not enabled modules built-in to the kernel, scripts cannot
use it to determine if the kernel has a module 'capability', as they
naively tend to do. 

So for instance I have all needed modules necessary to support audio 
+ alsa built-in to my kernel, yet no sound on my system because the 
alsa-utils scripts use modinfo in this way, and do not check if the 
module is built-in or not.

Please could the modinfo program (ie. kmod) support something like a
new '-S' (use sysfs) option to make it exclusively lookup modules first
in /sys/module and only then using whatever method it was using before -
perhaps this should be the default ?

Since I'd like sound soon, I'm going to work now on hacking something
like this together and will post patch back here in the hope it might
be useful.
Comment 1 Jason Vas Dias 2016-05-21 17:54:47 UTC
Something like this perhaps at the end of
kmod/tools/modinfo.c @ line 459:
...
        kmod_unref(ctx);

   // added lines:
        if( 0 > err )
          if( 0 < snprintf(dir_name_buf,PATH_MAX,"/sys/modules/%s", name))
            err = (access( dir_name_buf, F_OK ) == 0) ? 0 : 1;
   // end addition     

	return err >= 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
Comment 2 Jason Vas Dias 2016-05-21 17:56:09 UTC
Oops, "/sys/modules/%s" should be "/sys/module/%s" in previous comment.
Comment 3 Jason Vas Dias 2016-05-21 18:29:40 UTC
Created attachment 217041 [details]
patch against kmod v22 tools/modinfo.c

This patch fixes the problem . If there was a name given, and the first
lookup fails, then if the file :
   /sys/module/$name
exists, return OK .
Comment 4 Jason Vas Dias 2016-05-21 18:53:51 UTC
Created attachment 217051 [details]
patch against kmod v22 tools/modinfo.c

Patch that fixes problem .
Example output without patch:
$ modinfo -p snd
modinfo: ERROR: Module snd not found
$ echo $?
1
Example output with patch:
$ modinfo -p snd
modinfo: ERROR: Module snd not found.
built-in: snd
$ echo $?
0
Comment 5 Jason Vas Dias 2016-05-21 20:11:59 UTC
Created attachment 217061 [details]
patch against kmod v22 tools/modinfo.c

better patch - output now like:
$ modinfo -p snd
modinfo: ERROR: Module snd not found.
built-in: snd  major=116  cards_limit=1  cards_limit=1
$ echo $?
0
Comment 6 Jason Vas Dias 2016-05-21 20:49:24 UTC
Created attachment 217071 [details]
patch against kmod v22 tools/modinfo.c

Final version of patch to make modinfo show built-in modules. 
Output now like:

$ modinfo -d snd
modinfo: ERROR: Module snd not found.
built-in: snd author=TheLinuxDevelopers description=snd license=GPL filename=/sys/module/snd  major=116  cards_limit=1
Comment 7 pkozlov 2016-06-30 10:55:53 UTC
Agree that it is needed to modinfo to work for built-in modules. I have i915 built-in and what to see information about it.

$ modinfo i915
modinfo: ERROR: Module i915 not found.

Note You need to log in before you can comment on or make changes to this bug.