Chapter 8: The Virtual Filesystem
Chapter 8: The Virtual Filesystem............................................
C-Standard Library (Libc)
Application Application Application
System-
calls
Userspace
Virtual Filesystem (VFS) Kernelspace
Ext2/3 Reiserfs XFS
Figure 8-1: VFS layer for filesystem abstraction.
8.1 Filesystem Types
Filesystems may be grouped into three general classes:
- Disk-based filesystemsare the classic way of storing files on nonvolatile media to retain
their contents between sessions. In fact, most filesystems have evolved from this category.
Some well-known examples are Ext2/3, Reiserfs, FAT, and iso9660. All make use of block-
oriented media and must therefore answer the question, how to store file contents and struc-
ture information on the directory hierarchies. Of no interest to us here is the way in which
communication takes place with the underlying block device — the corresponding device
drivers in the kernel provide a uniform interface for this purpose. From the filesystem point
of view, the underlying devices are nothing more than a list of storage blocks for which an
appropriate organization scheme must be adopted. - Virtual filesystemsare generated in the kernel itself and are a simple way of enabling
userspace programs to communicate with users. Theprocfilesystem is the best example of
this class. It requires no storage space on any kind of hardware device; instead, the kernel
creates a hierarchical file structure whose entries contain information on a particular part
of the system. The file/proc/version, for example, has a nominal length of 0 bytes when
viewed with thelscommand.
wolfgang@meitner>ls -l /proc/version
-r--r--r-- 1 root root 0 May 27 00:36 /proc/version
However, if the file contents are output withcat, the kernel generates a list of infor-
mation on the system processor; this list is extracted from the data structures in kernel
memory.
wolfgang@meitner>cat /proc/version
Linux version 2.6.24 (wolfgang@schroedinger) (gcc version 4.2.1 (SUSE Linux))
#1 Tue Jan 29 03:58:03 GMT 2008 - Network filesystemsare a Halfway House between disk-based and virtual filesystems. They
permit access to data on a computer attached to the local computer via a network. In this
case, the data are, in fact, stored on a hardware device on a different system. This means
that the kernel need not be concerned with the details of file access, data organization, and
hardware communication — this is taken careof by the kernel of the remote computer. All
operations on files in this filesystem are carried out over a network connection. When a pro-
cess writes data to a file, the data are sent to the remote computer using a specific protocol