2 . 4
B A S I C F I L E S Y S T E M O P E R AT I O N S
ditional arguments may specify file access permissions, file modes, or other
flags specific to a given file system.
After allocating an i-node for a file, the file system must fill in whatever
information is relevant. File systems that store the creation time must record
that, and the size of the file must be initialized to zero. The file system
must also record ownership and security information in the i-node if that is
Creating a file does not reserve storage space for the contents of the file.
Space is allocated to hold data when data is written to the file. The cre-
ation of a file only allocates the i-node and enters the file into the directory
that contains it. It may seem counterintuitive, but creating a file is a simple
Creating a directory is similar to creating a file, only slightly more complex.
Just as with a file, the file system must allocate an i-node to record metadata
about the directory as well as enter the name of the directory into its parent
Unlike a file, however, the contents of a directory must be initialized. Ini-
tializing a directory may be simple, such as when a directory is stored as a
simple list, or it may be more complex, such as when a B-tree is used to store
the contents of a directory. A directory must also contain a reference back
to its parent directory. The reference back is simply the i-node number of
the parent directory. Storing a link to the parent directory makes navigation
of the file system hierarchy much simpler. A program may traverse down
through a directory hierarchy and at any point ask for the parent directory to
work its way back up. If the parent directory were not easily accessible in any
given directory, programs would have to maintain state about where they are
in the hierarchy--an error-prone duplication of state. Most POSIX-style file
systems store a link to the parent directory as the name "
" (dot-dot) in a
directory. The name "
" (dot) is always present and refers to the directory
itself. These two standardized names allow programs to easily navigate from
one location in a hierarchy to another without having to know the full path
of their current location.
Creating a directory is the fundamental operation that allows users to build
hierarchical structures to represent the organization of their information. A
directory must maintain a reference to its parent directory to enable nav-
igation of the hierarchy. Directory creation is central to the concept of a
hierarchical file system.
Opening existing files is probably the most used operation of a file system.
The task of opening a file can be somewhat complex. Opening a file is
Practical File System Design:The Be File System
, Dominic Giampaolo