CS 302 - Programming Assignment 8

This assignment makes use of two files contained in this zip file.

For this assignment you are to write a program that "unpacks" and displays the File Allocation Table (FAT) on a floppy disk so that the FAT can be more easily understood and manipulated. One of the points of this assignment is to emphasize why you want the operating system to provide "device abstractions" (because accessing a floppy disk at this low a level is not all that easy) and to also give you an idea of how an operating system can maintain a file system on a disk.

This assignment will use your floppy.h file from Assignment 7.

You are to write implementations for the following three functions, which are described in comments in the file floppyFAT.h which is contained in the above zip file.

BOOL fatRead(HANDLE theDisk, unsigned char *buffer);
void unpackFAT(unsigned char *buffer, int* unpackedFAT);
int countObjects(int* unpackedFAT);
Your definitions of the three functions must work with the driver program floppyFAT.c which is also in the above zip file (you do not need to make any changes in the file floppyFAT.c). Make sure that you error check all of the Win32 function calls that you make.

Notice that the third function in floppyFAT.h counts how many objects are on the floppy. An "object" is either a file or a directory. You need to read the references about the FAT12 file system and figure out a simple way to use the unpacked FAT to determine how many objects are on a floppy.

When you have this program done, experiment with it. Format a floppy and then look at its FAT. Compare the display of the FAT given by floppyFAT.c with dumping sectors 1 through 9 using floppy.c from assignment 7. Add a small file to the floppy and look at the fat again. Add a few small and medium size files to the floppy. Look at the FAT again. Delete the first couple of files that you put on the floppy. Look at the FAT again. Add a couple of new files to the floppy. Did they use up the FAT entries left empty by the deleted files? What does it mean for a floppy to become "fragmented"? Run floppyFAT.c and floppy.c simultaneously (in two different console windows) and use the display of the FAT given by floppyFAT.c to find and view, using floppy.c, the data sectors of a multi sector file.

Turn in a zip file containing your version of the floppyFAT.h file and also the floppyFAT.c file and your version of floppy.h from assignment 7.

This assignment is due Monday, April 25.

In your program you will need to make use of the following C operators.

Here are links to some web pages about the FAT file system.


Return to the main homework page.
Return to the CS 302 home page.


compliments and criticisms