每个注册的文件系统都是用一个类型为file_system_type的对象来表示,file_system_type如下所示:
struct file_system_type {
const char *name;
int fs_flags;
int (*get_sb) (struct file_system_type *, int,
const char *, void *, struct vfsmount *);
void (*kill_sb) (struct super_block *);
struct module *owner;
struct file_system_type * next;
struct list_head fs_supers;
struct lock_class_key s_lock_key;
struct lock_class_key s_umount_key;
};
所有文件系统类型的对象都插入到一个单向链表中。static struct file_system_type *file_systems;定义了一个全局的变量file_systems指向链表头,结构体中的next指向链表的下一个元素。
注册文件系统是用register_filesystem,以block_dev.c为例:
static struct file_system_type bd_type = {
.name = "bdev",
.get_sb = bd_get_sb,
.kill_sb = kill_anon_super,
};
void __init bdev_cache_init(void)
{
int err;
bdev_cachep = kmem_cache_create("bdev_cache", sizeof(struct bdev_inode),
0, (SLAB_HWCACHE_ALIGN|SLAB_R