Final Year Project:
Using Linux Filesystems Under Windows
Chris Bryden
BEng. Electronics and Software Engineering
School of Computer Science
University of Birmingham
19
3.3.6 Directories
Directories are implemented as a special kind of file. The file contains a
linked list of directory entries. A linked list is used instead of fixed size entries to
save disk space. The directory entry links a filename with an inode number, it
also stores the name length and entry length so a particular entry can be located
within the list. The filename is not stored as a null terminated string, hence its
length has to be stored.
The structure of a directory entry is shown below, taken form ext2_fs.h:
·
=inode - The inode number of the file.
·
=rec_len - the directory entry length.
·
=name_len - the filename length.
·
=name - the name of the file.
An entry exists in the directory for each file contained within that directory. The
first two entries in any directory are . and .., which point to the current directory
and the parent directory respectively.
/*
* Structure of a directory entry
*/
#define EXT2_NAME_LEN 255
struct ext2_dir_entry {
unsigned long inode;
unsigned short rec_len;
unsigned short name_len;
char
name[EXT2_NAME_LEN];
};