filesys - Roadmap 7: File System In this roadmap we study...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Roadmap 7: File System In this roadmap we study the following issues associated with the file system: # Two types of storage unit: byte (memory, user); sector (disk); # Data structures of file header (i-node), directory; # Implementations of the operations on files; # Synchronization in file system; # Disk management; # Interface between system (software) and disk (hardware device). As before, examine and understand the file system code first. Nachos file operations are similar (but not identical) to those in UNIX. It is a good idea to read the UNIX man pages for creat, open, close, read, write, lseek, and unlink (e.g., type "man creat"). Command line switches support the following file system operations:-cp copies a file from UNIX to nachos-p prints a nachos file to stdout-r removes a nachos file from the file system-l lists the contents of the nachos directory-D prints the contents of the entire file system-t tests the performance of the nachos file system If you want to use the real Nachos file system (based on the simulated disk), rather than the stub, remove-DFILESYS_STUB from DEFINE in build.sun/Makefile (or build.linux/Makefile). Examples ./nachos -f -cp ../test/halt halt Format the disk and copy the program halt into the simulated disk. ./nachos -x halt Run the program halt from the simulated disk. Before tracing the program, we first give an overview of nachos file system. It has the following objects: FileSystem { OpenFile *freeMapFile; OpenFile *directoryFile; }; Directory { int tableSize; DirectoryEntry *table; }; DirectoryEntry { bool inUse; int sector; char name[FileNameMaxLen + 1]; }; OpenFile { FileHeader *hdr; int seekPosition; }; FileHeader { Int numBytes; int numSectors; int dataSectors[NumDirect]; };---------- FileSystem ---------- | | freeMapFile -------------------- directoryFile | | | BitMap OpenFile Directory | | FileHeader DirectoryEntry Question What file system objects exist in memory and/or on disk? How are these objects moved between memory and disk? Now, we examine nachos file system by tracing the program. Start with threads/kernel.cc/Initialize() called by threads/main.cc/main(int argc, char **argv). void Kernel::Initialize() { ... synchDisk = new SynchDisk(); #ifdef FILESYS_STUB fileSystem = new FileSystem(); #else fileSystem = new FileSystem(formatFlag); #endif // FILESYS_STUB ... } If FILESYS_STUB is not defined, not using UNIX file system stub, then a FileSystem is constructed. The parameter formatFlag is set when the command line switch -f is present. First, a new synchDisk is constructed before the fileSystem is created. The file system consists of a root directory and a bitmap, which we have studied in user program. Both the directory and bitmap are treated as files, objects of class OpenFile, which provides operations on files. Then, you can test this simple file system using command line switch....
View Full Document

Page1 / 16

filesys - Roadmap 7: File System In this roadmap we study...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online