Hi all,

This virtual file system is implemented as a binary file and I have a problem with some of the functions as it needs to incorporate with Unix and I don't know how/where to start. The basic functions (i.e. manipulation) I had to perform are:

1. Display a directory listing
2. Renaming a file
3. Removing a file
4. Display the contents of each file

The starting point for the program is as follows:

Code:
#define FILE_SYS_SIZE 1024 
#define BLOCK_SIZE 32 
#define DATA_SIZE (BLOCK_SIZE - 2 * sizeof(unsigned char) - sizeof(short)) 
#define FILE_NAME_SIZE (DATA_SIZE-2*sizeof(short)) 
#define HEADER_BLOCK 11 
#define FENTRY_BLOCK 13 
#define DATA_BLOCK   15 
#define FREE_BLOCK   17 
typedef struct 
{ 
        short  size; 
        short  first_block; 
        char name[FILE_NAME_SIZE]; 
} FILE_ENTRY; 
typedef struct 
{ 
        short first_free; 
        short first_used; 
} HEADER; 
typedef struct 
{ 
        unsigned char num; 
        unsigned char type; 
        short next_block; 
        union { 
                HEADER header; 
                FILE_ENTRY fent; 
                char file_content[DATA_SIZE]; 
        } data; 
} BLOCK;
I already have a skeleton code:

Code:
int main() 
{ 
    /*
     * Directory listing & rename calls
     */
    ls(); 
    rename_file("File 1", "File ONE");
    ls();

    /*
     * Displaying the contents of the files
     */
    display( "File TWO" ); 
    display( "File THREE" ); 
    display( "MY FILE" );

    /*
     * Removing a File & Directory Listing
     */
    remove( "File TWO" );
    ls();

    return 0; 
}
My questions are:

1. How and where do I insert the mandatory Unix system functions i.e. open(), read(), write(), lseek(), close() into the program for it to work?

2. How and where do I insert the command to read from a given binary .dat file for it to work?

3. Do I use the rename method as above or the C method:
"int rename(const char *old, const char *new);

Thank you all for your attention and help!