linux-5.14.3/fs/fat/namei_vfat.c
static struct dentry *vfat_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { return mount_bdev(fs_type, flags, dev_name, data, vfat_fill_super); } static struct file_system_type vfat_fs_type = { .owner = THIS_MODULE, .name = "vfat", .mount = vfat_mount, .kill_sb = kill_block_super, .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, }; MODULE_ALIAS_FS("vfat"); static int __init init_vfat_fs(void) { return register_filesystem(&vfat_fs_type); } static void __exit exit_vfat_fs(void) { unregister_filesystem(&vfat_fs_type); } MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("VFAT filesystem support"); MODULE_AUTHOR("Gordon Chaffee"); module_init(init_vfat_fs) module_exit(exit_vfat_fs)
linux-5.14.3/fs/filesystems.c
/* * Handling of filesystem drivers list. * Rules: * Inclusion to/removals from/scanning of list are protected by spinlock. * During the unload module must call unregister_filesystem(). * We can access the fields of list element if: * 1) spinlock is held or * 2) we hold the reference to the module. * The latter can be guaranteed by call of try_module_get(); if it * returned 0 we must skip the element, otherwise we got the reference. * Once the reference is obtained we can drop the spinlock. */ static struct file_system_type *file_systems;
struct mount { struct vfsmount mnt struct dentry *mnt_mountpoint } struct dentry { struct qstr d_name; struct super_block *d_sb; ...... } struct vfsmount { struct dentry *mnt_root; struct super_block *mnt_sb; ...... } struct super_block { struct file_system_type *s_type; const struct super_operations *s_op; struct dentry *s_root; ...... }
3.
/* super_block => dentry => vfsmount => mount */ vfs_kern_mount() struct dentry *root = mount_fs(type, flags, name, data);