Nachos Phase 5
File System
The fifth phase of Nachos is to support the file system. Previously all you have
is the StubFileSystem
, a virtual file system that is not practical in real
operating systems. What you need to do in this phase is to build a file system that
supports the daily operations we take, create files, store them in the disk so
later they can be accessed, and manage them in a hierarchical structure.
Table of Contents
|
Description
To help you better develop your code in this phase, we provide you with a basic
framework in nachos.filesys
where you can start from. You’re free to come up with
your own idea and implement them in a different way. As long as you can demonstrate
the innovation and advantages of your design, you’ll be rewarded with extra
points.
The classes provided in this phase are:
-
nachos.machine.Disk
– a simulation of the hard disk whose operations are asynchronous -
nachos.machine.SynchDisk
- provide synchronous accesses to the disk -
nachos.filesys
– a basic framework of nachos file systemwhere you can start from.
To fulfill the tasks of this phase, the classes in the basic framework nachos.filesys
are designed as follows:
Inode class. The holder of all the basic information about a file, such as file
size, file position, etc. In the provided framework, the Inodes of a file are
organized into a list, each Inode occupies one segment. Note that unlimited size
of a file is achieved by using the list organization.
-
File.java
- Extended from OpenFile. In previous phase you are using StubOpenFile, what you need to do is to turn them into a real file class, which supports basic I/O operations on the simulated disk.
-
Folder.java
- A special File which manages the structural organization of files. Therefore it contains each file’s name, location, etc. Since the file size is unlimited, each folder can potentially hold unlimited number of files, whose name length is also unlimited. The Inode of the root folder is stored in a predefined location.
-
FreeList.java
- A special File which manages the free space of the disk. The FreeList is stored as a bit map which indicates the allocation information of disk segments (so the size of the FreeList is constant). The Inode of the FreeList is also stored in a predefined location.
Note, when you see FilesysKernel.format = true
, format the disk and copy all files in the test directory into your ‘/’
Tasks
- (10%) Implement File that supports basic I/O operations
- Use
nachos.machine.SynchDisk
to read/write on the simulated disk
- Use
- (20%) Implement Inode that supports unlimited file size
- allow user to create files as large as the disk size
- allow the
write()
syscall to extend the size of a file
- (20%) Implement hierarchical directory structure
- support access of the files in the directory
- support hierarchical structure
- support unlimited filename length
- be consistent with Unix style (i.e. use / instead of \)
- (20%) Implement disk space allocation
- support reuse of space (i.e. when a portion of the space will not be used any longer, it should be collected by the file system for later use)
- (30%) Implement syscall
- support
mkdir
,rmdir
,chdir
,getcwd
- support
ls
(you may need two extra syscalls:readdir
andstat
) - support
link
,symlink
(notice: when unlink a linked file, the space will freed only when the number of links is zero) - you may refer to
syscall.h
for the definition of the above syscalls
- support
- (10%) Support synchronizations (optional)
- guarantee the consistency of your file system
- support exclusive write and concurrent read
- (10%) Miscellaneous (optionoal)
- support absolute and relative path
- support "." and ".."
- support deletion of the current folder