tac0S
Template Affectional Command Operating System
|
Routines to manage the overall operation of the file system. More...
#include "copyright.h"
#include "disk.h"
#include "bitmap.h"
#include "directory.h"
#include "filehdr.h"
#include "filesys.h"
#include "stdlib.h"
Macros | |
#define | FreeMapSector 0 |
Sectors containing the file headers for the bitmap of free sectors, and the directory of files. These file headers are placed in well-known sectors, so that they can be located on boot-up. | |
#define | DirectorySector 1 |
#define | FreeMapFileSize (NumSectors / BitsInByte) |
Initial file sizes for the bitmap and directory; until the file system supports extensible files, the directory size sets the maximum number of files that can be loaded onto the disk. | |
#define | NumDirEntries 30 |
#define | DirectoryFileSize (sizeof(DirectoryEntry) * NumDirEntries) |
Routines to manage the overall operation of the file system.
Each file in the file system has: A file header, stored in a sector on disk (the size of the file header data structure is arranged to be precisely the size of 1 disk sector) A number of data blocks An entry in the file system directory
The file system consists of several data structures: A bitmap of free disk sectors (cf. bitmap.h) A directory of file names and file headers
Both the bitmap and the directory are represented as normal files. Their file headers are located in specific sectors (sector 0 and sector 1), so that the file system can find them on bootup.
The file system assumes that the bitmap and directory files are kept "open" continuously while Nachos is running.
For those operations (such as Create, Remove) that modify the directory and/or bitmap, if the operation succeeds, the changes are written immediately back to disk (the two files are kept open during all this time). If the operation fails, and we have modified part of the directory and/or bitmap, we simply discard the changed version, without writing it back to disk.
Our implementation at this point has the following restrictions:
there is no synchronization for concurrent accesses files have a fixed size, set when the file is created files cannot be bigger than about 3KB in size there is no hierarchical directory structure, and only a limited number of files can be added to the system there is no attempt to make the system robust to failures (if Nachos exits in the middle of an operation that modifies the file system, it may corrupt the disk)
Copyright (c) 1992-1993 The Regents of the University of California. All rights reserved. See copyright.h for copyright notice and limitation of liability and disclaimer of warranty provisions.