0

Basically in my project I have to create a VSF on unix os using gcc. I have made the architecture which consists of a meta block, header which contains the file descriptor and the file blocks. Now if I have to create a file system of say 1 GB, I am assuming that my meta will take 250KB, Headers will take 1MB and rest will be allocated to my file blocks. Because I am creating binary files only so I am using fread/fwrite function to write the structure of my blocks into the binary file. Now I want to pass the size 1 GB to my function which will create the different blocks. Now my question is how to create different blocks of given size using fwrite function so that all 1GB space will be distributed accordingly?

Ananda
  • 1,572
  • 7
  • 27
  • 54

1 Answers1

1

The signature for fwrite function is

fwrite(const void * restrict ptr, size_t size, size_t nmemb,
         FILE * restrict stream);

You just need to pick up such numbers that size*nmemb = 1G.

If i got your question wrong, please comment.

arrowd
  • 33,231
  • 8
  • 79
  • 110