Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <assert.h>
- #include <sys/param.h>
- #include <sys/ucred.h>
- #include <sys/mount.h>
- #include <stdlib.h>
- #include <stdio.h>
- int main() {
- int num_of_fs = getfsstat(NULL, 0, MNT_NOWAIT);
- assert(num_of_fs > 0);
- struct statfs *buf = malloc(sizeof(struct statfs) * num_of_fs);
- assert(buf);
- if ( getfsstat(buf, sizeof(struct statfs) * num_of_fs, MNT_NOWAIT) < 0) {
- perror("getfsstat");
- }
- printf("number of fs is %d\n", num_of_fs);
- // dump it
- {
- int i;
- for (i=0; i<num_of_fs; i++) {
- // f_type
- printf("--\n");
- #define DISP_I(x) printf(#x ": %d\n", buf[i].x);
- DISP_I(f_bsize);
- DISP_I(f_iosize);
- #undef DISP_I
- #define DISP_S(x) printf(#x ": %s\n", buf[i].x);
- DISP_S(f_fstypename);
- DISP_S(f_mntonname);
- DISP_S(f_mntfromname);
- #undef DISP_S
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment