1、文件系统VFSVFS的作用基于 VFS的文件访问VFS重要数据结构文件系统的注册与安装ext2、 ext3文件系统文件操作proc文件系统CRAMFS文件系统Linux File System各种各样的文件系统各种各样的文件系统m Windows FAT16,FAT32, NTFSm 传统 UNIX: UFS (Unix File System)m BSD文件系统 FFS(Fast File System)m Proc File System: 只存在于内存中m Linux File System ext2 ( is first introduced in kernel 2.0.x ) rei
2、serfs ( is first introduced in kernel 2.2.x ) ext3 ( is first introduced in kernel 2.4.x ,default in RedHat now) xfs (from SGI ) Jfs (from IBM )m 嵌入式小型文件系统m CRAMFSm JFFS2linux文件系统目录布局文件系统目录布局To comply with FSSTND(File System STaNDard):/ - first of mount point in linux/etc - keep linux default config
3、uration/boot - keep important linux booting files(can be a separate file system)/bin - Essential command binaries for both root and ord. users /sbin - Essential system binaries for administrator /dev - keep all device files/usr - keep all user binary and X library /home - keep user home directory/pr
4、oc - is pseudo file system for tracking running process and state of linux system/var - keeping mail, log file and printer spooling/lib - contain shared library that is required by system program/tmp - contain system temporary file/opt - Add-on application software packages Directory catalogue of fi
5、le nameNormal file format of data source file text fileSymbolic link a pointer to another fileSpecial file use for device controller in kernelNamed pipe communication channel which can be used by serveral processes(may be irrelevant) in order to exchange dataUNIX文件系统文件类型硬链接( Hard Link) rootlocalhost
6、 link# ls -ltotal 1-rw-r-r- 1 root root 667 Oct 15 13:39 arootlocalhost link# ln a brootlocalhost link# ls -ltotal 2-rw-r-r- 2 root root 667 Oct 15 13:39 a-rw-r-r- 2 root root 667 Oct 15 13:39 brootlocalhost link# rm arm: remove a? yrootlocalhost link# ls -ltotal 1-rw-r-r- 1 root root 667 Oct 15 13:
7、39 binode/root/linkab符号链接( Symbolic link)rootlocalhost symlink# ls -ltotal 1-rw-r-r- 1 root root 667 Oct 15 13:39 arootlocalhost symlink# ln -s a brootlocalhost symlink# ls -ltotal 1-rw-r-r- 1 root root 667 Oct 15 13:39 alrwxrwxrwx 1 root root 1 Oct 15 14:20 b - arootlocalhost yy# rm arm: remove a?
8、yrootlocalhost symlink# ls -ltotal 0lrwxrwxrwx 1 root root 1 Oct 15 14:20 b - arootlocalhost symlink# cat bcat: b: No such file or directoryinode/root/linkabVFS(Virtual FileSystem)的作用Virtual File SystemExt2 Ext3 .Buffer CacheDevice DriverProcess Control SubsystemSystem Call InterfaceUser ProgramsInt
9、er-process communicationSchedulerMemory managementHardware基于 VFS的文件访问VFS的目录项( dentry)VFS的 dentry定义在 include/linux/dcache.h中为了加快文件的查找,每一个曾被读取的目录或文件都可能在目录高速缓存( directory cache) 中有一个 dentry项;dentry描述了目录与文件的关系树。VFS的目录项( dentry)struct dentry /*include/linux/dcache.h*/atomic_t d_count;unsigned int d_flags
10、;struct inode * d_inode; /* Where the name belongs to - NULL is negative */struct dentry * d_parent; /* parent directory */struct list_head d_hash; /* lookup hash list */struct list_head d_lru; /* d_count = 0 LRU list */struct list_head d_child; /* child of parent list */struct list_head d_subdirs;
11、/* our children */struct list_head d_alias; /* inode alias list */int d_mounted;struct qstr d_name;unsigned long d_time; /* used by d_revalidate */struct dentry_operations *d_op;struct super_block * d_sb; /* The root of the dentry tree */unsigned long d_vfs_flags;void * d_fsdata; /* fs-specific data */unsigned char d_inameDNAME_INLINE_LEN; /* small names */;