CSC 714 PROJECT: Implemention of a Real-time File System
Home
Implementation Details
Tests and Benchmark results
Schedule
Project Proposal
Project Report - 1
Project Report - 2
Final Report

 

 

Implementation Details of Real-time File System(RTFS) on Renesas M16 board
Members
    Gayathri TK [gtambar@ncsu.edu]

Jayush Luniya [jrluniya@ncsu.edu]

Data Structures Used
   
  1. Directory Control Block (DCB): The directory control block contains metadata about a directory. This includes information about the files in the directory. The number of files in a directory is bounded by MAX_FILE_ENTRIES parameter. The metadata for the subdirectories is maintained in separate DCBs.

    typedef struct dirEntry_t
    {
        char dirName[MAX_DIR_NAME_SIZE];    // Directory Name
        FileEntry files[MAX_FILE_ENTRIES];  // File Control Block Entries
        struct dirEntry_t *leftChild;      // Leftmost Child
        struct dirEntry_t *rightSibling;  // Next subdir at the same level.
    }DirEntry, *DIRENTRY;

    The directory hierarchy is maintained as a tree as shown below:
  2. File Control Block (FCB): The file control block contains the metadata about a file. In order to reduce filesystem overhead, the FCB's are maintained inside the DCBs itself. We maintain an upper bound on the file size (NUM_BLKS_PER_FILE * DATA_BLK_SIZE)

    typedef struct fileEntry_t
    {
        unsigned int fileSize;   // File Size
        char fileName[MAX_FILE_NAME_SIZE];   // File Name
        int dataBlocks[NUM_BLKS_PER_FILE];   // File data Blocks
        BOOL isValid;    // File Entry is valid
    }FileEntry, *FILEENTRY;

  3. File Descriptor: File descriptor contains information about the open files in the system. Typically it contains information about the file it refers to and current read position. Since our file system supports writes only in append mode, there is no need for an explicit write pointer.

    typedef struct fileDesc_t
    {
        DIRENTRY dir;    // Directory in which the file exists
        int fileIndex;   // Index to the appropriate file entry in the DCB
        unsigned int readPos;   // Read Pointer
        BOOL free;   // File Descriptor is free
    }FileDesc, *FILEDESC;

  4. Filesystem Superblock: The filesystem superblock contains information about the filesystem itself like the pointer to the DCB of root, array of file descriptors and information about the free data blocks in the system.

    typedef struct superBlock_t
    {
        FileDesc fileDescriptor[MAX_FILE_DESC];  // File Desc Array
        int fdIndex;  // Start index to search for free file desc
        char data[MAX_DATA_BLKS][DATA_BLK_SIZE];   // Data Blocks
        char dataBitmap[DATA_BITMAP_SIZE];  // Free/Allocated Data Block Bitmap
        DIRENTRY root;   // Pointer to Root DCB
    }SuperBlock;

File System APIs
    RTFS filesystem supports the following APIs:

Directory Functions:
  • int f_mkdir(char *pathName)
        Description: Create a new directory. Pathname should be absolute.
        Return Value: Returns 0 on success, -1 on error.

  • int f_rmdir(char *pathName)
        Description:Remove an empty directory entry. Pathname should be absolute.
        Return Value:Returns 0 on success, -1 on error.
File Control Functions:
  • int f_creat (char *pathName)
        Description: Create a new file entry. Pathname should be absolute. f_create also allocates a new file descriptor.
        Return Value: Returns file descriptor number on success, -1 on error

  • int f_remove(char *pathName)
        Description:Remove the file entry. Pathname should be absolute.
        Return Value:Returns 0 on success, -1 on error.
File Access Functions:
  • int f_open (char *pathName)
        Description: : Open a file. Pathname should be absolute. We do not maintain the filesystem. We don't have any concept of file modes (read-only, write-only, read/write etc).
        Return Value: Returns file descriptor number on success, -1 on error.

  • int f_close(int fd)
        Description:Close an open file.
        Return Value:Returns 0 on success, -1 on error.

  • int f_read(int fd, void *buf, int count)
        Description:Read up to count bytes from file descriptor fd into the buffer starting at buf
        Return Value:On success, the number of bytes read is returned (zero on EOF), -1 on error.

  • int f_write(int fd, void *buf, int count)
        Description:Attempts to write count of data to the object referenced by the descriptor fd from the buffer pointed to by buf.
        Return Value:On success, the number of bytes written is returned, -1 on error.
Mini Shell
    To test the filesystem APIs we implemented a mini shell that supports the following commands:

mkdir Command to create a new directory
rmdir Command to remove an empty directory
touch Create a new file with file size = 0
remove Remove a file
cat Reads a file sequentially and writes to standard output
append Appends to a file
cd Change Present Working Directory (PWD)
ls View PWD directory contents
exit Exit the shell
Open Issues
   
  • Porting Issues:The present filesystem APIs have been tested using a mini-shell as a standalone application. We are currently working on issues and changes required for porting the filesystem to the Renesas board and testing it using the mini-shell on that board


  • Real Time Guarantees:Although the filesystem has been designed keeping real time issues in mind, we have to work on specifying the worst case bounds on file operations