mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-30 21:18:20 +00:00
Return with an explicit error code/message if sysfs isn't mounted.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4464 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
f8c7f20bf1
commit
f00aef9271
3 files changed
+14
-10
No files matched your search
+1
-1
@@ -34,7 +34,7 @@ static const char *errorlist[] =
|
|||||||
/* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name",
|
/* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name",
|
||||||
/* SENSORS_ERR_NO_ENTRY */ "No such feature known",
|
/* SENSORS_ERR_NO_ENTRY */ "No such feature known",
|
||||||
/* SENSORS_ERR_ACCESS */ "Can't read or write",
|
/* 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_DIV_ZERO */ "Divide by zero",
|
||||||
/* SENSORS_ERR_CHIP_NAME */ "Can't parse chip name",
|
/* SENSORS_ERR_CHIP_NAME */ "Can't parse chip name",
|
||||||
/* SENSORS_ERR_BUS_NAME */ "Can't parse bus name",
|
/* SENSORS_ERR_BUS_NAME */ "Can't parse bus name",
|
||||||
|
|||||||
+12
-3
@@ -20,6 +20,9 @@
|
|||||||
/* this define needed for strndup() */
|
/* this define needed for strndup() */
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
@@ -197,10 +200,16 @@ sensors_chip_features sensors_read_dynamic_chip(struct sysfs_device *sysdir)
|
|||||||
/* returns !0 if sysfs filesystem was found, 0 otherwise */
|
/* returns !0 if sysfs filesystem was found, 0 otherwise */
|
||||||
int sensors_init_sysfs(void)
|
int sensors_init_sysfs(void)
|
||||||
{
|
{
|
||||||
if (sysfs_get_mnt_path(sensors_sysfs_mount, NAME_MAX) == 0)
|
struct stat statbuf;
|
||||||
return 1;
|
|
||||||
|
|
||||||
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 */
|
/* returns: 0 if successful, !0 otherwise */
|
||||||
|
|||||||
+1
-6
@@ -237,12 +237,7 @@ int main (int argc, char *argv[])
|
|||||||
|
|
||||||
open_config_file(config_file_name);
|
open_config_file(config_file_name);
|
||||||
if ((res = sensors_init(config_file))) {
|
if ((res = sensors_init(config_file))) {
|
||||||
fprintf(stderr,"%s\n",sensors_strerror(res));
|
fprintf(stderr, "sensors_init: %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");
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
close_config_file(config_file_name);
|
close_config_file(config_file_name);
|
||||||
|
|||||||
Reference in new issue
Block a user