CS3431 - Programming Assignment 2

Overview

For this assignment, you are to implement a very rudimentary file system. We will be using the layered approach in this file system. I will be providing the functionality of the layer below you in physical.h and physical.c. The description of the functionality you need to provide is found in filesys.h, and a skeleton implementation in filesys.c. I also am providing a testing routine testfs.c which conducts a number of tests on your file system, which we will also use to grade your final submission. I have also provided a Makefile which you can use to build your file system implementation.

For simplicity, we can assume a predefined maximum number of files allowed on our file system (MAX_FILES) which is defined as 128. This allows us to reserve enough disk space on our disk during a format operation to keep information about each file. We also specified a small fixed maximum file name length (MAX_FILE_NAME), which is defined as 8. This includes the zero byte terminator, so the effective maximum file name limit is 7 characters. We also assume a fixed limit on the number of files that can be open at once (MAX_FILESOPEN), set to 10.

As we said in class, you are to work in teams of two people. I want to be sure that every team has a proficient C programmer, since this is an operating systems course, not a C programming course. If you made less than 100 on program 1, you must work with someone who did score 100.

Which system to use

We should all use system "elvis.cc.gatech.edu" for compilations and test runs. You can log into any system on the CoC network, and then telnet to elvis by entering "telnet elvis" (from a unix system), or using the telnet window on WindowsNT and opening a connection to "elvis". Elvis has 4 CPU's and lots of memory, so it should not be a bottleneck for us getting our work done.

Getting Started

Start by choosing an appropriate cluster size. We don't want to track the use of each individual sector on the disk, since this would require substantial overhead. Too large of a cluster size will waste disk space.

Next, define a C Structure to use for a "Directory" entry, to be stored on disk. I was able to create one that used exactly 16 bytes, which worked out nicely. Next choose a way to mark clusters as reserved (or alternately mark clusters as available), and choose a way to link clusters together. With those two decisions made, you can then determine apriori how much disk space to reserve for the Directory table and the Allocation table. Then, code the "FormatLow" and "FormatHigh" routines, which should simply zero out all disk sectors, and initialize the Directory Table and Cluster Allocation Table appropriately. You can test the format routine by running "testfs 1 2", which says to run test number 1 (FormatLow) followed by test number 2 (FormatHigh).

At this point, you can code the "Mount" procedure. This will be called every time we run "testfs", and allows you to do any initialization you might need (such as reading the Directory and Allocation tables into memory). Then code the "UnMount" procedure, which will be called in "testfs" when all tests are completed. This allows you to write any updates to the Directory and Allocation table back to the disk.

Next, you need to decide what information you need in an "Open File Table" entry, to keep track of open files. At a minimum, you need a pointer to the Directory entry, a pointer to a memory buffer for data (probably one cluster in size), a current offset into the buffer, and the current file position.

Next, code the OpenWrite routine, which needs to create a new Directory entry for the file specified and creates a corresponding Open File Table entry, and the Delete routine, which deletes an existing file. For Delete, be sure to mark any clusters that were assigned to that file as "available". Note that OpenWrite should automatically delete any previously existing file by the specified name.

Then, code the "Write" routine. Write should write the data first to a memory buffer (writing that buffer to disk only when it fills up or on a subsequent "flush" call).

Next should be flush, which causes the memory buffer to be written out to disk. Flush should NOT adujst the current file position.

The remaining routines can be coded in any order. THe requirements for all routines are clearly documented in "filesys.h" and "filesys.c". You should probably save "Seek" and "OpenExtend" until the last, as they are the most complicated.

Testing your Program

You can test your program using the "testfs.c" program I provided. It accepts one or more numeric command line arguments which specify which tests to run, and in which order. Presently there are 12 tests available in testfs, numbered from 1 to 12. As you are debugging, feel free to add debug statements into testfs.c. But for final testing we will use the original testfs.c and will likely test your final submission as follows:

testfs 1 2 3 4 5 6 7 8 9 10 11 12

testfs 7

testfs 8

The second two will insure "persistence" (you correctly updated the Directory and Allocation table on the disk).

Turning In Your Program

Email your "filesys.c" program (not as an attachment, but just as the body of the message) to namgeun@cc. One way to do this is (on unix):

mail namgeun@cc < filesys.c

Contact Information:

riley@cc.gatech.edu
College of Computing
Georgia Institute of Technology
Atlanta, GA 30332-0280

Last Modified: Nov. 26, 1997