Nachos 2013: File system
The fifth phase of Nachos is to implement a file system. In previous phases the file system is implemented in the StubFileSystem
, which simply uses Java File IO methods to support the very fundamental operations of a file system. In this phase you are going to build a real file system of your own with minimum use of the file system of the host operating system. You are going to support some basic operations such as creating and deleting of files, accessing and organizing files hierarchically, as well as some advanced operations like symbolic link and hard link. Unlike all the other previous phases, originality is highly encouraged in this one.
Description
To help you better implementing your code in this phase, a basic framework is provided in nachos.filesys
for you to start with. You can feel free to delete them all and develop your own framework if you prefer. The underlying design and implementation of the file system is open to you, as long as the file system support all the functionality described in the task section below.
The classes provided in this phase are:
nachos.machine.Disk
– a simulation of the hard disk whose operations are asynchronousnachos.machine.SynchDisk
- provide synchronous accesses to the disknachos.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.java
: An INode contains the metadata of a file, such as file size, file position, etc. In the provided framework, the Inodes of a file are organized into a list to support the unlimited size of a file, in which each element occupies one segment.
File.java
: A File is extended from OpenFile (in previous phase you are using StubOpenFile). It is designed to supports basic I/O operations on the simulated disk.
Folder.java
: A Folder is a special File to support the hierarchical structure of the file system. It contains each file’s name, location, etc. Each folder can potentially hold unlimited number of files. The Inode of the root folder is stored in a predefined location.
FreeList.java
: A FreeList is a special File responsible for the disk space allocation. The FreeList is stored as a bit map which indicates the allocation information of the disk segments (the size of the FreeList is constant). The Inode of the FreeList is stored in a predefined location.
Initially your file system is empty with no files. You should import all the files in the stub file system (the test directory) into the root of your own file system when FilesysKernel.format
is set to true
in the configure file.
Tasks
- Implement File that supports basic I/O operations
- Use
nachos.machine.SynchDisk
to read/write on the simulated disk
- Use
- 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
- Implement hierarchical directory structure
- support access of the files in the directory
- support hierarchical structure
- be consistent with Unix style (i.e. use / instead of \)
- 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)
- 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
- Miscellaneous
- support absolute and relative path
- support "." and ".."
- Support synchronizations
- guarantee the consistency of your file system
- support exclusive write and concurrent read