tac0S
Template Affectional Command Operating System
|
The following class defines the Nachos "file header" (in UNIX terms, the "i-node"), describing where on disk to find all of the data in the file. The file header is organized as a simple table of pointers to data blocks. More...
#include <filehdr.h>
Public Member Functions | |
bool | Allocate (BitMap *bitMap, int fileSize) |
FileHeader::Allocate Initialize a fresh file header for a newly created file. Allocate data blocks for the file out of the map of free disk blocks. More... | |
void | Deallocate (BitMap *bitMap) |
FileHeader::Deallocate De-allocate all the space allocated for data blocks for this file. More... | |
void | FetchFrom (int sectorNumber) |
FileHeader::FetchFrom Fetch contents of file header from disk. More... | |
void | WriteBack (int sectorNumber) |
FileHeader::WriteBack Write the modified contents of the file header back to disk. More... | |
int | ByteToSector (int offset) |
FileHeader::ByteToSector. More... | |
int | FileLength () |
FileHeader::FileLength. More... | |
void | Print () |
FileHeader::Print Print the contents of the file header, and the contents of all the data blocks pointed to by the file header. | |
void | test () |
int | get_sector (int id_sector) |
void | set_sector (int id_sector, int sector) |
Public Attributes | |
File_type | type |
The following class defines the Nachos "file header" (in UNIX terms, the "i-node"), describing where on disk to find all of the data in the file. The file header is organized as a simple table of pointers to data blocks.
The file header data structure can be stored in memory or on disk. When it is on disk, it is stored in a single sector – this means that we assume the size of this data structure to be the same as one disk sector. Without indirect addressing, this limits the maximum file length to just under 4K bytes.
There is no constructor; rather the file header can be initialized by allocating blocks for the file (if it is a new file), or by reading it from disk.
bool FileHeader::Allocate | ( | BitMap * | freeMap, |
int | fileSize | ||
) |
FileHeader::Allocate Initialize a fresh file header for a newly created file. Allocate data blocks for the file out of the map of free disk blocks.
freeMap | is the bit map of free disk sectors |
fileSize | is the bit map of free disk sectors |
int FileHeader::ByteToSector | ( | int | offset | ) |
offset | is the location within the file of the byte in question |
void FileHeader::Deallocate | ( | BitMap * | freeMap | ) |
FileHeader::Deallocate De-allocate all the space allocated for data blocks for this file.
freeMap | is the bit map of free disk sectors |
void FileHeader::FetchFrom | ( | int | sector | ) |
FileHeader::FetchFrom Fetch contents of file header from disk.
sector | is the disk sector containing the file header |
int FileHeader::FileLength | ( | ) |
void FileHeader::WriteBack | ( | int | sector | ) |
FileHeader::WriteBack Write the modified contents of the file header back to disk.
sector | is the disk sector to contain the file header |