From 99698b4bfa024c85c802e26b86b9dbc78b94345c Mon Sep 17 00:00:00 2001 From: "Mark D. Studebaker" Date: Fri, 8 Jun 2001 23:57:26 +0000 Subject: [PATCH] fix broken /proc error message from long ago and add improved one for when 'sensors -s' is not run as root. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1126 7894878c-1315-0410-8ee3-d5d059ff63e0 --- prog/sensors/main.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/prog/sensors/main.c b/prog/sensors/main.c index 23f94ef7..284e1e6c 100644 --- a/prog/sensors/main.c +++ b/prog/sensors/main.c @@ -207,12 +207,11 @@ int main (int argc, char *argv[]) open_config_file(); if ((res = sensors_init(config_file))) { - if (res == SENSORS_ERR_PROC) + fprintf(stderr,"%s\n",sensors_strerror(res)); + if (res == -SENSORS_ERR_PROC) fprintf(stderr, - "/proc/sys/dev/sensors/chips or /proc/bus/i2c unreadable:\n" - "Make sure you have inserted modules sensors.o and i2c-proc.o!"); - else - fprintf(stderr,"%s\n",sensors_strerror(res)); + "/proc/sys/dev/sensors/chips or /proc/bus/i2c unreadable;\n" + "Make sure you have done 'modprobe i2c-proc'!\n"); exit(1); } @@ -250,8 +249,16 @@ int do_the_real_work(void) void do_a_set(sensors_chip_name name) { int res; - if ((res = sensors_do_chip_sets(name))) - fprintf(stderr,"%s: %s\n",sprintf_chip_name(name),sensors_strerror(res)); + if ((res = sensors_do_chip_sets(name))) { + if (res == -SENSORS_ERR_PROC) { + fprintf(stderr,"%s: %s for writing;\n",sprintf_chip_name(name), + sensors_strerror(res)); + fprintf(stderr,"Run as root?\n"); + } else { + fprintf(stderr,"%s: %s\n",sprintf_chip_name(name), + sensors_strerror(res)); + } + } } const char *sprintf_chip_name(sensors_chip_name name) @@ -320,12 +327,12 @@ void do_a_print(sensors_chip_name name) print_w83781d(&name); else if (!strncmp(name.prefix,"maxilife-", 9)) print_maxilife(&name); + else if (!strcmp(name.prefix,"it87")) + print_it87(&name); else if (!strcmp(name.prefix,"ddcmon")) print_ddcmon(&name); else if (!strcmp(name.prefix,"eeprom")) print_eeprom(&name); - else if (!strcmp(name.prefix,"it87")) - print_it87(&name); else print_unknown_chip(&name); printf("\n");