Space: Block 0
typedef struct
{
// Directory info
int dir_index;
int dir_len;
// Data info
int data_index;
} super_block;
Space: Block 1 Function: List of file information.
typedef struct
{
bool used; // whether the file is being used
char name[MAX_FILENAME_LEN]; // file name
int size; // file size
int head; // first data block
int num_blocks; // number of blocks
int fd_count; // number of file descriptors using this file
} file_info;
Space: Block 2-3 Function: Store the file index of each block.
Space: Block 4-8191 Function: Store the data of the file.
- Initialize the super block
- Write the super block to disk
- Read super block
- Read directory info
- Clear file descriptors
- Write directory info
- Clear file descriptors
- Allocate a file descriptor
- Free the allocated file descriptor
- Initialize file information
- Remove file information
- Free file blocks
- Load current block
- Read current block
- Read the following blocks
- Load current block
- Write current block
- Write the allocated blocks
- Write into new blocks
- Get file info from the file descriptor table
- Modify fd of the file descriptor table
- Free blocks
- Modify file information
- Truncate fd offset
char find_file(char* name)
int find_free_file_des(char file_index)
int find_free_block(char file_index)
int find_next_block(int current, char file_index)