fancontrol: Fix handling of absolute paths in config
PATCH 1/1 fancontrol: Fix handling of absolute paths in config
The following patch fixes the fancontrol script so it can handle absolute filenames again.
Marc
pwm/fancontrol +11 -8
@@ -289,16 +289,19 @@ cd $DIR # Check for configuration change -if [ -z "$DEVPATH" -o -z "$DEVNAME" ] +if [ "$DIR" != "/" ] then - echo "Configuration is too old, please run pwmconfig again" >&2 - exit 1 + if [ -z "$DEVPATH" -o -z "$DEVNAME" ] + then + echo "Configuration is too old, please run pwmconfig again" >&2 + exit 1 + fi + if ! ValidateDevices "$DEVPATH" "$DEVNAME" + then + echo "Configuration appears to be outdated, please run pwmconfig again" >&2 + exit 1 + fi fi -if ! ValidateDevices "$DEVPATH" "$DEVNAME" -then - echo "Configuration appears to be outdated, please run pwmconfig again" >&2 - exit 1 -fi CheckFiles || exit 1 if [ -f "$PIDFILE" ]
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Marc,
Quoted 2 lines · Marc Ferland
The following patch fixes the fancontrol script so it can handle absolute filenames again.
Thanks for the report and the patch, and sorry for the long delay.
You are right that DEVPATH and DEVNAME shouldn't be mandatory when using absolute paths in the fancontrol configuration file. DEVPATH doesn't even make sense in that case.
However DEVNAME does still make sense. Using absolute paths doesn't guarantee that the device you point to after reboot is the same as the one you configured originally, unfortunately. Specifically, i2c bus numbers aren't guaranteed to be persistent over reboot. So your patch is good to get things working again but it prevents the user from asking fancontrol to check the device name when using absolute paths.
Thus I would prefer the more flexible change below:
--- prog/pwm/fancontrol | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
prog/pwm/fancontrol +6 -1
@@ -291,11 +291,16 @@ fi cd $DIR # Check for configuration change -if [ -z "$DEVPATH" -o -z "$DEVNAME" ] +if [ "$DIR" != "/" ] && [ -z "$DEVPATH" -o -z "$DEVNAME" ] then echo "Configuration is too old, please run pwmconfig again" >&2 exit 1 fi +if [ "$DIR" = "/" -a -n "$DEVPATH" ] +then + echo "Unneeded DEVPATH with absolute device paths" >&2 + exit 1 +fi if ! ValidateDevices "$DEVPATH" "$DEVNAME" then echo "Configuration appears to be outdated, please run pwmconfig again" >&2
This simply makes DEVPATH and DEVNAME mandatory when using relative paths and DEVNAME optional when using absolute paths. Does it work for you?
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 45 lines · Jean Delvare
Hi Marc,
Quoted 2 lines · Marc Ferland
The following patch fixes the fancontrol script so it can handle absolute filenames again.
Thanks for the report and the patch, and sorry for the long delay.
You are right that DEVPATH and DEVNAME shouldn't be mandatory when using absolute paths in the fancontrol configuration file. DEVPATH doesn't even make sense in that case.
However DEVNAME does still make sense. Using absolute paths doesn't guarantee that the device you point to after reboot is the same as the one you configured originally, unfortunately. Specifically, i2c bus numbers aren't guaranteed to be persistent over reboot. So your patch is good to get things working again but it prevents the user from asking fancontrol to check the device name when using absolute paths.
Thus I would prefer the more flexible change below:
--- prog/pwm/fancontrol | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)prog/pwm/fancontrol +6
-1@@ -291,11 +291,16 @@ fi cd $DIR # Check for configuration change -if [ -z "$DEVPATH" -o -z "$DEVNAME" ] +if [ "$DIR" != "/" ] && [ -z "$DEVPATH" -o -z "$DEVNAME" ] then echo "Configuration is too old, please run pwmconfig again" >&2 exit 1 fi +if [ "$DIR" = "/" -a -n "$DEVPATH" ] +then + echo "Unneeded DEVPATH with absolute device paths" >&2 + exit 1 +fi if ! ValidateDevices "$DEVPATH" "$DEVNAME" then echo "Configuration appears to be outdated, please run pwmconfig again" >&2
Quoted 3 lines
This simply makes DEVPATH and DEVNAME mandatory when using relative paths and DEVNAME optional when using absolute paths. Does it work for you?
Yes. Just tested on my system and everything seems to run smoothly.
Thank you,
Marc
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 6 lines · Marc Ferland
Quoted 3 lines · Jean Delvare
This simply makes DEVPATH and DEVNAME mandatory when using relative paths and DEVNAME optional when using absolute paths. Does it work for you?
Yes. Just tested on my system and everything seems to run smoothly.
Thanks for testing. Patch committed and added to the list of recommended patches.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors