Next: Putting
It All Together Up: File
System Physical Representation Previous: File
Header
Directories
Nachos supports a single top-level directory, managed by the Directory
object. When a file is created, it is added to the directory; likewise,
deleting a file results in its removal from the directory. Directory entries
themselves consist of (filename, fnode, free_flag) triplets, with the free_flag
indicating whether that directory slot is currently allocated. The following
directory operations are supported:
-
Directory(int size):
-
This constructor creates an (in-memory) directory object capable of holding
size entries.
-
void FetchFrom(OpenFile *file):
-
Fetch the directory contents stored in file file.
-
void WriteBack(OpenFile *file):
-
Flush the contents of the directory to the file file.
-
int Find(char *name):
-
Search the directory for a file called
name, returning its fnode
number if the file exists.
-
bool Add(char *name, int newSector):
-
Add the file name with fnode newSector to the directory.
Note that this routine only updates the in-memory copy of the directory.
To make the directory changes permanent, WriteBack must subsequently
be invoked.
-
bool Remove(char *name):
-
Remove file name from the directory. Note that the Remove
operator simply updates the directory; the FileHeader and data sectors
associated with
name are deallocated separately. In addition, a
subsequent call to WriteBack is needed to make the changes permanent.
-
List()
-
Print out the directory contents (debugging).
-
Print()
-
Print out contents of all files in the directory (debugging).
|
Nachos
Tutorials
Roadmap
Source Code
Introduction
Threads
Interrupts
Synchronization
System Calls
Exception Handling
Multiprogramming
File System
Networking
Tutorials
Lab 1 Tutorial
Lab 2 Tutorial
Lab 3 Tutorial
Lab 4 Tutorial
Lab 5 Tutorial
|