Reputation: 9611
On Linux systems, it is possible to identify "regular" filesystems
using statfs(2)
and inspecting the f_type
. Constants for several
filesystem types are mentioned in the statfs(2)
manpage, such as
EXT4_SUPER_MAGIC 0xEF53
BTRFS_SUPER_MAGIC 0x9123683E
FUSE_SUPER_MAGIC 0x65735546
PROC_SUPER_MAGIC 0x9fa0
SYSFS_MAGIC 0x62656572
(It turns out that those are actually defined in linux/magic.h
.)
I would like to be able to distinguish well-known remote filesystems (such as sshfs) from well-known local filesystems (such as the ntfs-3g). Is there any way to find out more about FUSE-based filesystems, such as a name at this point?
Upvotes: 2
Views: 1185
Reputation: 16086
As per some old IBM fuse documentation and the implementation of both sshfs and ntfs-3g setting f_type in the statfs implementation of each of the these filesystems appears to be ignored.
I believe using this method would result in a value of 0x65735546 based on the initialization of the value here.
A mechanism to get filesystem information in userspace is /proc/mounts
or /proc/<pid>/mountinfo
as documented here. This has the 9th field as filesystem type which has FUSE subtypes (if they were specified as a mount option and supported by the kernel) as type.subtype. E.g fuse.sshfs or fuse.ntfs-3g.
To access the same information in kernelspace , you can use lookup_mnt with the path, to get a pointer to a vfsmount struct, from that you can access the superblock and then the subtype. Where struct vfsmount *mnt
and the subtype is mnt->mnt_sb->s_subtype
.
Upvotes: 1