Final Year Project:
Using Linux Filesystems Under Windows
Chris Bryden
BEng. Electronics and Software Engineering
School of Computer Science
University of Birmingham
73
·
=sMountTime - A string giving the last time the filesystem was mounted
read/write
·
=usState - The curren state of the filesystem. This can take one of two
values:
·
=EXT2_VALID_FS 0x0001 - Valid Filesystem
·
=EXT2_ERROR_FS 0x0002 - The filesystem may contain errors
If the MountInfo structure contains valid data on the return of the
ext2_mount_fs function call, the filesystem was mounted successfully.
This ext2_mount_fs function is simple to implement, as shown in the
example below.
20.4 Implementing the ext2_ls Function
DIRECTORY FAR PASCAL ext2_ls(char far PathName[MAX_PATH_LEN]);
This function accepts one argument, the address of a string containing
the path of the directory to list, if this path is not specified, the current directory is
listed. The function returns a small structure of type DIRECTORY containing two
elements:
ulDirLen is the directory list length in bytes and lpDirData is a far pointer to the
memory location that the directory list is stored in.
void MountExt2Filesystem(unsigned short Drive, unsigned short Part)
{
MOUNTINFO MountInfo;
_fmemset(&MountInfo, 0, sizeof(MOUNTINFO));
MountInfo = ext2_mount_fs(Drive, Part);
if(MountInfo.ulInodes == 0)
{
/* NOT A VALID EXT2 FILESYSTEM */
}
else
{
/*PARTITION MOUNTED SUCCESSFULLY, DISPLAY MOUNTINFO TO USER */
/*CHECK usState TO DETERMINE CLEAN OR DIRTY FILESYSTEM */
}
return;
}
typedef struct directory {
unsigned long ulDirLen;
LPBYTE lpDirData;
} DIRECTORY;