How to create an array of size 2^16 blocks consisting of 256 bytes
<p>So my title says it all. I have to create a file system simulation for my Operating Systems class. I am still not very good with C which is why i am asking for help. And one of the things that is throwing me off is that i have to create a storage that is an array of 2^16 blocks of 256 bytes each; a block is just a plain sequence of bytes until it is overlaid with a structure (use a union, of course): directory or file meta-data, an index node, or a data node; there is also a type of the node: </p>

<p>this what i did</p>

<pre><code>#include "project1task3.h"

int main()
{

    createFileSystem();
}
/*
 * create the file system 
 * (i.e., allocate and initializing all structures and auxiliary data; 
 * create the superblock) 
 * 
 * 
 * */
void createFileSystem()
{
    // setting up file system "superblock"
    FS_NODE fileSystem;
    NODE typeNode;
    NODE* p; // pointer that will point to file or director
    //typeNode.type = DIR;
    int i;
    int j;
    size_t nodeSize;
     // allocate space for the fixed sie and the variable part (union)
    nodeSize = sizeof(FS_NODE) + sizeof(NODE);
    if ((memory = malloc(nodeSize)) == NULL)
    {
        for(i = 0; i &lt; MEM;i++)
        {
            for(j = 0; j &lt; BLOCK_SIZE;j++)
            {
                //not sure if this is how it should be
                memory-&gt;content.index[j] = 0;

            }
        }
    }




    strcpy(fileSystem.name,"\\");
    fileSystem.creat_t = 0; // set creation time to 0
    fileSystem.access = 400;  //the access should not allow for deletion or name change, 400 will allow only for read in
    fileSystem.owner = 000;// no permissions yet basically none
    fileSystem.size = 0;
    fileSystem.block_ref = BLOCK_SIZE;
    fileSystem.access_t =0;
    fileSystem.mod_t = 0;
    /*
     *A file-descriptor node holds meta-data information about a file or a directory
     *  such as size, access rights, creation time, access time, and modification time, along with a pointer to actual content of the file or director 
     * */
    typeNode.content.fd.creat_t =0;
    typeNode.content.fd.access = 400;
    typeNode.content.fd.size=0;
    typeNode.content.fd.mod_t = 0;
    typeNode.content.fd.access_t = 0;
    //if((memory= malloc(sizeof *memory + MEM)) != NULL)

    /*
     * 
     * In case of a node with the type opf directory, the size indicates the number of files in the directory, 
     * and the block reference points to the index block that holds indices to all files in the directory.
     *  Assume that a directory may hold directly up to 127 files or directories; each index of the index block points to a file or a directory descriptor.
     *  Of course, each of the subdirectries may hold another 127 files or directories, and so on.
     * 
     * 
     * */

     /*
      * *
      * 
      * In case of a file, the size in the file descriptor indicates the actual size of the file. 
      * The block reference either ponts to a single data block 
      * if the size of the file is less than 254, or to an index block with an array of references to data blocks for file larger than 254.
      *  Assume that the maximum size of a file is 127 * 254 (i.e., maximum allowed for a one-level indexing).
      * 
      * 
      * 
      * */



}
/*
 * 
 * create a file (i.e., allocate one block for meta-level information; set the size to 0, the times to the current time, and the access rights to some default)
create of a directory (just like a file creation, but with a different type)
delete a file (return blocks and clean up your supporting structures; e.g., reset the bits in the bit vector)
delete a directory (delete the files from the directory, and then delete the directory; clean up)
obtain file information (type - file or directory, size, times, access right, owner) 
 * 
 * 
 * */
void createAFile()
{
}

void createDirectory()
{
}


void deleteFile()
{
}

void obtainFileInfo()
{

}
</code></pre>

<p>THis is the header</p>

<pre><code>#include &lt;time.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;sys/stat.h&gt;
#include &lt;string.h&gt;
#define BLOCK_SIZE 256
#define MAX_NAME_LENGTH 128
#define DATA_SIZE 254
#define INDEX_SIZE 127
#define MEM 65536 //2^16

typedef char data_t;
typedef unsigned short index_t;

typedef enum
{
   DIR,
   FILEE,
   INDEX,
   DATA
} NODE_TYPE;

typedef struct fs_node
{
   char name[MAX_NAME_LENGTH];
   time_t creat_t; // creation time
   time_t access_t; // last access
   time_t mod_t; // last modification
   mode_t access; // access rights for the file
   unsigned short owner; // owner ID
   unsigned short size;
   index_t block_ref; // reference to the data or index block
} FS_NODE;

typedef struct node
{
   NODE_TYPE type;
   union
   {
      FS_NODE fd;
      data_t data[DATA_SIZE];
      index_t index[INDEX_SIZE];
   } content;
} NODE;

// storage blocks

NODE *memory; // allocate 2^16 blocks (in init
void createFileSystem();
void createAFile();
void createDirectory();
void deleteFile();
void obtainFileInfo();
</code></pre>

<p>idk if i set it up right, but i think this is how i should set up the node memory to create an array of 2^16 blocks of 256 bytes per block. Any help would be appreciated.</p>