2. The Virtual File System (VFS)
• The Virtual File System (also known as the Virtual Filesystem Switch)
is the software layer in the kernel that provides the filesystem interface
to user space programs.
• It also provides an abstraction within the kernel which allows
• The virtual file system (VFS) interface, also known as the v-node
interface, provides a bridge between the physical and logical file
systems. The information that follows discusses the virtual file system
interface, its data structures, and its header files, and explains how to
configure a virtual file system.tem implementations to coexist.
• Four main objects: superblock, dentries, inodes, files
Several processes may have the same file open for reading or writing,
and file structures contain the required information such as the current
6. System Calls
• A system call is a way for programs to interact with the operating
• A computer program makes a system call when it makes a request to
the operating system's kernel.
• System call provides the services of the operating system to the user
programs via Application Program Interface(API).
8. Data Structures - Super Block, Inode, File
• Each VFS object is stored in a suitable data structure, which includes
both the object attributes and a pointer to a table of object methods.
• The kernel may dynamically modify the methods of the object and,
hence, it may install specialized behavior for the object.
• The sb_lock spin lock protects the list against concurrent accesses in
9. Inode Objects
• All information needed by the filesystem to handle a file is included in
a data structure called an inode.
• A filename is a casually assigned label that can be changed, but the
inode is unique to the file and remains the same as long as the file
10. Dentry Objects
• The VFS treats directories as files. In the path /bin/vi, both bin and vi
are filesbin being the special directory file and vi being a regular file.
• An inode object represents both these components.
• Despite this useful unification, the VFS often needs to perform
directory-specific operations, such as path name lookup.
• Path name lookup involves translating each component of a path,
ensuring it is valid, and following it to the next component.
11. • To facilitate this, the VFS employs the concept of a directory entry
(dentry). A dentry is a specific component in a path. Using the
previous example, /, bin, and vi are all dentry objects.
• The first two are directories and the last is a regular file. This is an
important point: dentry objects are all components in a path, including
files. Resolving a path and walking its components is a nontrivial
exercise, time-consuming and rife with string comparisons. The dentry
object makes the whole process easier.
12. Dentry Cache
After the VFS layer goes through the trouble of resolving each element
in a path name into a dentry object and arriving at the end of the path, it
would be quite wasteful to throw away all that work.
Instead, the kernel caches dentry objects in the dentry cache or, simply,
13. • The dentry cache consists of three parts:
• Lists of "used" dentries that are linked off their associated inode via the
i_dentry field of the inode object. Because a given inode can have multiple
links, there might be multiple dentry objects; consequently, a list is used.
• A doubly linked "least recently used" list of unused and negative dentry
objects. The list is insertion sorted by time, such that entries toward the
head of the list are newest. When the kernel must remove entries to reclaim
memory, the entries are removed from the tail; those are the oldest and
presumably have the least chance of being used in the near future.
• A hash table and hashing function used to quickly resolve a given path into
the associated dentry object.
14. Files Associated with a Process
• A file system is a process of managing how and where data on a
storage disk, which is also referred to as file management or FS.
• It is a logical disk component that compresses files separated into
groups, which is known as directories.
• It is abstract to a human user and related to a computer; hence, it
manages a disk's internal operations. Files and additional directories
can be in the directories.
15. • Although there are various file systems with Windows, NTFS is the
most common in modern times.
• It would be impossible for a file with the same name to exist and also
impossible to remove installed programs and recover specific files
without file management, as well as files would have no organization
without a file structure.
• The file system enables you to view a file in the current directory as
files are often managed in a hierarchy.
16. Filesystem Type Registration
• Often, the user configures Linux to recognize all the filesystems
needed when compiling the kernel for her system.
• But the code for a filesystem actually may either be included in the
kernel image or dynamically loaded as a module.
• The VFS must keep track of all filesystem types whose code is
currently included in the kernel.
• It does this by performing filesystem type registration.
17. • It is the filesystem that is directly mounted by the kernel during the
booting phase and that holds the system initialization scripts and the
most essential system programs.
• Other filesystems can be mounted—either by the initialization scripts
or directly by the users—on directories of already mounted
filesystems. Being a tree of directories, every filesystem has its
own root directory.
• The directory on which a filesystem is mounted is called the mount
point. A mounted filesystem is a child of the mounted filesystem to
which the mount point directory belongs.
• In a traditional Unix system, there is only one tree of mounted
filesystems: starting from the system’s root filesystem, each process
can potentially access every file in a mounted filesystem by specifying
the proper pathname.
• In this respect, Linux 2.6 is more refined: every process might have its
own tree of mounted filesystems—the so-called namespace of the
19. Mounting and Unmounting
• Mounting a file system attaches that file system to a directory (mount
point) and makes it available to the system.
• The root (/) file system is always mounted. Any other file system can
be connected or disconnected from the root (/) file system.
20. • When you mount a file system, any files or directories in the
underlying mount point directory are unavailable as long as the file
system is mounted.
• These files are not permanently affected by the mounting process, and
they become available again when the file system is unmounted.
21. Implementation of VFS System Calls.
• A virtual file system (VFS) or virtual filesystem switch is an abstract
layer on top of a more concrete file system.
The purpose of a VFS is to allow client applications to access different
types of concrete file systems in a uniform way.