资源预览内容
第1页 / 共40页
第2页 / 共40页
第3页 / 共40页
第4页 / 共40页
第5页 / 共40页
第6页 / 共40页
第7页 / 共40页
第8页 / 共40页
第9页 / 共40页
第10页 / 共40页
亲,该文档总共40页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
1Linux File System 文件系统 VFSVFS的作用基于VFS的文件访问VFS重要数据结构 文件系统的注册与安装 ext2、ext3文件系统 文件操作 proc文件系统 CRAMFS文件系统2各种各样的文件系统各种各样的文件系统mmWindows FAT16,FAT32, NTFSWindows FAT16,FAT32, NTFSm传统UNIX: UFS (Unix File System)mBSD文件系统FFS(Fast File System)mProc File System:只存在于内存中mLinux File System ext2 ( is first introduced in kernel 2.0.x ) reiserfs ( 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嵌入式小型文件系统mCRAMFSmJFFS23linuxlinux文件系统目录布局文件系统目录布局To comply with FSSTND(File System STaNDard):/ - first of mount point in linux /etc - keep linux default configuration /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 /proc - 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 4UNIX文件系统文件类型 Directory catalogue of file name Normal file format of data source file text file Symbolic link a pointer to another file Special file use for device controller in kernel Named pipe communication channel which can be used by serveral processes(may be irrelevant) in order to exchange data5硬链接(Hard Link) rootlocalhost link# ls -l total 1 -rw-r-r- 1 root root 667 Oct 15 13:39 a rootlocalhost link# ln a b rootlocalhost link# ls -l total 2 -rw-r-r- 2 root root 667 Oct 15 13:39 a -rw-r-r- 2 root root 667 Oct 15 13:39 b rootlocalhost link# rm a rm: remove a? y rootlocalhost link# ls -l total 1 -rw-r-r- 1 root root 667 Oct 15 13:39 binode /root/linkab6符号链接(Symbolic link)rootlocalhost symlink# ls -l total 1 -rw-r-r- 1 root root 667 Oct 15 13:39 a rootlocalhost symlink# ln -s a b rootlocalhost symlink# ls -l total 1 -rw-r-r- 1 root root 667 Oct 15 13:39 a lrwxrwxrwx 1 root root 1 Oct 15 14:20 b - a rootlocalhost yy# rm a rm: remove a? y rootlocalhost symlink# ls -l total 0 lrwxrwxrwx 1 root root 1 Oct 15 14:20 b - a rootlocalhost symlink# cat b cat: b: No such file or directoryinode /root/linkab7VFS(Virtual FileSystem)的作用Virtual File SystemExt2Ext3.Buffer CacheDevice DriverProcess Control SubsystemSystem Call InterfaceUser ProgramsInter-process communicationSchedulerMemory managementHardware8基于VFS的文件访问9VFS的目录项(dentry)VFS的dentry定义在include/linux/dcache.h中 为了加快文件的查找,每一个曾被读取的目录或文件都可 能在目录高速缓存(directory cache)中有一个dentry项; dentry描述了目录与文件的关系树。10VFS的目录项(dentry)struct dentry /*include/linux/dcache.h*/ atomic_t d_count; unsigned int d_flags; 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;/* 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 */ ;11打开文件表 linux系统运行期间维护一张以struct file (在 include/linux/fs.h 中)作为节点的双向链表(系统打 开文件表)。表头由first_file给出。struct file *first_file = NULL; /* fs/file_table.c */对于每个进程,struct task_struct中的files指向的 files_struct结构中有一个fd指针数组,即维护一张进 程打开文件表。数组元素即是指向系统打开文件表 中某一节点的指针。 12VFS重要数据结构files_struct (在sched.h);file (在fs.h);dentry (在 dcache.h); superblock(在 fs.h);inode (在 fs.h)13文件系统类型static struct file_system_type *file_systems =(struct file_system_type *) NULL; struct file_system_type struct super_block *(*read_super)();/* 读出该文件系统在外存的super_block */ const char *name; /* 文件系统的类型名 */ int requires_dev; /* 支持文件系统的设备 */ struct file_system_type * next;/* 文件系统类型链表的后续指针 */ ; 14文件系统统注册与注销 文件系统类型的注册和注销函数 int register_filesystem(struct file_system_type * fs) int unregister_filesystem(struct file_system_type * fs)file_systemsfile_system_type file_system_type file_system_type 15文件系统的安装(mount)/binetcdevusrRoot filesystem/usr filesystemComplete hierarchy after mounting /usr/binmanlib/binetcdevusrusrbinmanlib16文件系统的安装(mount)安装点dentry rootd_mounted!=0i_sbmnt_mountpoint mnt_root下挂文件系统 安装点vfsmount17已安装文件系统的描述static LIST_HEAD(vfsmntlist);struct vfsmount struct list_head mnt_hash;struct vfsmount *mnt_parent; /* fs we are mounted on */ struct dentry *mnt_mountpoint; /* dentry of mountpoint */struct
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号