Question says it all. I want C function call that returns the list the mounted filesystems along with associated information such as filesystem type.
Or even /proc/mounts
MarkR
2009-12-20 08:06:02
+5
A:
You're looking for getmntent
and other *mntent
functions family. See manpage For further reference.
Code example taken from here and slightly modified. /etc/mtab
is a file that contains a list of mounted filesystems.
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);
Unfortunately, these functions are not in POSIX. But they're manpaged and implemented in glibc, so I think they're a better alternative than parsing /proc
.
Pavel Shved
2009-12-20 02:42:16