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

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

View Full Document Right Arrow Icon
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?
Image of page 1

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

View Full Document Right Arrow Icon
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. machine/disk.*, filesys/synchdisk.* class SynchDisk : public CallBackObj { public: SynchDisk(); // Initialize a synchronous disk, // by initializing the raw Disk.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern