| 根据文件系统所在的物理介质和数据在物理介质上的组织方式来区分不同的文件系统类型的。  file_system_type结构用于描述具体的文件系统的类型信息。被Linux支持的文件系统,都有且仅有一  个file_system_type结构而不管它有零个或多个实例被安装到系统中。 而与此对应的是每当一个文件系统被实际安装,就有一个vfsmount结构体被创建,这个结构体对应一个安装点。 清单5. 和文件系统相关 struct file_system_type {  const char *name; /*文件系统的名字*/  struct subsystem subsys; /*sysfs子系统对象*/  int fs_flags; /*文件系统类型标志*/  /*在文件系统被安装时,从磁盘中读取超级块,在内存中组装超级块对象*/  struct super_block *(*get_sb) (struct file_system_type*,   int, const char*, void *);    void (*kill_sb) (struct super_block *); /*终止访问超级块*/   struct module *owner; /*文件系统模块*/  struct file_system_type * next; /*链表中的下一个文件系统类型*/  struct list_head fs_supers; /*具有同一种文件系统类型的超级块对象链表*/ }; struct vfsmount {  struct list_head mnt_hash; /*散列表*/  struct vfsmount *mnt_parent; /*父文件系统*/  struct dentry *mnt_mountpoint; /*安装点的目录项对象*/  struct dentry *mnt_root; /*该文件系统的根目录项对象*/  struct super_block *mnt_sb; /*该文件系统的超级块*/  struct list_head mnt_mounts; /*子文件系统链表*/  struct list_head mnt_child; /*子文件系统链表*/  atomic_t mnt_count; /*使用计数*/  int mnt_flags; /*安装标志*/  char *mnt_devname; /*设备文件名*/  struct list_head mnt_list; /*描述符链表*/  struct list_head mnt_fslink; /*具体文件系统的到期列表*/  struct namespace *mnt_namespace; /*相关的名字空间*/ }; 
 2.2.5.2 和进程相关 清单6. 打开的文件集 struct files_struct {//打开的文件集  atomic_t count; /*结构的使用计数*/  ……  int max_fds; /*文件对象数的上限*/  int max_fdset; /*文件描述符的上限*/  int next_fd; /*下一个文件描述符*/  struct file ** fd; /*全部文件对象数组*/  ……  }; struct fs_struct {//建立进程与文件系统的关系  atomic_t count; /*结构的使用计数*/  rwlock_t lock; /*保护该结构体的锁*/  int umask; /*默认的文件访问权限*/  struct dentry * root; /*根目录的目录项对象*/  struct dentry * pwd; /*当前工作目录的目录项对象*/  struct dentry * altroot; /*可供选择的根目录的目录项对象*/  struct vfsmount * rootmnt; /*根目录的安装点对象*/  struct vfsmount * pwdmnt; /*pwd的安装点对象*/  struct vfsmount * altrootmnt;/*可供选择的根目录的安装点对象*/ }; 
 2.2.5.3 和路径查找相关 清单7. 辅助查找 struct nameidata {  struct dentry *dentry; /*目录项对象的地址*/  struct vfsmount *mnt; /*安装点的数据*/  struct qstr last; /*路径中的最后一个component*/  unsigned int flags; /*查找标识*/  int last_type; /*路径中的最后一个component的类型*/  unsigned depth; /*当前symbolic link的嵌套深度,不能大于6*/  char *saved_names[MAX_NESTED_LINKS + 1];/  /*和嵌套symbolic link 相关的pathname*/  union {  struct open_intent open; /*说明文件该如何访问*/  } intent; /*专用数据*/ }; 
 2.2.6 对象间的联系 如上的数据结构并不是孤立存在的。正是通过它们的有机联系,VFS才能正常工作。如下的几张图是对它们之间的联系的描述。 (编辑:我爱故事小小网_铜陵站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |