Raunaq Kochar Raunaq Kochar - 9 months ago 79
Linux Question

Check if Stackable file system mounted or not programmatically

I am providing the path of any file in a directory on which a stackable file system is being mounted. Is there any way to programmatically check whether the mounted file system is the stackable file system or my underlying lower file system?

I have tried using

, but it always returns success as it detects my lower file system, even though my traceable file system hasn't been mounted.
I want to do this programmatically in C and not using command line. e.g mount

Answer Source

Can you examine f_type parameter and define the file system type from there?

#include <stdio.h>
#include <sys/vfs.h>

void main(int argc, char **argv) {
  char *path=argv[1];
  int a;

  struct statfs foo;

  a = statfs(path, &foo);
  printf("%d,%ld\n", a, foo.f_type);

works for me.