Final Year Project:
Using Linux Filesystems Under Windows
Chris Bryden
BEng. Electronics and Software Engineering
School of Computer Science
University of Birmingham
27
regarding the filesystem that has just been mounted. This information includes
the filesystem size, the date of the last mount and the flag that indicates whether
the filesystem contains errors.
4.4.3 The ls command
This function acts in a similar way to the command line ls or dir
commands. Its task is to return a directory listing to the calling application. A
path can be supplied to this function and a listing of that directory will be
returned, or if none is supplied, a listing of the current directory is returned.
To obtain a directory listing this function first calls the function in layer 1 to
convert the path of the directory to an inode number, it then calls the read
directory function to read the directory represented by that inode.
The directory listing is passed to the calling application.
4.4.4 The cd command
This function changes the current directory to the one specified by the
calling application. It performs a check to determine whether the specified path
points to a valid directory, and if so, changes the stored current directory to the
one specified.
To verify that the directory is a valid one, the layer 1 function is called to
obtain the inode number of the inode representing the specified directory. Once
the inode has been obtained, its type is one of the values it holds, so it can be
easily determined if the inode represents a directory. To read the directory the
read directory function in layer 1 is called to read the directory corresponding to
the inode number specified.
The cd command returns the path of the current directory to the calling
application.
4.4.5 The cp command
This function copies a file from the ext2fs path specified to the DOS path
specified. It first performs checks on the validity of both paths, and checks to see
that the destination file does not already exist. If all is well, the file is copied from
the source to the destination. If not an error code is returned to the calling
application.
To copy the file the source path is converted to an inode number by the
layer 1 function provided to do this. Then the copy file function in layer 1 is called