Final Year Project:
Using Linux Filesystems Under Windows
Chris Bryden
BEng. Electronics and Software Engineering
School of Computer Science
University of Birmingham
23
4.3 Layer 1 - The Ext2 Translation Layer
This layer forms the bulk of the library. It must process the raw data read
using the read logical sector function provided by layer 0 to produce output such
as inodes and directory listings that can be used by layer 2 to implement basic
filesystem commands such as ls and cd. It must also perform the task of copying
files
The tasks that the functions in this layer have to perform are:
·
=Reading a logical block from the filesystem
·
=Reading the superblock information
·
=Reading a specified group descriptor
·
=Reading a specified inode
·
=Reading the list of blocks allocated to a particular inode
·
=Converting a path name to an inode number
·
=Copying a file from the ext2 filesystem to the DOS filesystem
·
=Reading a directory listing
The interface that layer 1 has to provide to layer 2 consists of the
functions to read a directory, convert a path name to an inode number, read an
inode and copy a file.
The foundation for this layer is the function to read a block form the
filesystem. This interfaces layer 1 with layer 0. Under ext2fs, the block size is set
when the filesystem is created, so it can take a number of different values. The
function to read a block has to read a specified block from the filesystem, taking
into account the block size. This function, therefore, performs one or more calls
to the read logical sector function of layer 0 when called to read a block. As the
read block function is used every time any operation needs to read a block form
disk, it is vital that it is efficient. To improve performance a caching system is
implemented within this function. For further details regarding the implementation
of the cache please see section 5.11.
The first task that has to be performed by this layer is obtaining the
superblock information. It is based upon the information that is contained in the
superblock that the validity of the filesystem can be determined, also information
contained in the superblock is needed to perform calculations necessary to even
the most basic of filesystem operations. The superblock and the group
descriptors are both read and buffered in memory when ext2lib is first loaded, for
performance reasons.
To illustrate how the rest of the functions fit together to provide the
filesystem commands of layer 2, and in so doing illustrate what is necessary of
these functions and what they require, a mini case study will be used. That of