Changeset 5036

Show
Ignore:
Timestamp:
11/24/07 11:46:02 (7 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.

Location:
lm-sensors/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/CHANGES

    r5033 r5036  
    44SVN-HEAD 
    55  Library: Fix fschrc and fschmd support 
     6           Fix sysfs presence detection 
    67  Makefile: Revert changeset 4738, fix bug #2187 differently 
    78  Module eeprom: Hide Sony Vaio serial numbers to regular users (2.6 backport) 
  • 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