Changeset 6017

Show
Ignore:
Timestamp:
01/31/12 13:54:03 (4 months ago)
Author:
khali
Message:

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.

Location:
lm-sensors/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/CHANGES

    r6016 r6017  
    44SVN HEAD 
    55  libsensors: Added support for new sysfs attributes 
     6              Change sysfs detection to survive upcoming kernel changes 
    67  sensors: Added support for new sysfs attributes 
    78           Display both instantaneous and average power if available. 
  • lm-sensors/trunk/lib/sysfs.c

    r6007 r6017  
    2525#include <sys/types.h> 
    2626#include <sys/stat.h> 
     27#include <sys/vfs.h> 
    2728#include <unistd.h> 
    2829#include <string.h> 
     
    4142 
    4243#define ATTR_MAX        128 
     44#define SYSFS_MAGIC     0x62656572 
    4345 
    4446/* 
     
    594596int sensors_init_sysfs(void) 
    595597{ 
    596         struct stat statbuf; 
     598        struct statfs statfsbuf; 
    597599 
    598600        snprintf(sensors_sysfs_mount, NAME_MAX, "%s", "/sys"); 
    599         if (stat(sensors_sysfs_mount, &statbuf) < 0 
    600          || statbuf.st_nlink <= 2)      /* Empty directory */ 
     601        if (statfs(sensors_sysfs_mount, &statfsbuf) < 0 
     602         || statfsbuf.f_type != SYSFS_MAGIC) 
    601603                return 0; 
    602604