You need to open the virtual disk file in sfs_format () function as well. At the end of the function you need to close it. The format function will initialize the on disk structures of the file system.
You can use memcpy() or bcopy() to copy n bytes from one location to another one in program memory.
You can use type-casting to put/access a structured data in a buffer (character array) like the following.
struct foo {
int a;
int b;
int c;
};
struct foo * p;
char buf[100];
p = (struct foo *) buf;
p->a = 10 ;
p->b = 20;
p->c = 30;