2007-3-6 自己看吧,就这几行代码. filesytem 的精华并不在这个同名文件中.
#ifdef CONFIG_DEVPTS_FS extern int init_devpts_fs(void); #endif
void __init filesystem_setup(void) { init_devfs_fs(); /* Header file may make this empty */
#ifdef CONFIG_NFS_FS init_nfs_fs(); #endif
#ifdef CONFIG_DEVPTS_FS init_devpts_fs(); #endif }
#if defined(CONFIG_NFSD_MODULE) struct nfsd_linkage *nfsd_linkage = NULL;
long asmlinkage sys_nfsservctl(int cmd, void *argp, void *resp) { int ret = -ENOSYS; lock_kernel();
if (nfsd_linkage || (request_module ("nfsd") == 0 && nfsd_linkage)) ret = nfsd_linkage->do_nfsservctl(cmd, argp, resp);
unlock_kernel(); return ret; } EXPORT_SYMBOL(nfsd_linkage);
#elif ! defined (CONFIG_NFSD) asmlinkage int sys_nfsservctl(int cmd, void *argp, void *resp) { return -ENOSYS; } #endif /* CONFIG_NFSD */
倒是吧fs type列到这里吧,就像人走过的时候顺笔写上, xxx到此一游. struct file_system_type { const char *name; int fs_flags; struct super_block *(*read_super) (struct super_block *, void *, int); struct module *owner; struct vfsmount *kern_mnt; /* For kernel mount, if it's FS_SINGLE fs */ struct file_system_type * next; };
#define DECLARE_FSTYPE(var,type,read,flags) \ struct file_system_type var = { \ name: type, \ read_super: read, \ fs_flags: flags, \ owner: THIS_MODULE, \ }
#define DECLARE_FSTYPE_DEV(var,type,read) \ DECLARE_FSTYPE(var,type,read,FS_REQUIRES_DEV)
read_super,是一个文件系统的开始.里边有这个文件系统的根,s_root. mount的时候,才需要做这个动作. do_mount(kern_mount) +read_super构建一颗由vfsmount链接起来的dentry->mnt->dentry(root)混合树...
由vfsmount, dentry 组成的这棵数, 加上file->dentry<-->inode<-->super<fs_system_type 所形成的复杂的"网状"结构, 是整个 VFS的"组织结构".而组织结构最大的作用,就是互相方便的引用,查找. 同时也提供给user一个以字符串为媒介的接口"path". 光是这庞大的组织,就占去了vfsmount,dentry,inode,super不少的"经费"(空间).然后依附于每个个体,都有一组feature:功能性 featrue+底层接口虚拟化. VFS在这个组织之上,依赖于这些feature,构筑整个VFS的实现,向上提供给user文件系统的统一操作,向下,有一组"标准"接口,可以方便 的实现具体的文件系统. struct file_system_type { const char *name; /*feature*/ int fs_flags; /*feature*/ struct super_block *(*read_super) (struct super_block *, void *, int); /*featue虚拟化接口*/ struct module *owner; /*组织*/ struct vfsmount *kern_mnt; /*组织*/ struct file_system_type * next; /*组织*/ };
|