How can I determine the type of file-system that a file is stored on? I might have the filename, or later, just a descriptor.
I would happily use a script at first, but would like also to know how to do it with syscalls from C.
On the command line/script, You can use stat
:
$ stat -f -c "%T" someFileOnExt2Ext3
ext2/ext3
$ stat -f -c "%T" someFileOnNFS
nfs
This eventually leads to the statfs(2) system call:
int statfs(const char *path, struct statfs *buf);
The function statfs() returns information about a mounted file system. path is the pathname of any file within the mounted file system, buf is a pointer to a statfs structure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With