What is equivalent to getfsstat () on Linux?

The question says it all. I need a C function call that returns a list of mounted file systems along with related information such as the file system type.

+3
source share
2 answers

You are looking for getmntentother feature families *mntent. See manpage for further reference.

Sample code taken from here and slightly modified. /etc/mtabis a file containing a list of mounted file systems.

mounts = setmntent("/etc/mtab", "r");
while ( (ent = getmntent(mounts)) != NULL ){
    if (strcmp(ent->mnt_type, "iso9660") == 0)
       /* copy mount point to output */
       strcpy(retval[cd_count - 1], ent->mnt_dir);
    } /* if */
} /* while */
endmntent(mounts);

, POSIX. glibc, , , /proc.

+6

/proc/filesystems.

+1

Source: https://habr.com/ru/post/1726152/


All Articles