Final Year Project: Using Linux Filesystems Under Windows   Chris Bryden BEng. Electronics and Software Engineering    School of Computer Science   University of Birmingham 74 The  directory  list  held  in  the  memory  location  pointed  to  by  lpDirData  is stored in the same format as directories are stored on the disk. That is, a linked list of directory entries having the following format, defined in ext2_fs.h : The directory entries are not of the same size, as the next entry starts as soon as the name of the previous entry ends. For this reason, rec_len is used to determine the start of the next directory entry. This is shown in the example code below: #define EXT2_NAME_LEN 255 struct ext2_dir_entry { unsigned long   inode; /* Inode number */ unsigned short rec_len; /* Directory entry length */ unsigned short name_len; /* Name length */ char name[EXT2_NAME_LEN]; /* File name */ }; void ListDirectory(char PathName[MAX_PATH_LEN]) { unsigned long ulDirOffset = 0; DIRENT DirEnt; DIRECTORY Directory; Directory = ext2_ls(&PathName); if(Directory.ulDirLen == 0 || Directory.lpDirData == NULL) { /* INVALID DIRECTORY */ while(ulDirOffset < Directory.ulDirLen) { /*get directory entry*/ _fmemcpy(&DirEnt,Directory.lpDirData + ulBuffOffset, sizeof(DIRENT)); /*Increment next entry offset */ ulBuffOffset += DirEnt.rec_len; /*null terminate string*/ DirEnt.name[DirEnt.name_len] = NULL; /*DISPLAY DIRECTORY ENTRY*/ } return; }