File System Assignment

Create a File System

Define a set of C (or at your own risk, C++) functions that implement a complete disc file system. You may use the emulator or the fakedisc functions for a normal unix program.

You must provide functions to do at least the following:
  1. Format a disc. Taking an empty or unwanted emulated disc drive (or fake-disc file), make it completely ready for use. This includes providing some kind of 'superblock' with essential volume information, some way of knowing which blocks are available for use, and some kind of root directory (which may initially be empty).
  2. Mounter, dismounter, flusher. Before using a disc, one should expect the system to have to do something to prepare that disc. Perhaps just reading its super-block, perhaps reading part of the free-list into memory, there are many possibilities. It is sensible to make the programmer call a 'Mount' function to prepare a disc for use before using it. Also, when a program has finished with a disc, it is sensible to make the programmer 'dismount' it, so that everything held in memory may be made safe. Additionally, some kind of 'flush' function can be useful: its job is to make sure all information is safely on disc while the disc is still in use (in case of crashes, etc).
  3. Block allocator and deallocator. These are low level functions that will be used by your functions: other programmers should not be expected to use them at all.
  4. File Creator and/or Opener. Given the name of a file (and possibly other parameters specifying create/read/write/etc) prepare a file for access.
  5. File Close. After a file has been opened/created, and used, closing it, freeing up all system resources used by it, is a useful operation.
  6. Read from File. After a file has been opened/created, asking for the next N bytes of data from that file to be read into a memory array.
  7. Write to File. After a file has been opened/created, asking for N bytes of data from a memory array to be written into it.
  8. Get File Info. Retrieving useful information about a file, such as its name, length, creation date, etc.
A programmer should be able to include your functions in a program of his/her own and get from them the functionality of a normal file system with a reasonably convenient interface. Your functions should be documented sufficiently that a competent programmer could use them successfully without having to see your implementation.

If you use the emulator, it has a built-in debugging system that lets you inspect (and even modify) the contents of any disc block. Look at the emulator's on-line help system for details. The compiler has various system functions (their names begin with "sys$" for accessing discs and the data on them; look at the emulator/compiler documentation for details.

Showing that your functions Work

You should provide a simple(-ish) test program that makes use of your functions. It should act like a very basic shell, allowing the user/tester to enter commands such as "dir" or "ls", "exit", and various commands for creating, adding to, deleteing, and showing the contents of files.

Act as though you are a developer for a new kind of processor: no operating system exists for it yet, so you are making a very basic kind of DOS shell for it, so that people can test the disc system (which you are also responsible for creating). Any other fancy stuff you choose to put in (e.g. what good is a DOS shell if it can't run programs?) will be a welcome bonus.

Submissions

Document your work in a nice report. The report should accurately describe the implementation choices you made, and the reasons behind them. It should also detail how your functions and shell are properly used. Submit the report and the working code.