Project 4: The Nachos File System

Due Date: June 14th

questions: besmith@cs.ucsb.edu

Overview

Currently, the Nachos File System is primitive and is limited in many ways. In this project, you will remedy some of these limitations.

In project 2, you wrote the kernel code to handle file-system calls, but did not implement the file-system; you either used Unix syscalls directly or you used the Nachos stub implementation of the file-system. If you used the first method, you will need to modify your syscall code to use the Nachos file-system interface. Make your implementation of the file-system robust. User code should not be able to crash Nachos. Handle error conditions gracefully wherever possible. When in doubt, ask "What would Unix do in this case? You may also assume (or require) that only a single process is accessing the disk at any given time. Depending on how you solved project 2, this may be already be a "feature".

Project Stages

You will be primarily be modifiying the files in the filesys directory.

Modify your system calls to use Nachos file-system stubs (if they don't already)

Understand how Nachos emulates a disk: Take a look at disk.cc in the machine directory. This file contains code used to emulate an actual disk. You won't want to modify these files, but it is useful for understanding the other parts of the file-system. On a real machine (not emulated), a disk driver would provide an interface similar to that provided by the Disk class.

Examine the "-f" and "-cp" commmand line switches for Nachos to see what they do and how you'll want to use them.

Understand how Nachos implements files: Take a look at openfile.cc. You should use the routines in this file for your system calls. If you implemented your system calls using the Nachos file-system, you should (hopefully :)) understand how the OpenFile class works. The OpenFile class uses the FileHeader class. Examine the FileHeader class and see why the file size is limited. Look at the implementation of FileHeader and see what each part is doing. Also, look through the code in the filesys directory to figure out why files cannot currently be resized.

Understand how Nachos implements a directory: Examine the directory implementation in directory.cc. Make sure you understand what is contained in a directory entry, and how an entry is created and modified.

Modify Nachos so that you can create large (up to 64KB) files: This will probably (but not necessarily) require you to implement doubly indirect blocks. The use of (indirect and) doubly indirect blocks to keep track of sectors used for large files was described in class. It is also described in OSC, Chapter 21.7.2 as a part of the inode description. For this, you will need to modify the FileHeader class. You should not have to modify anything else.

Allow the write() syscall to extend the size of a file: Currently, if the user tries to write beyond the end of the file, Nachos returns an error. Modify the current implementation so that a write beyond the end of the file extends the size of the file. Gracefully handle the case the disk is full - the user process should not crash. Instead an error should be returned.

Implement a hierarchical directory structure: This part of the project will require the most work. You will probably want to modify the DirectoryEntry class to include a flag that identifies an entry as a directory instead of a file. You will need to modify the Directory class, as well as the OpenFile class to implement the hierarchical directory structure. You will also need to implement a procedure that resolves file-names to the corresponding file-headers (or inodes). Every directory should include the "." and ".." entries. Use "/" as the delimiting character. You will also need to add two new system calls - for creating and deleting directories.

Implement a few simple UNIX file utilites to test your system: Implement a few programs to help you test your file-system implementation. Include them in the code handed in. Suggestions include ls, cat, touch and rm. Nothing fancy; just the basic functions. Use the shell to run these programs.

Suggestions

Write up your design and implementation in a file called PROJECT4_WRITEUP. Explain how you did things and what (if anything) doesn't work and why. Explain what test programs you created and how they work. As always, make sure that your code at least compiles and links as provided. Turn in your whole code directory, including any test programs that you created.