39 #include "copyright.h" 43 #define MAX_OPEN_FILE 50 44 #define ROOT_DIRECTORY_FILE 0 45 #define CURRENT_DIRECTORY_FILE 1 47 #ifdef FILESYS_STUB // Temporarily implement file system calls as 56 bool Create(
const char *name,
int initialSize) {
59 if (fileDescriptor == -1)
return FALSE;
60 Close(fileDescriptor);
64 OpenFileTable*
Open(
char *name) {
67 if (fileDescriptor == -1)
return NULL;
68 return new OpenFileTable(fileDescriptor);
106 bool MkDir(
const char *directory_name,
unsigned int tid = 0);
108 bool CdDir(
const char *directory_name,
unsigned int tid = 0);
110 bool RmDir(
const char *directory_name,
unsigned int tid = 0);
122 bool Remove(
const char *name,
unsigned int tid = 0);
133 int UserOpen(
const char *name,
unsigned int tid);
135 int UserRead(
int fileDescriptor,
char *into,
int numBytes,
unsigned int tid);
137 int UserWrite(
int fileDescriptor,
char *from,
int numBytes,
unsigned int tid);
139 void UserSetSeek(
int fileDescriptor,
int position,
unsigned int tid);
141 int UserCloseFile(
int fileDescriptor,
int* threadTableFileDescriptor,
unsigned int tid);
147 OpenFile *get_open_file_by_sector(
int sector);
149 int close_file(
OpenFile* openFile,
OpenFile** threadFileTable,
unsigned int tid);
151 int removeFiletoGlobalTable(
OpenFile* openFile);
153 OpenFile** get_thread_file_table(
unsigned int tid);
155 file_table_t* get_thread_file_table_t(
unsigned int tid);
157 void addFiletoGlobalTable(
OpenFile *openFile);
159 void init_ThreadsFilesTable();
161 int getFileDescriptor(
OpenFile* openFile,
unsigned int tid);
163 void initFileDesciptortable(
int* table);
165 void initOpenFileTable(
OpenFile** table);
OpenFile * OpenFromPathName(const char *path_name, unsigned int tid=0)
FileSystem::OpenFromPathName.
Definition: filesys.cc:346
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.
Definition: filesys.cc:296
bool MkdirFromPathName(const char *path_name, unsigned int tid=0)
FileSystem::MkdirFromPathName.
Definition: filesys.cc:396
int UserRead(int fileDescriptor, char *into, int numBytes, unsigned int tid)
allow user to read into file
Definition: filesys.cc:721
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.
Definition: filesys.cc:206
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 De...
Definition: filesys.cc:853
int OpenForReadWrite(const char *name, bool crashOnError)
OpenForReadWrite Open a file for reading or writing.
Definition: sysdep.cc:168
Data structures for opening, closing, reading and writing.
int OpenForWrite(const char *name)
OpenForWrite Open a file for writing. Create it if it doesn't exist; truncate it if it does already e...
Definition: sysdep.cc:151
void UserSetSeek(int fileDescriptor, int position, unsigned int tid)
User method that allow user to move the seek into a file.
Definition: filesys.cc:739
bool RmDir(const char *directory_name, unsigned int tid=0)
FileSystem::RmDir Remove the folder given.
Definition: filesys.cc:560
File_type
enum that define if the FileHeader define a file or a directory
Definition: filehdr.h:25
void Close(int fd)
Close Close a file. Abort on error.
Definition: sysdep.cc:247
bool MkDir(const char *directory_name, unsigned int tid=0)
FileSystem::MkDir Create a new folder in the Nachos file system.
Definition: filesys.cc:502
Definition: openfile.h:77
bool CdDir(const char *directory_name, unsigned int tid=0)
FileSystem::CdDir Come in folder given.
Definition: filesys.cc:477
void Print()
FileSystem::Print Print everything about the file system: the contents of the bitmap the contents of ...
Definition: filesys.cc:904
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...
Definition: filesys.cc:768
int UserWrite(int fileDescriptor, char *from, int numBytes, unsigned int tid)
Allow user to write into a file.
Definition: filesys.cc:731
bool unregisterOpenFileTable(unsigned int tid)
When thread die need to call this method.
Definition: filesys.cc:964
void registerOpenFileTable(int *table, unsigned int tid)
Allow a thread to use filesystem by register his tid.
Definition: filesys.cc:945
FileSystem(bool format)
FileSystem::FileSystem Initialize the file system. If format = TRUE, the disk has nothing on it...
Definition: filesys.cc:82
bool RmdirFromPathName(const char *path_name, unsigned int tid=0)
Definition: filesys.cc:435
int UserOpen(const char *name, unsigned int tid)
allow a user to open a file
Definition: filesys.cc:711
void List()
FileSystem::List List all the files in the file system directory.
Definition: filesys.cc:888
~FileSystem()
~FileSystem() delete all file system
Definition: filesys.cc:986
Data structures for managing a disk file header.
bool Unlink(const char *name)
Unlink Delete a file.
Definition: sysdep.cc:259