| static const char * const sysfs_known_mountpoints[] = { |
| char sysfs_mountpoint[PATH_MAX]; |
| static int sysfs_valid_mountpoint(const char *sysfs) |
| if (statfs(sysfs, &st_fs) < 0) |
| else if (st_fs.f_type != (long) SYSFS_MAGIC) |
| const char *sysfs_find_mountpoint(void) |
| return (const char *) sysfs_mountpoint; |
| ptr = sysfs_known_mountpoints; |
| if (sysfs_valid_mountpoint(*ptr) == 0) { |
| strcpy(sysfs_mountpoint, *ptr); |
| /* give up and parse /proc/mounts */ |
| fp = fopen("/proc/mounts", "r"); |
| fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n", |
| sysfs_mountpoint, type) == 2) { |
| if (strcmp(type, "sysfs") == 0) |
| return sysfs_found ? sysfs_mountpoint : NULL; |