The Linux Programming Interface

(nextflipdebug5) #1

278 Chapter 14


various information about the file, including its type, size, link count, ownership,
permissions, timestamps, and pointers to the file’s data blocks.
Linux provides a range of journaling file systems, including Reiserfs, ext3, ext4,
XFS, JFS, and Btrfs. A journaling file system records metadata updates (and option-
ally on some file systems, data updates) to a log file before the actual file updates
are performed. This means that in the event of a system crash, the log file can be
replayed to quickly restore the file system to a consistent state. The key benefit of
journaling file systems is that they avoid the lengthy file-system consistency checks
required by conventional UNIX file systems after a system crash.
All file systems on a Linux system are mounted under a single directory tree,
with the directory / at its root. The location at which a file system is mounted in the
directory tree is called its mount point.
A privileged process can mount and unmount a file system using the mount()
and umount() system calls. Information about a mounted file system can be
retrieved using statvfs().

Further information
For detailed information about devices and device drivers, see [Bovet & Cesati,
2005] and especially [Corbet et al., 2005]. Some useful information about devices
can be found in the kernel source file Documentation/devices.txt.
Several books provide further information about file systems. [Tanenbaum,
2007] is a general introduction to file-system structures and implementation.
[Bach, 1986] provides an introduction to the implementation of UNIX file systems,
oriented primarily toward System V. [Vahalia, 1996] and [Goodheart & Cox, 1994]
also describe the System V file-system implementation. [Love, 2010] and [Bovet &
Cesati, 2005] describe the Linux VFS implementation.
Documentation on various file systems can be found in the kernel source sub-
directory Documentation/filesystems. Individual web sites can be found describing
most of the file-system implementations available on Linux.

14.13 Exercise


14-1. Write a program that measures the time required to create and then remove a
large number of 1-byte files from a single directory. The program should create
files with names of the form xNNNNNN, where NNNNNN is replaced by a random six-digit
number. The files should be created in the random order in which their names are
generated, and then deleted in increasing numerical order (i.e., an order that is
different from that in which they were created). The number of files (NF) and the
directory in which they are to be created should be specifiable on the command
line. Measure the times required for different values of NF (e.g., in the range from
1000 to 20,000) and for different file systems (e.g., ext2, ext3, and XFS). What
patterns do you observe on each file system as NF increases? How do the various
file systems compare? Do the results change if the files are created in increasing
numerical order (x000001, x000001, x0000002, and so on) and then deleted in the same
order? If so, what do you think the reason(s) might be? Again, do the results vary
across file-system types?
Free download pdf