Get the file system type where the file is stored.

How to determine the type of filesystem on which a file is stored? I can have a filename or later, just a descriptor.

I'd happily use a script, but would also like to know how to do it using system calls with C.

+3


source to share


1 answer


On the command line / script, you can use stat

:

$ stat -f -c "%T" someFileOnExt2Ext3
ext2/ext3

$ stat -f -c "%T" someFileOnNFS
nfs

      

This will eventually lead to the statfs (2) system call :



int statfs(const char *path, struct statfs *buf);

      

Statfs () returns information about the mounted filesystem. path is the path to any file on the mounted filesystem, buf is a pointer to a statfs structure.

+10


source







All Articles