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?

Any help appreciated.

12-08-2010

nonoob

Is your file system going to be simulated using one or two or more files? My guess is that the directory structure will be stored in one file, while the file's contents are simulated in another.

You would create/write your filled-in structures to those files. The thing to do is to sketch out an algorithm... what to do for "create", "open", etc.

12-08-2010

Chrishas

As far as I could tell,since the description says to use an array of 1024 byte blocks to simulate the filesystem, and then goes on to say use blocks 0..127 of the disk(which is the array) that I have to use one file.As I said before, the difficulty seems to be the writing and reading from the array cause its a byte array.

12-09-2010

nonoob

But the Tfiledata is 1024 + two ints for overhead. So I don't know how this is supposed to fit into one 1024 byte block.

I'm not sure where your problem is. Are you asking how to write a struct?

12-09-2010

Chrishas

Well i moved on from the initial problem of writing to the byte array
i get a segmentation fault from the following function, ipossibly from the fgetc but i dont know why

I'd have to see how you allocated memory for the 1024 disk entries.
You should probably read 4k at a time... why read 1 character at a time?
It doesn't make sense to check (!disk) so late in the game. I hope its address is non zero before you start to populate it.

12-09-2010

Chrishas

the disk[] is declared as in my 1st post,how would you read the characters?

12-09-2010

nonoob

First off, fopen(filename,"rb")) so that any new-line characters aren't fiddled with.

Use fread, with size being sizeof(TBlock) and nmemb being 4 to read 4k at a time. Reading in multiples of blocks is also good for catching errors like your disk not having an exact multiple of blocks. That is, if it's 1.5 blocks, there's a problem, but it would be hard to catch by reading individual characters.

As a side note, you should define BLOCK_SIZE as 1024 and N_BLOCKS as 4096. Then use them instead of hard coding magic numbers all over.