Final Year Project:
Using Linux Filesystems Under Windows
Chris Bryden
BEng. Electronics and Software Engineering
School of Computer Science
University of Birmingham
24
retrieving a directory listing. It should be noted that because directories are
implemented as a special type of file in the ext2fs, this process is practically
identical to that for reading a file.
4.3.1 A Mini-case study: Obtaining a Directory Listing
The steps in the diagram on the
right show the tasks necessary to read a
directory.
Firstly, the inode number of the
inode that represents the directory has to
be found. For further details on how this is
done, please refer to section 5.17. It is
then necessary to read this inode from the
inode table. However, to be able to do this,
the group that the inode is in has to be
determined. This is a simple calculation
based
on
information
held
in
the
superblock, which is conveniently buffered
in memory. Once the group has been
determined, its group descriptor has to be
read. These are also buffered in memory,
but a function is necessary to locate and
return the correct descriptor.
The group descriptor is necessary
to determine the block address of the start
of the inode table. Once this has been
read, the required inode can be found and
copied into memory.
Next, the list of blocks that the inode
has allocated has to be read, so this means reading direct, indirect, and possibly
double and triple indirect blocks (although this is unlikely in the case of a
directory). So a function is necessary to read the complete list of blocks, and it
must be designed to handle all the levels of indirection
Once this block list has been read, the actual blocks can be accessed.
This is, in effect, reading the directory.
This mini case study has illustrated the need for the functions listed at the
beginning of this section. The function of copying a file only differs in that on
reading the blocks allocated to the inode, they are copied into an open file within
the DOS filesystem.
Convert pathname to inode number
Determine which group the inode is in
Read the group descriptor for that group to
determine the start of the inode table
Read inode from inode table into memory
Read the list of blocks allocated to that inode.
These blocks make up the file that contains the
directory listing
Read the blocks, and, therefore the directory listing