Linux Kernel Development (7)

Posted on 2011-06-16 17:22  Teddy Yan  阅读(127)  评论(0编辑  收藏  举报

The Virtual Filesystem

The Unix concept of the file is in stark contrast to record-oriented filesystems, such as OpenVMS’s Files-11. Record-oriented filesystems provide a richer, more structured representation of files than Unix’s simple byte-stream abstraction, at the cost of simplicity and flexibility.

Unix, directories are actually normal files that simply list the files contained therein. Because a directory is a file to the VFS, the same operations performed on files can be performed on directories.

VFS Objects and Their Data Structures

TheVFS is object-oriented.2 A family of data structures represents the common file model.These data structures are akin to objects.

Furthermore, each mount point is represented by the vfsmount structure.This structure contains information about the mount point, such as its location and mount flags.

The superblock object is implemented by each filesystem and is used to store information describing that specific filesystem.This object usually corresponds to the filesystem
superblock or the filesystem control block, which is stored in a special sector on disk (hence the object’s name).

The inode object represents all the information needed by the kernel to manipulate a file or directory. For Unix-style filesystems, this information is simply read from the on-disk inode.

Whatever the case, the inode object is constructed in memory in whatever manner is applicable to the filesystem. An inode represents each file on a filesystem, but the inode object is constructed in memory only as files are accessed.This includes special files, such as device files or pipes.

To facilitate this, the VFS employs the concept of a directory entry (dentry).A dentry is a specific component in a path. Despite this useful unification, the VFS often needs to perform directory-specific operations, such as path name lookup. The dentry object makes the whole process easier.

Unlike the previous two objects, the dentry object does not correspond to any sort of on-disk data structure.The VFS creates it on-the-fly from a string representation of a path name.

The final primary VFS object that we shall look at is the file object. The file object is used to represent a file opened by a process.

Data Structures Associated with Filesystems

The Block I/O Layer

Copyright © 2024 Teddy Yan
Powered by .NET 8.0 on Kubernetes