5 static const char * const sysfs_known_mountpoints
[] = {
10 static int sysfs_found
;
11 char sysfs_mountpoint
[PATH_MAX
+ 1];
13 static int sysfs_valid_mountpoint(const char *sysfs
)
17 if (statfs(sysfs
, &st_fs
) < 0)
19 else if (st_fs
.f_type
!= (long) SYSFS_MAGIC
)
25 const char *sysfs_find_mountpoint(void)
27 const char * const *ptr
;
32 return (const char *) sysfs_mountpoint
;
34 ptr
= sysfs_known_mountpoints
;
36 if (sysfs_valid_mountpoint(*ptr
) == 0) {
38 strcpy(sysfs_mountpoint
, *ptr
);
39 return sysfs_mountpoint
;
44 /* give up and parse /proc/mounts */
45 fp
= fopen("/proc/mounts", "r");
49 while (!sysfs_found
&&
50 fscanf(fp
, "%*s %" STR(PATH_MAX
) "s %99s %*s %*d %*d\n",
51 sysfs_mountpoint
, type
) == 2) {
53 if (strcmp(type
, "sysfs") == 0)
59 return sysfs_found
? sysfs_mountpoint
: NULL
;