diff options
author | khali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0> | 2012-01-31 12:54:03 +0000 |
---|---|---|
committer | khali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0> | 2012-01-31 12:54:03 +0000 |
commit | c87eebf8539df08f677db2494cf2f093c14f53aa (patch) | |
tree | 2ebc6ec69f3a28e84e44b565a1bce07b6a21f3aa /lib | |
parent | ab71f6d7f525a22ecae711ee26e45a3ffe2559fd (diff) | |
download | lm-sensors-c87eebf8539df08f677db2494cf2f093c14f53aa.tar.gz |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sysfs.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/sysfs.c b/lib/sysfs.c index 94cea355..9068a71a 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -24,6 +24,7 @@ #include <sys/types.h> #include <sys/stat.h> +#include <sys/vfs.h> #include <unistd.h> #include <string.h> #include <stdlib.h> @@ -40,6 +41,7 @@ /****************************************************************************/ #define ATTR_MAX 128 +#define SYSFS_MAGIC 0x62656572 /* * Read an attribute from sysfs @@ -593,11 +595,11 @@ exit_free: /* returns !0 if sysfs filesystem was found, 0 otherwise */ int sensors_init_sysfs(void) { - struct stat statbuf; + struct statfs statfsbuf; snprintf(sensors_sysfs_mount, NAME_MAX, "%s", "/sys"); - if (stat(sensors_sysfs_mount, &statbuf) < 0 - || statbuf.st_nlink <= 2) /* Empty directory */ + if (statfs(sensors_sysfs_mount, &statfsbuf) < 0 + || statfsbuf.f_type != SYSFS_MAGIC) return 0; return 1; |