From 0ce944ad664c19fbbbaedc24c8f239e9b2c7b99f Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 9 Sep 2007 15:47:08 +0000 Subject: [PATCH] Do not attempt to read label files from procfs, they do not exist there. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@4792 7894878c-1315-0410-8ee3-d5d059ff63e0 --- lib/access.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/access.c b/lib/access.c index d7acb793..17cc1317 100644 --- a/lib/access.c +++ b/lib/access.c @@ -27,6 +27,7 @@ #include "error.h" #include "proc.h" #include "general.h" +#include "sysfs.h" static int sensors_do_this_chip_sets(sensors_chip_name name); @@ -149,8 +150,6 @@ int sensors_get_label(sensors_chip_name name, int feature, char **result) { const sensors_chip *chip; const sensors_chip_feature *featureptr; - char buf[128], path[PATH_MAX]; - FILE *f; int i; *result = NULL; @@ -166,18 +165,23 @@ int sensors_get_label(sensors_chip_name name, int feature, char **result) goto sensors_get_label_exit; } - /* No user specified label, check for a _label sysfs file */ - snprintf(path, PATH_MAX, "%s/%s_label", name.busname, - featureptr->data.name); - - if ((f = fopen(path, "r"))) { - i = fread(buf, 1, sizeof(buf) - 1, f); - fclose(f); - if (i > 0) { - /* i - 1 to strip the '\n' at the end */ - buf[i - 1] = 0; - *result = strdup(buf); - goto sensors_get_label_exit; + if (sensors_found_sysfs) { + char buf[128], path[PATH_MAX]; + FILE *f; + + /* No user specified label, check for a _label sysfs file */ + snprintf(path, PATH_MAX, "%s/%s_label", name.busname, + featureptr->data.name); + + if ((f = fopen(path, "r"))) { + i = fread(buf, 1, sizeof(buf) - 1, f); + fclose(f); + if (i > 0) { + /* i - 1 to strip the '\n' at the end */ + buf[i - 1] = 0; + *result = strdup(buf); + goto sensors_get_label_exit; + } } }