daily pastebin goal
91%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <assert.h>
  2. #include <sys/param.h>
  3. #include <sys/ucred.h>
  4. #include <sys/mount.h>
  5. #include <stdlib.h>
  6. #include <stdio.h>
  7.  
  8. int main() {
  9.     int num_of_fs = getfsstat(NULL, 0, MNT_NOWAIT);
  10.     assert(num_of_fs > 0);
  11.  
  12.     struct statfs *buf = malloc(sizeof(struct statfs) * num_of_fs);
  13.     assert(buf);
  14.     if ( getfsstat(buf, sizeof(struct statfs) * num_of_fs, MNT_NOWAIT) < 0) {
  15.         perror("getfsstat");
  16.     }
  17.     printf("number of fs is %d\n", num_of_fs);
  18.  
  19.     // dump it
  20.     {
  21.         int i;
  22.         for (i=0; i<num_of_fs; i++) {
  23.             // f_type
  24.             printf("--\n");
  25. #define DISP_I(x) printf(#x ": %d\n", buf[i].x);
  26.             DISP_I(f_bsize);
  27.             DISP_I(f_iosize);
  28. #undef DISP_I
  29.  
  30. #define DISP_S(x) printf(#x ": %s\n", buf[i].x);
  31.             DISP_S(f_fstypename);
  32.             DISP_S(f_mntonname);
  33.             DISP_S(f_mntfromname);
  34. #undef DISP_S
  35.         }
  36.     }
  37.  
  38.     return 0;
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top