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.
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; }
Oops, "/sys/modules/%s" should be "/sys/module/%s" in previous comment.
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 .
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
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
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
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.