From e0cd97ce46a326e140c5335c718c32818c24913d Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 20 Mar 2009 14:08:43 +0000 Subject: [PATCH] Don't call an external tool (ls) to get the list of dimms. Using opendir() is more efficient and more flexible. git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@5691 7894878c-1315-0410-8ee3-d5d059ff63e0 --- eeprom/decode-dimms | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/eeprom/decode-dimms b/eeprom/decode-dimms index 4a3d9cb..b53be36 100755 --- a/eeprom/decode-dimms +++ b/eeprom/decode-dimms @@ -1615,7 +1615,7 @@ my $dimm_count = 0; sub get_dimm_list { - my $dir; + my ($dir, $file, @files); if ($use_sysfs) { $dir = '/sys/bus/i2c/drivers/eeprom'; @@ -1623,8 +1623,13 @@ sub get_dimm_list $dir = '/proc/sys/dev/sensors'; } - if (-d $dir) { - return split(/\s+/, `ls $dir`); + if (opendir(local *DIR, $dir)) { + while (defined($file = readdir(DIR))) { + next if $file =~ m/^\./; + push @files, $file; + } + close(DIR); + return sort @files; } elsif (! -d '/sys/module/eeprom') { print "No EEPROM found, are you sure the eeprom module is loaded?\n"; exit;