Upcoming change in sysfs will break the way libsensors detects if

sysfs is mounted. Adjust the implementation so that it still works after
said change.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6017 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare committed 2012-01-31 12:54:03 +00:00
1 parent c9c0cb604f
commit ae32c8a919
2 files changed
+6 -3

No files matched your search

+1
View File
@@ -3,6 +3,7 @@ lm-sensors CHANGES file
SVN HEAD SVN HEAD
libsensors: Added support for new sysfs attributes libsensors: Added support for new sysfs attributes
Change sysfs detection to survive upcoming kernel changes
sensors: Added support for new sysfs attributes sensors: Added support for new sysfs attributes
Display both instantaneous and average power if available. Display both instantaneous and average power if available.
Report thermal sensor type 1 as CPU diode Report thermal sensor type 1 as CPU diode
+5 -3
View File
@@ -24,6 +24,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/vfs.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@@ -40,6 +41,7 @@
/****************************************************************************/ /****************************************************************************/
#define ATTR_MAX 128 #define ATTR_MAX 128
#define SYSFS_MAGIC 0x62656572
/* /*
* Read an attribute from sysfs * Read an attribute from sysfs
@@ -593,11 +595,11 @@ exit_free:
/* 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)
{ {
struct stat statbuf; struct statfs statfsbuf;
snprintf(sensors_sysfs_mount, NAME_MAX, "%s", "/sys"); snprintf(sensors_sysfs_mount, NAME_MAX, "%s", "/sys");
if (stat(sensors_sysfs_mount, &statbuf) < 0 if (statfs(sensors_sysfs_mount, &statfsbuf) < 0
|| statbuf.st_nlink <= 2) /* Empty directory */ || statfsbuf.f_type != SYSFS_MAGIC)
return 0; return 0;
return 1; return 1;