linux kernel文件系统数据结构file_system_type
文件系统类型用于表示各种不同的文件系统,如fat, sysfs, proc等等,对于每个不同的文件系统,都以struct file_system_type进行描述,内核将它们以单链表的形式链接起来,其表头由全局变量file_systems表示。
文件系统类型的 数据结构位:file_system_type
此结构体定义了文件系统的类型,每种文件系统都必须定义一个此结构体并通过register_filesystem进行注册。
struct file_system_type {
//文件系统的名字
const char *name;
//文件系统类型标志的bitmap
int fs_flags;
//在安装文件时,会调用get_sb()从磁盘中读取超级块。
int (*get_sb) (struct file_system_type *, int,
const char *, void *, struct vfsmount *);
//卸载文件系统时,会调用此函数做一些清理工作。
void (*kill_sb) (struct super_block *);
//指向拥有这个结构的模块,如果一个文件系统被编译进内核,则该字段为NULL
struct module *owner;
//形成文件系统类型链表
struct file_system_type * next;
//同一种文件类型的超级块形成一个链表,fs_supers是这个链表的头
struct list_head fs_supers;
//相关锁
struct lock_class_key s_lock_key;
struct lock_class_key s_umount_key;
};
不同类型的文件系统通过next字段形成一个链表,同一种文件系统类型的超级块通过s_instances字段连接在一起,并挂入fs_supers链表中。所有的vfsmount通过mnt_list字段形成一个链表。