Final Year Project:
Using Linux Filesystems Under Windows
Chris Bryden
BEng. Electronics and Software Engineering
School of Computer Science
University of Birmingham
46
The resolution algorithm is implemented using a while loop to perform the
directory entry scan nested within another while loop used to read successive
parts of the filename. This works so:
while (next_filename_offset is less than path_length)
{
read Nth directory;
read (N+1)th filename;
while(directory_offset is less than directory_length)
{
read next directory entry;
if( (N+1)th filename = current directory entry name)
{
next_inode = current_directory_entrys_inode;
break;
}
}
increment N;
}
return next_inode;
Looking at the source code for this function, it is clear to see where all the above
psuedocode instructions have been implemented. The function returns the inode
number of the inode representing the file or directory This function makes up
part of the interface between layers 1 and 2.
5.18 Layer 1: The CopyFile Funciton
This file is used to copy a file from the ext2 filesystem to a DOS
filesystem. As arguments it takes the inode number of the source file, the DOS
path (including drive letter) of the destination file and a flag to indicate whether
the function is to overwrite the destination file if it already exists. The copy file
function returns an error code, which is defined in L1-copy.h:
The first two tasks that this function has to perform are retrieving the inode
for the source file, and the block list for this inode. It does this with calls to
GetInode and ReadBlockList, respectively.
The next operation is to test if the source file exists, this is done by
attempting to open the source file for reading. If the overwrite flag, fOWrite, is
#define INODE_NOT_FOUND 1
#define BLK_LIST_ERR
2
#define OPEN_FILE_ERR
3
#define FILE_EXISTS
4
#define PATH_NOT_FOUND 5