Skip to content

Instantly share code, notes, and snippets.

@NattyNarwhal
Created July 26, 2018 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NattyNarwhal/470158b4817cba60f5cb898ef290d97c to your computer and use it in GitHub Desktop.
Save NattyNarwhal/470158b4817cba60f5cb898ef290d97c to your computer and use it in GitHub Desktop.
mntctl/statfs congruency
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/mntctl.h>
#include <sys/vmount.h>
#include <sys/statfs.h>
int main(void) {
int needsize, ret;
struct vmount *mounts;
struct statfs64 fs;
mntctl (MCTL_QUERY, sizeof(needsize), &needsize);
mounts = malloc(needsize);
ret = mntctl (MCTL_QUERY, needsize, mounts);
for (int i = 0; i < ret; i++) {
statfs64 (vmt2dataptr(mounts, VMT_STUB), &fs);
printf ("FS mounted on %s has a vmount.vmt_gfstype %d and statfs64.f_vfstype of %d\n", vmt2dataptr(mounts, VMT_STUB), mounts->vmt_gfstype, fs.f_vfstype);
mounts = (void*)mounts + mounts->vmt_length;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment