Show
Ignore:
Timestamp:
11/24/07 11:46:02 (3 years ago)
Author:
khali
Message:

Fix sysfs presence detection. Since sysfsutils 2.0.0, libsysfs will
return success even if sysfs isn't mounted. We have to check by ourselves
if it is mounted or not, so that we can fallback to procfs on Linux 2.4
systems.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/lib/sysfs.c

    r4635 r5036  
    2121#define _GNU_SOURCE 
    2222 
     23#include <sys/types.h> 
     24#include <sys/stat.h> 
     25#include <unistd.h> 
    2326#include <string.h> 
    2427#include <stdlib.h> 
     
    3942int sensors_init_sysfs(void) 
    4043{ 
    41         if (sysfs_get_mnt_path(sensors_sysfs_mount, NAME_MAX) == 0) 
     44        struct stat statbuf; 
     45 
     46        /* libsysfs will return success even if sysfs is not mounted, 
     47           so we have to double-check */ 
     48        if (sysfs_get_mnt_path(sensors_sysfs_mount, NAME_MAX) == 0 
     49         && stat(sensors_sysfs_mount, &statbuf) == 0 
     50         && statbuf.st_nlink > 2) 
    4251                sensors_found_sysfs = 1; 
    4352