Hello... this is a new one:
this code works in FreeBSD, Solaris, Mac OS X and even RHEL Linux.
On this page http://manpages.ubuntu.com/manpages/....2freebsd.html they say that getfsstat is a standard c library. I researched it a bit and it turns out that it should work in ubuntu.
It is very important to the project that i am working on to get getfsstat to work properly, and i think the only problem with this example to run well is the fact that somewhere ubuntu can't find, or lacks a proper library.
Thank you.
Code:
#include <sys/param.h>
#include <sys/mount.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#define MAX_FS 128
void
print_mounted_fs(void)
{
struct statfs buf[MAX_FS];
int fs_count;
int i;
fs_count = getfsstat(NULL, 0, MNT_NOWAIT);
if (fs_count == -1) {
fprintf(stderr, "Error: %d\n", errno);
exit(1);
}
printf("%d file systems found.", fs_count);
getfsstat(buf, fs_count * sizeof(buf[0]), MNT_NOWAIT);
printf("\n");
for (i = 0; i < fs_count; ++i) {
printf("%s\n", buf[i].f_mntonname);
}
}
int
main(void)
{
print_mounted_fs();
return 0;
}
Bookmarks