nachos.kernel.filesys
Class FileSystem

java.lang.Object
  extended by nachos.kernel.filesys.FileSystem
Direct Known Subclasses:
FileSystemReal, FileSystemStub

public abstract class FileSystem
extends java.lang.Object

This abstract class defines the interface to a Nachos file system. A file system is a set of files stored on disk, organized into directories. Operations on the file system have to do with "naming" -- creating, opening, and deleting files, given a textual file name. Operations on an individual "open file" (read, write, close) are to be found in the OpenFile class (Openfile.java). We define two separate implementations of the file system: a "real" file system, built on top of a disk simulator, and a "stub" file system, which just re-defines the Nachos file system operations as operations on the native file system on the machine running the Nachos simulation.


Constructor Summary
protected FileSystem()
          Protected constructor to force creation of a filesystem using the init() factory method.
 
Method Summary
abstract  boolean create(java.lang.String name, long initialSize)
          Create a new file with a specified name and size.
static FileSystem init(java.lang.String[] args, boolean stub)
          Factory method to create the proper type of filesystem and hide the type actually being used.
 void list()
          List contents of the filesystem directory (for debugging).
abstract  OpenFile open(java.lang.String name)
          Open the file with the specified name and return an OpenFile object that provides access to the file contents.
 void print()
          Print contents of the entire filesystem (for debugging).
abstract  boolean remove(java.lang.String name)
          Remove the file with the specified name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSystem

protected FileSystem()
Protected constructor to force creation of a filesystem using the init() factory method.

Method Detail

create

public abstract boolean create(java.lang.String name,
                               long initialSize)
Create a new file with a specified name and size.

Parameters:
name - The name of the file.
initialSize - The size of the file.
Returns:
true if the operation was successful, otherwise false.

open

public abstract OpenFile open(java.lang.String name)
Open the file with the specified name and return an OpenFile object that provides access to the file contents.

Parameters:
name - The name of the file.
Returns:
An OpenFile object that provides access to the file contents, if the file was successfully opened, otherwise null.

remove

public abstract boolean remove(java.lang.String name)
Remove the file with the specified name.

Parameters:
name - The name of the file.
Returns:
true if the operation was successful, otherwise false.

init

public static FileSystem init(java.lang.String[] args,
                              boolean stub)
Factory method to create the proper type of filesystem and hide the type actually being used.

Parameters:
args - Command-line arguments, used to determine whether the filesystem should be "formatted" after being initialized.
stub - True if we should be using the stub filesystem, rather than the real filesystem.

list

public void list()
List contents of the filesystem directory (for debugging). This is only implemented by the real filesystem.


print

public void print()
Print contents of the entire filesystem (for debugging). This is only implemented by the real filesystem.