2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-30 22:05:11 +00:00

sensors-detect: Use modules.builtin instead of /sys/module

/sys/module doesn't actually contain all built-in modules, only the
ones which have a version or at least one parameter. Better use file
modules.builtin which is generated since kernel 2.6.33, it is complete
and this will let us handle built-in modules properly.
This commit is contained in:
Jean Delvare
2013-06-10 13:02:47 +00:00
parent b0e1a6333e
commit 256811bc9e
2 changed files with 13 additions and 12 deletions

View File

@@ -2616,11 +2616,12 @@ sub initialize_conf
# [2] -> SUBLEVEL
# [3] -> EXTRAVERSION
#
use vars qw(@kernel_version $kernel_arch);
use vars qw($kernel_version @kernel_version $kernel_arch);
sub initialize_kernel_version
{
`uname -r` =~ /(\d+)\.(\d+)\.(\d+)(.*)/;
chomp($kernel_version = `uname -r`);
$kernel_version =~ /(\d+)\.(\d+)\.(\d+)(.*)/;
@kernel_version = ($1, $2, $3, $4);
chomp($kernel_arch = `uname -m`);
@@ -2792,20 +2793,19 @@ use vars qw(%modules_list %modules_supported @modules_we_loaded);
sub initialize_modules_list
{
local $_;
local ($_, *INPUTFILE);
# /sys/module contains built-in drivers too, but doesn't exist on
# older kernels (added in kernel 2.6.7)
if (opendir(local *MODULES, "$sysfs_root/module")) {
while (defined($_ = readdir(MODULES))) {
next if m/^\./;
$modules_list{$1} = 1 if m/^(\S*)/;
# Starting with kernel 2.6.33, a list of built-in modules is available
if (open(*INPUTFILE, "/lib/modules/$kernel_version/modules.builtin")) {
while (<INPUTFILE>) {
tr/-/_/;
$modules_list{$1} = 1 if m/\/([^\/]+)\.ko$/;
}
return;
close(INPUTFILE);
}
# Fall back to /proc/modules as it is always available
open(local *INPUTFILE, "/proc/modules") or return;
# List all loaded modules
open(*INPUTFILE, "/proc/modules") or return;
while (<INPUTFILE>) {
$modules_list{$1} = 1 if m/^(\S*)/;
}