diff --git a/lib/error.c b/lib/error.c index e1435243..62addd89 100644 --- a/lib/error.c +++ b/lib/error.c @@ -34,7 +34,7 @@ static const char *errorlist[] = /* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name", /* SENSORS_ERR_NO_ENTRY */ "No such feature known", /* SENSORS_ERR_ACCESS */ "Can't read or write", - /* SENSORS_ERR_PROC */ "Can't access procfs/sysfs file", + /* SENSORS_ERR_PROC */ "Can't access sysfs file", /* SENSORS_ERR_DIV_ZERO */ "Divide by zero", /* SENSORS_ERR_CHIP_NAME */ "Can't parse chip name", /* SENSORS_ERR_BUS_NAME */ "Can't parse bus name", diff --git a/lib/sysfs.c b/lib/sysfs.c index f2919877..8be60fd0 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -20,6 +20,9 @@ /* this define needed for strndup() */ #define _GNU_SOURCE +#include +#include +#include #include #include #include @@ -197,10 +200,16 @@ sensors_chip_features sensors_read_dynamic_chip(struct sysfs_device *sysdir) /* returns !0 if sysfs filesystem was found, 0 otherwise */ int sensors_init_sysfs(void) { - if (sysfs_get_mnt_path(sensors_sysfs_mount, NAME_MAX) == 0) - return 1; + struct stat statbuf; - return 0; + /* libsysfs will return success even if sysfs is not mounted, + so we have to double-check */ + if (sysfs_get_mnt_path(sensors_sysfs_mount, NAME_MAX) + || stat(sensors_sysfs_mount, &statbuf) < 0 + || statbuf.st_nlink <= 2) /* Empty directory */ + return 0; + + return 1; } /* returns: 0 if successful, !0 otherwise */ diff --git a/prog/sensors/main.c b/prog/sensors/main.c index 0cd1b8d0..2a1a6969 100644 --- a/prog/sensors/main.c +++ b/prog/sensors/main.c @@ -237,12 +237,7 @@ int main (int argc, char *argv[]) open_config_file(config_file_name); if ((res = sensors_init(config_file))) { - fprintf(stderr,"%s\n",sensors_strerror(res)); - if (res == -SENSORS_ERR_PROC) - fprintf(stderr, - "Kernel interface access error\n" - "For 2.6 kernels, make sure you have mounted sysfs and libsensors\n" - "was compiled with sysfs support!\n"); + fprintf(stderr, "sensors_init: %s\n", sensors_strerror(res)); exit(1); } close_config_file(config_file_name);