sensors/lm_sensors-2.10.2.dif

671 lines
20 KiB
Plaintext
Raw Blame History

--- Makefile
+++ Makefile 2006-11-10 15:39:03.000000000 +0100
@@ -45,8 +45,8 @@ LINUX_HEADERS := $(LINUX)/include
# may be used mistakenly. Note: This should point to the directory
# *above* the linux/ subdirectory, so to /usr/local/include in the
# above example.
-I2C_HEADERS := /usr/local/include
-#I2C_HEADERS := $(LINUX_HEADERS)
+#I2C_HEADERS := /usr/local/include
+I2C_HEADERS := $(LINUX_HEADERS)
ifneq ($(MAKECMDGOALS),user)
ifneq ($(MAKECMDGOALS),user_install)
@@ -75,7 +75,7 @@ DEBUG := 0
DESTDIR :=
# This is the prefix that will be used for almost all directories below.
-PREFIX := /usr/local
+PREFIX := /usr
# Your C compiler
CC := gcc
@@ -97,7 +97,7 @@ ifeq (,$(findstring /2.4., $(MODPREF)))
else
SYSFS_SUPPORT :=
endif
-#SYSFS_SUPPORT := 1
+SYSFS_SUPPORT := 1
# Prevent 2.6+ users from using improper targets, as this won't work.
ifeq (,$(findstring /2.4., $(MODPREF)))
@@ -141,7 +141,7 @@ LIBINCLUDEDIR := $(INCLUDEDIR)/sensors
# You should not need to change this. It is the base directory under which the
# manual pages will be installed.
-MANDIR := $(PREFIX)/man
+MANDIR := $(PREFIX)/share/man
MACHINE := $(shell uname -m)
@@ -216,7 +216,7 @@ ifeq ($(DEBUG),1)
ALL_CPPFLAGS += -DDEBUG
ALL_CFLAGS += -O -g
else
-ALL_CFLAGS += -O2
+ALL_CFLAGS += $(RPM_OPT_FLAGS)
endif
ifeq ($(WARN),1)
@@ -279,7 +279,7 @@ LIBCPPFLAGS := $(ALL_CPPFLAGS)
ifdef SYSFS_SUPPORT
LIBCPPFLAGS := $(LIBCPPFLAGS) -DSYSFS_SUPPORT
endif
-LIBCFLAGS := -fpic $(ALL_CFLAGS)
+LIBCFLAGS := -fpic -D_REENTRANT $(ALL_CFLAGS)
.PHONY: all user clean install user_install uninstall user_uninstall version package
--- prog/detect/sensors-detect
+++ prog/detect/sensors-detect 2006-11-10 17:45:13.000000000 +0100
@@ -2106,7 +2106,9 @@ sub initialize_conf
}
}
- if (-f '/etc/modules.conf') {
+ if (-f '/etc/modprobe.conf') {
+ $modules_conf = '/etc/modprobe.conf';
+ } elsif (-f '/etc/modules.conf') {
$modules_conf = '/etc/modules.conf';
} elsif (-f '/etc/conf.modules') {
$modules_conf = '/etc/conf.modules';
@@ -5406,7 +5408,7 @@ sub generate_modprobes
$modprobes .= "# I2C adapter drivers\n" if $nr;
for ($i = 0; $i < $nr; $i++) {
foreach $adap (@adapters) {
- next unless exists $adap->{nr_later} and $adap->{nr_later} == $i;
+ next unless exists $adap->{driver} and $adap->{nr_later} == $i;
if ($adap->{driver} eq "UNKNOWN") {
$modprobes .= "# modprobe unknown adapter ".$adap->{adapname}."\n";
} elsif ($adap->{driver} eq "DISABLED") {
@@ -5436,6 +5438,19 @@ sub generate_modprobes
next if $chip->{driver} eq "use-isa-instead";
if ($chip->{driver} eq "to-be-written") {
$modprobes .= "# no driver for $chip->{detected}[0]{chipname} yet\n";
+ } elsif ($chip->{driver} eq "w83627hf") {
+ my $check = 0;
+ open MODPROBE, "modprobe -l w83627hf|" or die "can not execute modprobe\n";
+ while (<MODPROBE>) {
+ $check = /^.*w83627hf.*$/;
+ }
+ close MODPROBE;
+ if ($check) {
+ $modprobes .= "modprobe $chip->{driver}\n";
+ } else {
+ $modprobes .= "# no driver for ".$chip->{detected}[0]{chipname}." using w83781d\n";
+ $modprobes .= "modprobe w83781d\n"
+ }
} else {
# need the * for 2.4 kernels, won't necessarily be an exact match
open(local *INPUTFILE, "modprobe -l $chip->{driver}\\* 2>/dev/null |");
@@ -5714,7 +5729,7 @@ sub main
print "#----cut here----\n".
$modprobes.
"# sleep 2 # optional\n".
- "/usr/local/bin/sensors -s # recommended\n".
+ "/usr/bin/sensors -s # recommended\n".
"#----cut here----\n\n";
print "If you have some drivers built into your kernel, the list above will\n".
@@ -5783,6 +5798,8 @@ EOT
print "Copy prog/init/lm_sensors.init to /etc/init.d/lm_sensors\n".
"for initialization at boot time.\n"
unless -f "/etc/init.d/lm_sensors";
+ system("/sbin/insserv", "/etc/init.d/lm_sensors")
+ if -f "/etc/init.d/lm_sensors";
}
}
--- prog/dump/isadump.c
+++ prog/dump/isadump.c 2006-02-28 13:05:01.000000000 +0100
@@ -35,15 +35,26 @@
#include "util.h"
#include "superio.h"
-
/* To keep glibc2 happy */
#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 0
-#include <sys/io.h>
+# if !defined(__sparc__) && !defined(__sparc64__) && !defined(__powerpc__)
+# include <sys/io.h>
+# else
+#ifdef __powerpc__
+#define __KERNEL__
+#define CONFIG_ALL_PPC
+#endif
+# include <asm/io.h>
+#ifdef __powerpc__
+#undef __KERNEL__
+#undef CONFIG_ALL_PPC
+#endif
+# endif
#else
-#include <asm/io.h>
+# include <asm/io.h>
#endif
-#ifdef __powerpc__
+#if defined(__powerpc__) || defined(__sparc__) || defined(__sparc64__)
unsigned long isa_io_base = 0; /* XXX for now */
#endif /* __powerpc__ */
@@ -252,7 +263,7 @@ int main(int argc, char *argv[])
}
}
-#ifndef __powerpc__
+#if !defined(__sparc__) && !defined(__sparc64__) && !defined(__powerpc__)
if ((datareg < 0x400) && (addrreg < 0x400) && !flat) {
if (ioperm(datareg, 1, 1)) {
fprintf(stderr, "Error: Could not ioperm() data "
--- prog/init/README
+++ prog/init/README 2006-02-28 13:05:01.000000000 +0100
@@ -10,7 +10,7 @@ The script lm_sensors.init is a nice sta
On RH and other RH-based systems (MDK, notably) use this sort of startup
mechanism (i.e. SVR4-based), as opposed to the everything-in-one-script
(/etc/rc or /etc/rc.local) like the BSD-based systems do.
-The lm_sensors.init file should be copied to /etc/rc.d/init.d/lm_sensors.
+The lm_sensors.init file should be copied to /etc/init.d/lm_sensors.
For more information see the top of the file.
It requires the /etc/sysconfig/sensors file, which identifies
the correct modules.
@@ -28,10 +28,10 @@ by Marc Rieffel <marc@paracel.com>.
----------------
The script sensord.init also loads the modules, and then
-starts the sensord daemon. See the directory ../sensord for
+starts the sensord daemon. See the manual page sensord(8) for
more information on the daemon.
-The sensord.init file should be copied to /etc/rc.d/init.d/sensord.
+The sensord.init file should be copied to /etc/init.d/sensord.
For more information see the top of the file.
To configure this service one should put appropriate "alias i2c-bus-0 xxx"
--- prog/init/lm_sensors.init.suse
+++ prog/init/lm_sensors.init.suse 2006-02-28 13:05:01.000000000 +0100
@@ -1,19 +1,14 @@
#!/bin/sh
#
### BEGIN INIT INFO
-# Provides: lm_sensors
-# Required-Start: $local_fs
-# X-UnitedLinux-Should-Start:
-# Required-Stop: $local_fs
-# X-UnitedLinux-Should-Stop:
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 2 6
-# Short-Description: LM Sensors
-# Description: LM Sensors for hardware monitoring
+# Provides: sensors
+# Required-Start: $remote_fs
+# Required-Stop: $remote_fs
+# Default-Start: 2 3 5
+# Default-Stop:
+# Description: sensors is used for monitoring motherboard sensor values.
+# Config file is /etc/sysconfig/lm_sensors
### END INIT INFO
-# chkconfig: 2345 26 74
-# description: sensors is used for monitoring motherboard sensor values.
-# config: /etc/sysconfig/sensors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -40,115 +35,91 @@
# MODULE_1, MODULE_2, MODULE_3, etc.
# If sensors isn't supported by the kernel, try loading the module...
-[ -e /proc/sys/dev/sensors ] || /sbin/modprobe i2c-proc &>/dev/null
+[ -e /sys/bus/i2c/devices ] || /sbin/modprobe i2c-dev &>/dev/null
# Don't bother if /proc/sensors still doesn't exist, kernel doesn't have
# support for sensors.
-[ -e /proc/sys/dev/sensors ] || exit 0
-
+[ -e /sys/bus/i2c/devices ] || exit 0
+
# If sensors was not already running, unload the module...
-[ -e /var/lock/subsys/lm_sensors ] || /sbin/modprobe -r i2c-proc &>/dev/null
+[ -e /var/lock/subsys/sensors ] || /sbin/modprobe -r i2c-dev &>/dev/null
CONFIG=/etc/sysconfig/lm_sensors
-PSENSORS=/usr/local/bin/sensors
+PSENSORS=/usr/bin/sensors
+FANCONFIG=/etc/fancontrol
+PFAN=/usr/sbin/fancontrol
# Source function library.
-#. /etc/init.d/functions
-
-# Shell functions sourced from /etc/rc.status:
-# rc_check check and set local and overall rc status
-# rc_status check and set local and overall rc status
-# rc_status -v ditto but be verbose in local rc status
-# rc_status -v -r ditto and clear the local rc status
-# rc_status -s display "skipped" and exit with status 3
-# rc_status -u display "unused" and exit with status 3
-# rc_failed set local and overall rc status to failed
-# rc_failed <num> set local and overall rc status to <num>
-# rc_reset clear local rc status (overall remains)
-# rc_exit exit appropriate to overall rc status
-# rc_active checks whether a service is activated by symlinks
-# rc_splash arg sets the boot splash screen to arg (if active)
. /etc/rc.status
-# Reset status of this service
-rc_reset
-
-# Return values acc. to LSB for all commands but status:
-# 0 - success
-# 1 - generic or unspecified error
-# 2 - invalid or excess argument(s)
-# 3 - unimplemented feature (e.g. "reload")
-# 4 - user had insufficient privileges
-# 5 - program is not installed
-# 6 - program is not configured
-# 7 - program is not running
-# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
-#
-# Note that starting an already running service, stopping
-# or restarting a not-running service as well as the restart
-# with force-reload (in case signaling is not supported) are
-# considered a success.
-
-RETVAL=0
-
start() {
- echo -n $"Starting up sensors: "
+ echo -n "Starting up sensors"
+ unset ${!MODULE_*}
test -r "$CONFIG" && . "$CONFIG"
- modules=`grep \^MODULE_ $CONFIG | wc -l | tr -d ' '`
- i=0
- while [ $i -lt $modules ] ; do
- module=`eval echo '$'MODULE_$i`
- echo starting module __${module}__
+ for i in ${!MODULE_*} ; do
+ eval module=\$$i
/sbin/modprobe $module &>/dev/null
- i=`expr $i + 1`
+ rc_status
done
- $PSENSORS -s
+ rc_status
- RETVAL=$?
- if [ $RETVAL -eq 0 ] && touch /var/lock/subsys/lm_sensors ; then
- rc_status -v
+ /usr/bin/sensors -s &> /dev/null
+ rc_status
+
+ # Start fan control, if configured
+ if test -s "$FANCONFIG" -a -x "$PFAN" ; then
+ echo -n ", starting fan control: "
+ /sbin/startproc -q "$PFAN"
+ rc_status
else
- rc_status -v
+ echo -n ": "
fi
+
+ rc_status -v && touch /var/lock/subsys/sensors
}
stop() {
- echo -n $"Shutting down sensors: "
+ echo -n "Shutting down sensors"
+ unset ${!MODULE_*}
test -r "$CONFIG" && . "$CONFIG"
- modules=`grep \^MODULE_ $CONFIG | wc -l | tr -d ' '`
- i=`expr $modules`
- while [ $i -ge 0 ] ; do
- module=`eval echo '$'MODULE_$i`
+ # Stop fan control, if it was started
+ if test -s /var/run/fancontrol.pid ; then
+ echo -n ", stopping fan control: "
+ /sbin/killproc -TERM "$PFAN"
+ rc_status
+ else
+ echo -n ": "
+ fi
+
+ for i in ${!MODULE_*} ; do
+ eval module=\$$i
/sbin/modprobe -r $module &>/dev/null
- i=`expr $i - 1`
+ rc_status
done
- /sbin/modprobe -r i2c-proc &>/dev/null
- RETVAL=$?
- if [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/lm_sensors ; then
- rc_status -v
- else
- rc_status -v
- fi
+ rc_status -v && rm -f /var/lock/subsys/sensors
}
dostatus() {
- $PSENSORS
- RETVAL=$?
+ $PSENSORS
+ rc_status
}
restart() {
stop
start
- RETVAL=$?
+ rc_status
}
condrestart() {
[ -e /var/lock/subsys/lm_sensors ] && restart || :
}
+# Reset status of this service
+rc_reset
+
# See how we were called.
case "$1" in
start)
@@ -163,12 +134,12 @@ case "$1" in
restart|reload)
restart
;;
- condrestart)
+ try-restart)
condrestart
;;
*)
- echo "Usage: sensors.init {start|stop|status|restart|reload|condrestart}"
+ echo "Usage: lm_sensors {start|stop|status|restart|reload|try-restart}"
exit 1
esac
-exit $RETVAL
+rc_exit
--- prog/init/sensord.init
+++ prog/init/sensord.init 2006-02-28 13:05:01.000000000 +0100
@@ -1,130 +1,83 @@
-#!@BASH@
+#!/bin/bash
#
-# @INITRDDIR@/sensord
-#
-# sensord This shell script takes care of starting and stopping
-# sensord, the lm_sensors hardware health monitoring daemon.
-#
-# Here is the sensors service for SysV init, based on lm_sensors-2.5.5-sensors
-# from Mandrake lm_sensors source RPM. It is modified according to recommendations
-# for RedHat initscripts. The drivers starting part is taken from alsasound
-# service. To configure this service one should put appropriate "alias i2c-bus-0
-# xxx" and "alias i2c-sensors-chip-0 xxx" in /etc/modules.conf. The rest should be
-# self explaining.
-#
-# You put it into /etc/rc.d/init.d/, you make a symlink (probably using
-# chkconfig, ntsysv, tksysv or serviceconf program) named S95xxx and K05xxx
-# into /etc/rc#.d (where # is the number of runlevel), and sensors service
-# (which starts lm_sensors modules, runs sensors -s and starts sensord)
-# will be started automatically at startup/reboot and stopped at shutdown.
-# One could also start/stop service manually.
-#
-# This service was tested for RedHat 7.2 only.
-# Jakub Nar<61>bski, Poland
+# /etc/init.d/sensord
#
+### BEGIN INIT INFO
+# Provides: sensors
+# Required-Start: $remote_fs
+# Required-Stop: $remote_fs
+# Default-Start: 2 3 5
+# Default-Stop:
+# Description: This shell script takes care of starting and stopping
+# sensord, the lm_sensors hardware health monitoring daemon.
+### END INIT INFO
-# chkconfig: 2345 05 95
-# processname: sensord
-# config: @SYSCONFDIR@/sensors.conf
-# pidfile: /var/run/sensord.pid
-# description: Sensors is a sensors daemon which can be used to alert you \
-# in the event of a hardware health monitoring alarm.
# Source function library.
-. @INITRDDIR@/functions
-
-# Set default return value to 0 (success)
-RETVAL=0
-# Add @SBINDIR@ (sensord) and @BINDIR@ (sensors) to PATH if necessary
-echo "$PATH" | grep -q @SBINDIR@ || PATH=$PATH:@SBINDIR@
-echo "$PATH" | grep -q @BINDIR@ || PATH=$PATH:@BINDIR@
-export PATH
+. /etc/rc.status
# Modules to load from modules.conf (modules configuration)
-i2c_bus_drivers=<3D>modprobe -c | \
- awk <20>/^[[:space:]]*alias[[:space:]]+i2c-bus-[[:digit:]]/ { print $3 }<7D><>
-i2c_chip_drivers=<3D>modprobe -c | \
- awk <20>/^[[:space:]]*alias[[:space:]]+i2c-sensors-chip-[[:digit:]]/ { print $3
-}<7D><>
+i2c_bus_drivers=`modprobe -c | \
+ awk '/^[[:space:]]*alias[[:space:]]+i2c-bus-[[:digit:]]/ { print $3 }'`
+i2c_chip_drivers=`modprobe -c | \
+ awk '/^[[:space:]]*alias[[:space:]]+i2c-sensors-chip-[[:digit:]]/ { print $3 }'`
# Configuration of sensord
interval=1m # interval between scanning for sensor alarms
log_interval=30m # interval between logging all sensor readings
-# Check that we use kernel for which lm_sensors-drivers was installed
-[ <20>uname -r<> = @MVERSION@ ] || exit 0
-
# Check that lm_sensors is installed.
-[ -x @SBINDIR@/sensord ] || exit 0
-[ -x @BINDIR@/sensors ] || exit 0
-
-echo_status()
-{
- if [ $1 -eq 0 ]; then
- echo_success
- else
- echo_failure
- fi
- echo
-}
+[ -x /usr/sbin/sensord ] || exit 0
+[ -x /usr/bin/sensors ] || exit 0
start()
{
# Start modules
echo "Starting I2C bus (adapter) drivers: "
for driver in $i2c_bus_drivers; do
- echo -n "Starting I2C driver: $driver "
- /sbin/modprobe <20>echo $driver<65>
- echo_status $?
+ /sbin/modprobe $driver &> /dev/null
+ rc_status
done
+ rc_status -v
+
echo "Starting I2C chip (sensors) drivers: "
for driver in $i2c_chip_drivers; do
- echo -n "Starting I2C driver: $driver "
- /sbin/modprobe $(echo $driver)
- echo_status $?
+ /sbin/modprobe $driver &> /dev/null
+ rc_status
done
+ rc_status -v
+
# Set Alarm
echo -n "Configuring sensors: "
- sensors -s && sleep 2
+ sensors -s
+ rc_status && sleep 2
+ rc_status -v
+
echo_status $?
# Start daemons.
echo -n $"Starting sensord: "
- daemon sensord -i $interval -l $log_interval
- RETVAL=$?
-
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sensord
-
- echo
- return $RETVAL
+ startproc /usr/sbin/sensord -i $interval -l $log_interval
+ rc_status -v && touch /var/lock/subsys/sensord
}
stop()
{
# Stop daemons.
echo -n $"Shutting down sensord: "
- killproc sensord
- RETVAL=$?
+ killproc /usr/sbin/sensord
+ rc_status -v
- echo
# Remove modules
- drivers=<3D>echo "$i2c_chip_drivers $i2c_bus_drivers" | \
- tr -s "[:space:]\n" " "<22>
- echo -n "Removing I2C drivers: $drivers"
- /sbin/modprobe -r -q $drivers
- echo_status $?
-
- echo
- [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sensord
-
- return $RETVAL
+ echo -n "Removing I2C drivers: " $i2c_chip_drivers $i2c_bus_drivers
+ /sbin/modprobe -r -q $i2c_chip_drivers $i2c_bus_drivers
+ rc_status -v && rm -f /var/lock/subsys/sensord
}
reload()
{
# Reread configuration file
sensors -s
-
- return $?
+ rc_status
}
# See how we were called.
@@ -135,9 +88,6 @@ case "$1" in
stop)
stop
;;
- status)
- status sensord
- ;;
restart)
stop
start
@@ -145,11 +95,11 @@ case "$1" in
reload)
reload
;;
- condrestart)
+ try-restart)
[ -e /var/lock/subsys/sensord ] && restart || :
;;
*)
- echo "Usage: sensord {start|stop|restart|reload|condrestart|status}"
+ echo "Usage: sensord {start|stop|restart|reload|try-restart|status}"
exit 1
;;
esac
--- prog/pwm/fancontrol
+++ prog/pwm/fancontrol 2006-02-28 13:05:01.000000000 +0100
@@ -188,10 +188,10 @@ function restorefans()
do
pwmo=${AFCPWM[$fcvcount]}
pwmdisable $pwmo
- fcvcount=$fcvcount+1
+ let fcvcount=$fcvcount+1
done
echo 'Verify fans have returned to full speed'
- exit 1
+ exit 0
}
trap restorefans SIGHUP SIGINT SIGQUIT SIGTERM SIGKILL
@@ -274,7 +274,7 @@ function UpdateFanSpeeds {
if [ $pwmpval -eq 0 -o $fanval -eq 0 ]
then # if fan was stopped start it using a safe value
echo $minsa > $pwmo
- sleep 1
+ read < <(exec sleep 1)
fi
fi
echo $pwmval > $pwmo # write new value to pwm output
@@ -287,7 +287,7 @@ function UpdateFanSpeeds {
then
echo "new pwmval=$pwmval"
fi
- fcvcount=$fcvcount+1
+ let fcvcount=$fcvcount+1
done
}
@@ -302,7 +302,7 @@ do
echo "Error enabling PWM on $DIR/$pwmo"
restorefans
fi
- fcvcount=$fcvcount+1
+ let fcvcount=$fcvcount+1
done
echo 'Starting automatic fan control...'
@@ -311,7 +311,7 @@ echo 'Starting automatic fan control...'
while true
do
UpdateFanSpeeds
- sleep $INTERVAL
+ read < <(exec sleep $INTERVAL)
done
# some old stuff/missing features, will clean this up soon
--- prog/pwm/pwmconfig
+++ prog/pwm/pwmconfig 2006-02-28 13:05:01.000000000 +0100
@@ -248,6 +248,9 @@ echo
PLOTTER=gnuplot
STEP=15
PDELAY=2
+STEP2=2
+STEP2_BELOW=31
+PDELAY=3
function pwmdetail()
{
@@ -315,6 +318,7 @@ function pwmdetail()
fi
break
fi
+ test $pwm -lt $STEP2_BELOW && let STEP=$STEP2
let pwm=$pwm-$STEP
done
pwmdisable $P
--- prog/sensors/main.c
+++ prog/sensors/main.c 2007-01-30 17:26:00.000000000 +0100
@@ -187,6 +187,11 @@ int main (int argc, char *argv[])
exit(0);
case 'c':
config_file_name = optarg;
+ if (!config_file_name || *config_file_name == '\0') {
+ fprintf(stderr, "Could not open config file\n");
+ perror(config_file_name);
+ exit(1);
+ }
break;
case 's':
do_sets = 1;