|
| FileSystem (bool format) |
| FileSystem::FileSystem Initialize the file system. If format = TRUE, the disk has nothing on it, and we need to initialize the disk to contain an empty directory, and a bitmap of free sectors (with almost but not all of the sectors marked as free). More...
|
|
| ~FileSystem () |
| ~FileSystem() delete all file system
|
|
bool | Create (const char *name, int initialSize, File_type type=f) |
| FileSystem::Create Create a file in the Nachos file system (similar to UNIX create). Since we can't increase the size of files dynamically, we have to give Create the initial size of the file. More...
|
|
bool | MkDir (const char *directory_name, unsigned int tid=0) |
| FileSystem::MkDir Create a new folder in the Nachos file system. More...
|
|
bool | CdDir (const char *directory_name, unsigned int tid=0) |
| FileSystem::CdDir Come in folder given. More...
|
|
bool | RmDir (const char *directory_name, unsigned int tid=0) |
| FileSystem::RmDir Remove the folder given. More...
|
|
path_parse_t * | CdFromPathName (const char *path_name, unsigned int tid=0, int truncate=0) |
| FileSystem::CdFromPathName can jump into the directory with a path. More...
|
|
OpenFile * | OpenFromPathName (const char *path_name, unsigned int tid=0) |
| FileSystem::OpenFromPathName. More...
|
|
bool | MkdirFromPathName (const char *path_name, unsigned int tid=0) |
| FileSystem::MkdirFromPathName. More...
|
|
bool | RmdirFromPathName (const char *path_name, unsigned int tid=0) |
|
OpenFile * | Open (const char *name, unsigned int tid=0) |
| FileSystem::Open Open a file for reading and writing. To open a file: Find the location of the file's header, using the directory Bring the header into memory. More...
|
|
bool | Remove (const char *name, unsigned int tid=0) |
| FileSystem::Remove Delete a file from the file system. This requires: Remove it from the directory Delete the space for its header Delete the space for its data blocks Write changes to directory, bitmap back to disk. More...
|
|
void | List () |
| FileSystem::List List all the files in the file system directory.
|
|
void | Print () |
| FileSystem::Print Print everything about the file system: the contents of the bitmap the contents of the directory for each file in the directory, the contents of the file header the data in the file.
|
|
void | registerOpenFileTable (int *table, unsigned int tid) |
| Allow a thread to use filesystem by register his tid. More...
|
|
bool | unregisterOpenFileTable (unsigned int tid) |
| When thread die need to call this method. More...
|
|
int | UserOpen (const char *name, unsigned int tid) |
| allow a user to open a file More...
|
|
int | UserRead (int fileDescriptor, char *into, int numBytes, unsigned int tid) |
| allow user to read into file More...
|
|
int | UserWrite (int fileDescriptor, char *from, int numBytes, unsigned int tid) |
| Allow user to write into a file. More...
|
|
void | UserSetSeek (int fileDescriptor, int position, unsigned int tid) |
| User method that allow user to move the seek into a file. More...
|
|
int | UserCloseFile (int fileDescriptor, int *threadTableFileDescriptor, unsigned int tid) |
|
bool FileSystem::Create |
( |
const char * |
name, |
|
|
int |
initialSize, |
|
|
File_type |
type = f |
|
) |
| |
FileSystem::Create Create a file in the Nachos file system (similar to UNIX create). Since we can't increase the size of files dynamically, we have to give Create the initial size of the file.
The steps to create a file are: Make sure the file doesn't already exist Allocate a sector for the file header Allocate space on disk for the data blocks for the file Add the name to the directory Store the new file header on disk Flush the changes to the bitmap and the directory back to disk
- Returns
- Return TRUE if everything goes ok, otherwise, return FALSE.
Create fails if: file is already in directory no free space for file header no free entry for file in directory no free space for data blocks for the file
Note that this implementation assumes there is no concurrent access to the file system!
- Parameters
-
name | – name of file to be created |
initialSize | – size of file to be created |