470 likes | 794 Views
Linux Filesystems. 9662815 林承諺 9662822 關啟邦. Linux Filesystems: The Virtual Filesystem. Outline. VFS Filesystem Types Common File Model Structure of VFS Mount Path lookup open read. VFS- Virtual Files System. To Support various native filesystems
E N D
Linux Filesystems 9662815 林承諺 9662822 關啟邦
Outline • VFS • Filesystem Types • Common File Model • Structure of VFS • Mount • Path lookup • open • read
VFS- Virtual Files System • To Support various native filesystems • To allow access to files of other operating systems • Provide uniform ways of manipulating files, directories, and other objects • The kernel supports more than 40 filesystems.
VFS $cp /floppy/TEST /tmp/test Understanding the Linux Kernel 3rd Ed
Filesystem Types • Disk-based filesystems • Storing files on nonvolatile media • Ext2/3, Reiserfs, FAT, and ISO9660 • Make use of block-oriented media • Network filesystems • Permit access to data on a computer attached to the local computer via a network
Filesystem Types • All operations on files in this filesystem are carried out over a network connection • NFS, Coda, AFS, NCP(Novell) • Virtual filesystems (Special filesystems) • Generated in the kernel itself • Requires no storage space on any kind of hardware device • A simple interface to access the contents of some kernel data structure • /proc
The Common File Model • Supports a uniform view of the objects in the filesystem. • A structure model consisting of all components that mirror a powerful filesystem • The model exists only virtually and must be adapted to each filesystem using a variety of objects with function pointers
The Common File Model • Inode Object • Information about a specific file • Inode number • Store in filesystem control block • File Object • Interaction between an open file and a process • Only in kernel memory
The Common File Model • Superblock Object • Information concerning a mounted filesystem • Store in filesystem control block • Dentry Object • Directory entry cache • Provide quick access to the results of a previous full lookup operation • Establish a link between a filename and its inode
Inode Object linux/include/linux/fs.h Device file
Inode lists • Each inode has a i_list to store the inode on a list • State of inode • inode_unused • Valid but no longer active inodes • inode_in_use • Used but unchanged inodes • i_count >0, i_nlink >0 • Dirty inodes • invalidate_inodes fs/inode.c
Inode Operations linux/include/linux/fs.h
File Objects linux/include/linux/fs.h
File Operations linux/include/linux/fs.h
Superblock Object linux/include/linux/fs.h
Superblock operations linux/include/linux/fs.h
Dentry Object linux/include/linux/dcache.h
Dentry Operations linux/include/linux/dcache.h
Registering Filesystems linux/fs/filesystem.c
Registering Filesystems linux/include/linux/fs.h
sys_mount linux/fs/namespace.c
do_mount linux/fs/namespace.c
do_new_mount linux/fs/namespace.c
do_kern_mount linux/fs/super.c
vfs_kern_mount linux/fs/super.c
mount_root linux/init/do_mounts.c
mount_block_root linux/init/do_mounts.c
do_mount_root linux/init/do_mounts.c
__link_path_walk linux/fs/namei.c
__link_path_walk linux/fs/namei.c
__link_path_walk linux/fs/namei.c
do_lookup linux/fs/namei.c
follow_link linux/fs/hostfs/hostfs_kern.c
sys_open linux/fs/open.c
do_sys_open linux/fs/open.c
sys_read linux/fs/read_write.c
vfs_read linux/fs/read_write.c
Reference • Linux-2.6.29 • Professional Linux Kernel Architecture • Understanding the Linux Kernel • IBM developWorks kernel anatomy series