Hi,
I have to complete program which creates a simple filesystem by using an array of 1024 byte blocks by contiguous allocation and the following header:
also blocks 0-127 will be used to store dir entries, and i have to implement my own function which are at the end of the header. My main difficulty is with the direntries and how to store the in the disk structure which stores bytes?Code:#include <sys/stat.h> typedef unsigned char Byte; typedef struct Tblock Block; struct Tblock{ Byte sector[1024]; }; Block disk [4096]; typedef struct Tdirentry Direntry; struct Tdirentry{ int startblock; int length; char name[56]; // sizeof(Direntry) == 64 // struct stat *buf; }; typedef struct Tfiledata Filedata; struct Tfiledata{ int blockno; int charno; Byte blockcopy[1024]; }; int myfgetc(Filedata * src); // read one byte void myfputc(Byte x, Filedata * dst); //write one byte Filedata * myopen ( const char * name, const char * code); //open file for reading or writing -- return 0 for failure void myclose(Filedata * ff); // close the file
Any help appreciated.