SimpleFS
A Simple File Sytem implementation including Disk and Shell Layers
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
FileSystem Class Reference

FileSytem Class. Contains fs layer to access and store disk blocks. Used by sfssh (shell) to provide access to the end-user. More...

#include <fs.h>

Collaboration diagram for FileSystem:
Collaboration graph
[legend]

Classes

union  Block
 Block Union Corresponds to one block of disk of size Disk::BLOCKSIZE. Can be used as a SuperBlock, Inode, Pointers block, or raw Data block. More...
 
struct  Directory
 Directory Structure. Contains a table of directory entries for storing hierarchy. Also contains fields for Size and Valid bits. Name is matched against the one in Directory entry. Also, it is allocated from end for effectively using disk space. More...
 
struct  Dirent
 Directory Entry. Contains necessary fields to locate the file and directory Consumes 64 KB per object. Used to store information about a directory. More...
 
struct  Inode
 Inode Structure Corresponds to a file stored on the disk. Contains the list of raw data blocks used to store the data. Stores the size of the file. More...
 
struct  SuperBlock
 SuperBlock structure. It is the first block in any disk. It's main function is to help validating the disk. Contains metadata of the disk. More...
 

Public Member Functions

bool mount (Disk *disk)
 mounts the file system onto the disk More...
 
bool set_password ()
 Adds password to the mounted disk (fs_disk). Gives the control to change_password if disk is pasword protected. More...
 
bool change_password ()
 Changes password in the mounted disk (fs_disk). Checks the current password and gives control to set_password. More...
 
bool remove_password ()
 Removes password from the mounted disk (fs_disk). More...
 
bool touch (char name[])
 Creates a file with size 0. Main function is to allocate an Inode and add Dirent to the curr_dir. Error if file already exists. More...
 
bool mkdir (char name[])
 Creates an empty directory with the given name Adds 2 Dirent , '.' and '..' in it's table. More...
 
bool rmdir (char name[])
 Removes the directory with given name. Also removes all the Dirent in it's table. More...
 
bool cd (char name[])
 Change curr_dir to the given Directory name. More...
 
bool ls ()
 List all the curr_dir Dirent. More...
 
bool rm (char name[])
 Removes the given file/Directory. More...
 
bool copyout (char name[], const char *path)
 Copies the file in curr_dir to the path provided. Prints amount of bytes copied. More...
 
bool copyin (const char *path, char name[])
 Copies the file with path provided to the curr_dir. Prints amount of bytes copied. Creates a newfile if file doesn't exist. Overwrites the file if already exists. More...
 
bool ls_dir (char name[])
 List the Directory given by the name. Called by ls to print curr_dir. Prints a table of Dirent. More...
 
void exit ()
 Unmounts the disk and resets pointer. More...
 
void stat ()
 Returns the stat of the disk. The stat contains information like number of directories, number of files, block number etc. More...
 

Static Public Member Functions

static void debug (Disk *disk)
 prints the basic outline of the disk More...
 
static bool format (Disk *disk)
 formats the entire disk More...
 

Private Member Functions

ssize_t create ()
 creates a new inode More...
 
bool remove (size_t inumber)
 removes the inode More...
 
ssize_t stat (size_t inumber)
 check size of an inode More...
 
ssize_t read (size_t inumber, char *data, int length, size_t offset)
 read from disk More...
 
ssize_t write (size_t inumber, char *data, int length, size_t offset)
 write to the disk More...
 
bool load_inode (size_t inumber, Inode *node)
 loads inode corresponding to inumber into node More...
 
ssize_t allocate_free_block ()
 allocate the first free block from the disk More...
 
void read_helper (uint32_t blocknum, int offset, int *length, char **data, char **ptr)
 reads the block from disk and changes the pointers accordingly More...
 
ssize_t write_ret (size_t inumber, Inode *node, int ret)
 writes the node into the corresponding inode block More...
 
void read_buffer (int offset, int *read, int length, char *data, uint32_t blocknum)
 reads from buffer and writes to a block in the disk More...
 
bool check_allocation (Inode *node, int read, int orig_offset, uint32_t &blocknum, bool write_indirect, Block indirect)
 allocates a block if required; if no block is available in the disk; returns false More...
 
uint32_t allocate_block ()
 allocates the first free block from free block bitmap More...
 
Directory add_dir_entry (Directory dir, uint32_t inum, uint32_t type, char name[])
 Adds directory entry to the cached curr_dir. dir_write_back should be done by the caller. More...
 
void write_dir_back (struct Directory dir)
 Writes the Directory back to the disk. More...
 
int dir_lookup (Directory dir, char name[])
 Finds a valid entry with the same name. More...
 
Directory read_dir_from_offset (uint32_t offset)
 Reads Directory from Dirent offset in curr_dir. More...
 
Directory rmdir_helper (Directory parent, char name[])
 Helper function to remove directory from parent directory. More...
 
Directory rm_helper (Directory parent, char name[])
 Helper function to remove file/directory from parent directory. More...
 

Private Attributes

vector< bool > free_blocks
 
vector< int > inode_counter
 
vector< uint32_t > dir_counter
 
struct SuperBlock MetaData
 
Directory curr_dir
 

Detailed Description

FileSytem Class. Contains fs layer to access and store disk blocks. Used by sfssh (shell) to provide access to the end-user.

Definition at line 131 of file fs.h.


Class Documentation

◆ FileSystem::Block

union FileSystem::Block

Block Union Corresponds to one block of disk of size Disk::BLOCKSIZE. Can be used as a SuperBlock, Inode, Pointers block, or raw Data block.

Definition at line 202 of file fs.h.

Collaboration diagram for FileSystem::Block:
Class Members
char Data[Disk::BLOCK_SIZE]

Contains indexes of Direct Blocks. 0 if null.ck

struct Directory Directories[FileSystem::DIR_PER_BLOCK]

Data block

struct Inode Inodes[FileSystem::INODES_PER_BLOCK]

SuperBlock

uint32_t Pointers[FileSystem::POINTERS_PER_BLOCK]

Inode block

struct SuperBlock Super

◆ FileSystem::Directory

struct FileSystem::Directory

Directory Structure. Contains a table of directory entries for storing hierarchy. Also contains fields for Size and Valid bits. Name is matched against the one in Directory entry. Also, it is allocated from end for effectively using disk space.

Definition at line 177 of file fs.h.

Collaboration diagram for FileSystem::Directory:
Class Members
uint32_t inum

Valid bit for validation

char Name[NAMESIZE]

inum = block_num * DIR_PER_BLOCK + offset

Dirent Table[ENTRIES_PER_DIR]

Directory Name

uint16_t Valid

◆ FileSystem::Dirent

struct FileSystem::Dirent

Directory Entry. Contains necessary fields to locate the file and directory Consumes 64 KB per object. Used to store information about a directory.

Definition at line 163 of file fs.h.

Class Members
uint32_t inum

valid bit to check if the entry is valid

char Name[NAMESIZE]

inum for Inodes or offset for dir

uint8_t type
uint8_t valid

type = 1 for file, type = 0 for directory

◆ FileSystem::Inode

struct FileSystem::Inode

Inode Structure Corresponds to a file stored on the disk. Contains the list of raw data blocks used to store the data. Stores the size of the file.

Definition at line 190 of file fs.h.

Class Members
uint32_t Direct[FileSystem::POINTERS_PER_INODE]

Size of file

uint32_t Indirect

Direct pointers

uint32_t Size

Whether or not inode is valid

uint32_t Valid

◆ FileSystem::SuperBlock

struct FileSystem::SuperBlock

SuperBlock structure. It is the first block in any disk. It's main function is to help validating the disk. Contains metadata of the disk.

Definition at line 148 of file fs.h.

Class Members
uint32_t Blocks

File system magic number

uint32_t DirBlocks

Number of blocks reserved for inodes

uint32_t InodeBlocks

Number of blocks in file system

uint32_t Inodes

Number of blocks reserved for directories

uint32_t MagicNumber
char PasswordHash[257]

Field to check if the disk is password protected

uint32_t Protected

Number of inodes in file system

Member Function Documentation

◆ add_dir_entry()

FileSystem::Directory FileSystem::add_dir_entry ( Directory  dir,
uint32_t  inum,
uint32_t  type,
char  name[] 
)
private

Adds directory entry to the cached curr_dir. dir_write_back should be done by the caller.

Parameters
dirDirectory in which entry is to be added
inuminum of the File/Directory
typetype = 1 for file , type = 0 for Directory
nameName of the file/Directory
Returns
Directory with added entry or with valid bit set to 0 incase of error
Implementation details
  • Find a free Dirent in the Table to be modified
  • If No Dirent Found, Error
  • Free Dirent found, add the new one to the table

Definition at line 125 of file fs_layer_2.cpp.

◆ allocate_block()

uint32_t FileSystem::allocate_block ( )
private

allocates the first free block from free block bitmap

Returns
block number of the block allocated; 0 if no block is available
Implementation details
  • sanity check
  • iterate through the free bit map and allocate the first free block
  • disk is full

Definition at line 566 of file fs_layer_1.cpp.

◆ allocate_free_block()

ssize_t FileSystem::allocate_free_block ( )
private

allocate the first free block from the disk

Returns
returns the blocknum of the disk; if the disk is full, returns 0

◆ cd()

bool FileSystem::cd ( char  name[])

Change curr_dir to the given Directory name.

Parameters
nameDirectory name to be used.
Returns
true if successful
false incase of error
Implementation details
  • Read the dirblock from the disk

Definition at line 441 of file fs_layer_2.cpp.

◆ change_password()

bool FileSystem::change_password ( )

Changes password in the mounted disk (fs_disk). Checks the current password and gives control to set_password.

Returns
true if password changed
false incase of error
Implementation details
  • Sanity Checks
  • Initializations
  • Get curr password
  • Check password
  • Store it in cached MetaData

Definition at line 57 of file fs_layer_2.cpp.

Here is the call graph for this function:

◆ check_allocation()

bool FileSystem::check_allocation ( Inode node,
int  read,
int  orig_offset,
uint32_t &  blocknum,
bool  write_indirect,
Block  indirect 
)
private

allocates a block if required; if no block is available in the disk; returns false

Parameters
nodeused to set the size of inode in case allocation fails
readbytes read from buffer so far
orig_offsetoffset passed to write() function call
blocknumindex of block in the free block bitmap
write_indirecttrue if the block is an indirect node
indirectthe indirect node if required
Returns
true if allocation is successful; false otherwise
Implementation details
  • sanity check
  • if blocknum is 0, then allocate a new block
  • set size of node and write back to disk if it is an indirect node

Definition at line 635 of file fs_layer_1.cpp.

◆ copyin()

bool FileSystem::copyin ( const char *  path,
char  name[] 
)

Copies the file with path provided to the curr_dir. Prints amount of bytes copied. Creates a newfile if file doesn't exist. Overwrites the file if already exists.

Parameters
nameName of the file to be copied in
pathPath to store the file outside.
Returns
true if successful
false incase of error.
Implementation details
  • Sanity Checks
  • Check if file exists. Else create one
  • Get inode of the created file
  • Open File for reading
  • Read File and get the Data
  • Save the file
  • Checks to ensure proper write
  • Endings

Definition at line 526 of file fs_layer_2.cpp.

◆ copyout()

bool FileSystem::copyout ( char  name[],
const char *  path 
)

Copies the file in curr_dir to the path provided. Prints amount of bytes copied.

Parameters
nameName of the file to be copied out
pathPath to store the file outside.
Returns
true if successful
false incase of error.
Implementation details
  • Sanity Checks
  • Get table offset for the filename
  • Open File for copyout
  • Read from the inode and write it to the File
  • Endings

Definition at line 485 of file fs_layer_2.cpp.

◆ create()

ssize_t FileSystem::create ( )
private

creates a new inode

Returns
the inumber of the newly created inode
Implementation details
  • sanity check
  • read the superblock
  • locate free inode in inode table
  • check if inode block is full
  • find the first empty inode
  • set the inode to default values

Definition at line 291 of file fs_layer_1.cpp.

◆ debug()

void FileSystem::debug ( Disk disk)
static

prints the basic outline of the disk

Parameters
diskthe disk to be debugged
Returns
void function; returns nothing
Implementation details
  • read superblock
  • verifying the integrity of the file system
  • printing the superblock
  • reading the inode blocks
  • array of inodes
  • iterating through INODES_PER_BLOCK inodes

iterating through the direct nodes

  • iterate through the indirect nodes

Definition at line 25 of file fs_layer_1.cpp.

Here is the call graph for this function:

◆ dir_lookup()

int FileSystem::dir_lookup ( Directory  dir,
char  name[] 
)
private

Finds a valid entry with the same name.

Parameters
dirLookup directory
nameFile/Directory Name
Returns
offset into the curr_dir table. -1 incase of error
Implementation details
  • Search the curr_dir.Table for name
  • No such dir found

Definition at line 196 of file fs_layer_2.cpp.

◆ exit()

void FileSystem::exit ( )

Unmounts the disk and resets pointer.

Definition at line 477 of file fs_layer_2.cpp.

◆ format()

bool FileSystem::format ( Disk disk)
static

formats the entire disk

Parameters
diskthe disk to be formatted
Returns
true if the formatting was successful; false otherwise
Implementation details
  • write superblock
  • Reinitialising password protection
  • clear all other blocks
  • clear individual Inodes
  • clear all direct Pointers
  • clear indirect Pointer
  • Free Data Blocks
  • Free Directory Blocks
  • Create Root directory
  • Create table entries for "." and ".."
  • Empty the directories

Definition at line 88 of file fs_layer_1.cpp.

Here is the call graph for this function:

◆ load_inode()

bool FileSystem::load_inode ( size_t  inumber,
Inode node 
)
private

loads inode corresponding to inumber into node

Parameters
inumberindex into inode table
nodepointer to inode
Returns
boolean value indicative of success of the load operation
Implementation details
  • sanity check
  • find index of inode in the inode table
  • load the inode into Inode *node

Definition at line 333 of file fs_layer_1.cpp.

◆ ls()

bool FileSystem::ls ( )

List all the curr_dir Dirent.

Returns
true if successful
false incase of error

Definition at line 461 of file fs_layer_2.cpp.

◆ ls_dir()

bool FileSystem::ls_dir ( char  name[])

List the Directory given by the name. Called by ls to print curr_dir. Prints a table of Dirent.

Parameters
nameName of the directory to be listed
Returns
true if successful
false incase of error.
Implementation details
  • Get the directory entry offset
  • Read directory from block
  • Sanity checks
  • Print Directory Data

Definition at line 216 of file fs_layer_2.cpp.

◆ mkdir()

bool FileSystem::mkdir ( char  name[])

Creates an empty directory with the given name Adds 2 Dirent , '.' and '..' in it's table.

Parameters
nameName of the directory to be added.
Returns
true if successful
false incase of errors
Implementation details
  • Find empty dirblock
  • Read empty dirblock
  • Find empty directory in dirblock
  • Create new directory
  • Create 2 new entries for "." and ".."
  • Add new entry to the curr_dir
  • Write the new directory back to the disk
  • Write the curr_dir back to the disk
  • Increment the counter

Definition at line 245 of file fs_layer_2.cpp.

◆ mount()

bool FileSystem::mount ( Disk disk)

mounts the file system onto the disk

Parameters
diskthe disk to be mounted
Returns
true if the mount operation was successful; false otherwise
Implementation details
  • sanity check
  • read superblock
  • Handle Password Protection
  • copy metadata
  • allocate free block bitmap
  • allocate inode counter
  • setting free bit map node 0 to true for superblock
  • read inode blocks
  • set free bit map for inode blocks
  • set free bit map for direct pointers
  • set free bit map for indirect pointers
  • Allocate dir_counter

Definition at line 178 of file fs_layer_1.cpp.

Here is the call graph for this function:

◆ read()

ssize_t FileSystem::read ( size_t  inumber,
char *  data,
int  length,
size_t  offset 
)
private

read from disk

Parameters
inumberindex into the inode table of the corresponding inode
datadata buffer
lengthbytes to be read from disk
offsetstart point of the read operation
Returns
bytes read from disk; -1 in case of an error
Implementation details
  • sanity check
  • IMPORTANT: start reading from index = offset
  • if offset is greater than size of inode, then no data can be read if length + offset exceeds the size of inode, adjust length accordingly
  • data is head; ptr is tail
  • load inode; if invalid, return error
  • the offset is within direct pointers
  • calculate the node to start reading from
  • check if the direct node is valid
  • read the direct blocks
  • if length <= 0, then enough data has been read
  • more data is to be read
  • check if all the direct nodes have been read completely and if the indirect pointer is valid
  • read the indirect nodes
  • if length <= 0, then enough data has been read
  • data exhausted but the length requested was more
  • logically, this should never print
  • data exhausted but the length requested was more
  • logically, this should never print
  • inode has no stored data
  • offset begins in the indirect block
  • check if the indirect node is valid
  • change offset accordingly and find the indirect node to start reading from
  • iterate through the indirect nodes
  • if length <= 0, then enough data has been read
  • data exhausted but the length requested was more
  • logically, this should never print
  • the indirect node is invalid
  • inode is invalid

Definition at line 443 of file fs_layer_1.cpp.

◆ read_buffer()

void FileSystem::read_buffer ( int  offset,
int *  read,
int  length,
char *  data,
uint32_t  blocknum 
)
private

reads from buffer and writes to a block in the disk

Parameters
offsetstarts writing at index = offset
readbytes read from buffer so far
lengthbytes to be written to the disk
datadata buffer
blocknumindex of block in free block bitmap
Returns
void function; returns nothing
Implementation details
  • sanity check
  • allocate memory to ptr which acts as buffer for reading from disk
  • read data into ptr and change pointers accordingly
  • free the allocated memory

Definition at line 610 of file fs_layer_1.cpp.

◆ read_dir_from_offset()

FileSystem::Directory FileSystem::read_dir_from_offset ( uint32_t  offset)
private

Reads Directory from Dirent offset in curr_dir.

Parameters
offsetoffset of curr_dir.Table which needs to be read.
Returns
Directory. Returns Directory with valid bit=0 incase of error.
Implementation details
  • Sanity Check
  • Get offsets and indexes
  • Read Block

Definition at line 154 of file fs_layer_2.cpp.

◆ read_helper()

void FileSystem::read_helper ( uint32_t  blocknum,
int  offset,
int *  length,
char **  data,
char **  ptr 
)
private

reads the block from disk and changes the pointers accordingly

Parameters
blocknumindex into the free block bitmap
offsetstart reading from index = offset
lengthnumber of bytes to be read
datadata buffer
ptrbuffer to store the read data
Returns
void function; returns nothing
Implementation details
  • read the block from disk and change the pointers accordingly

Definition at line 428 of file fs_layer_1.cpp.

◆ remove()

bool FileSystem::remove ( size_t  inumber)
private

removes the inode

Parameters
inumberindex into the inode table of the inode to be removed
Returns
true if the remove operation was successful; false otherwise
Implementation details
  • sanity check
  • check if the node is valid; if yes, then load the inode
  • decrement the corresponding inode block in inode counter if the inode counter decreases to 0, then set the free bit map to false
  • free direct blocks
  • free indirect blocks

Definition at line 361 of file fs_layer_1.cpp.

◆ remove_password()

bool FileSystem::remove_password ( )

Removes password from the mounted disk (fs_disk).

Returns
true if password removed
false incase of error
Implementation details
  • Initializations
  • Get current password
  • Curr password incorrect. Error
  • Update cached MetaData
  • Write back the changes

Definition at line 87 of file fs_layer_2.cpp.

◆ rm()

bool FileSystem::rm ( char  name[])

Removes the given file/Directory.

Parameters
nameEntry to be removed
Returns
true if successful
false incase of error

Definition at line 468 of file fs_layer_2.cpp.

◆ rm_helper()

FileSystem::Directory FileSystem::rm_helper ( Directory  parent,
char  name[] 
)
private

Helper function to remove file/directory from parent directory.

Parameters
parentParent Directory which contains name
nameFile/Directory to be removed
Returns
Directory. Returns Directory with valid bit=0 incase of error.
Implementation details
  • Get the offset for removal
  • Check if directory
  • Get inumber
  • Remove the inode
  • Remove the entry
  • Write back the changes

Definition at line 364 of file fs_layer_2.cpp.

◆ rmdir()

bool FileSystem::rmdir ( char  name[])

Removes the directory with given name. Also removes all the Dirent in it's table.

Parameters
nameName of the Directory to be deleted
Returns
true if successful
false incase of errors.
Implementation details

Definition at line 397 of file fs_layer_2.cpp.

◆ rmdir_helper()

FileSystem::Directory FileSystem::rmdir_helper ( Directory  parent,
char  name[] 
)
private

Helper function to remove directory from parent directory.

Parameters
parentDirectory from which the other directory is to be removed.
nameName of the directory to be removed
Returns
Directory. Returns Directory with valid bit=0 incase of error.
Implementation details
  • initializations
  • Sanity Checks
  • Get offset of the directory to be removed
  • Get block
  • Check Directory
  • Check if it is root directory
  • Remove all Dirent in the directory to be removed
  • Read the block again, because the block may have changed by Dirent
  • Write it back
  • Remove it from the parent
  • Update the counter

Definition at line 306 of file fs_layer_2.cpp.

◆ set_password()

bool FileSystem::set_password ( )

Adds password to the mounted disk (fs_disk). Gives the control to change_password if disk is pasword protected.

Returns
true if New password is set
false incase of error
Implementation details
  • Sanity checks
  • Initializations
  • Get new password
  • Set cached MetaData to Protected

Definition at line 27 of file fs_layer_2.cpp.

Here is the caller graph for this function:

◆ stat() [1/2]

void FileSystem::stat ( )

Returns the stat of the disk. The stat contains information like number of directories, number of files, block number etc.

Returns
true if successful
false incase of error
Implementation details
  • Sanity checks
  • Read Super Block and print MetaData
  • Read directory blocks
  • Read Directoreis in each directory block
  • Read Table Entries for each directory

Definition at line 583 of file fs_layer_2.cpp.

◆ stat() [2/2]

ssize_t FileSystem::stat ( size_t  inumber)
private

check size of an inode

Parameters
inumberindex into the inode table of inode whose size is to be determined
Returns
size of the inode; -1 if the inode is invalid
Implementation details
  • sanity check
  • load inode; if valid, return its size

Definition at line 412 of file fs_layer_1.cpp.

◆ touch()

bool FileSystem::touch ( char  name[])

Creates a file with size 0. Main function is to allocate an Inode and add Dirent to the curr_dir. Error if file already exists.

Parameters
nameName of the file to be added
Returns
true if successful
false incase of error
Implementation details
  • Check if such file exists
  • Allocate new inode for the file
  • Add the directory entry in the curr_directory
  • Write back the changes

Definition at line 410 of file fs_layer_2.cpp.

◆ write()

ssize_t FileSystem::write ( size_t  inumber,
char *  data,
int  length,
size_t  offset 
)
private

write to the disk

Parameters
inumberindex into the inode table of the corresponding inode
datadata buffer
lengthbytes to be written to disk
offsetstart point of the write operation
Returns
bytes written to disk; -1 in case of an error
Implementation details
  • sanity check
  • insufficient size
  • if the inode is invalid, allocate inode. need not write to disk right now; will be taken care of in write_ret()
  • set size of the node
  • check if the offset is within direct pointers
  • find the first node to start writing at and change offset accordingly
  • check if the node is valid; if invalid; allocates a block and if no block is available, returns false
  • read from data buffer
  • enough data has been read from data buffer
  • store in direct pointers till either one of the two things happen:
  1. all the data is stored in the direct pointers
  2. the data is stored in indirect pointers
  • start writing into direct nodes
  • check if the node is valid; if invalid; allocates a block and if no block is available, returns false
  • enough data has been read from data buffer
  • check if the indirect node is valid
  • check if the node is valid; if invalid; allocates a block and if no block is available, returns false
  • initialise the indirect nodes
  • write into indirect nodes
  • check if the node is valid; if invalid; allocates a block and if no block is available, returns false
  • enough data has been read from data buffer
  • space exhausted
  • offset begins in indirect blocks
  • find the first indirect node to write into and change offset accordingly
  • check if the indirect node is valid
  • check if the node is valid; if invalid; allocates a block and if no block is available, returns false
  • initialise the indirect nodes
  • check if the node is valid; if invalid; allocates a block and if no block is available, returns false
  • enough data has been read from data buffer
  • write into indirect nodes
  • check if the node is valid; if invalid; allocates a block and if no block is available, returns false
  • enough data has been read from data buffer
  • space exhausted
  • error

Definition at line 658 of file fs_layer_1.cpp.

◆ write_dir_back()

void FileSystem::write_dir_back ( struct Directory  dir)
private

Writes the Directory back to the disk.

Parameters
dirValid Directory to be written back
Implementation details
  • Get block offset and index
  • Read Block
  • Write the Dirblock

Definition at line 178 of file fs_layer_2.cpp.

◆ write_ret()

ssize_t FileSystem::write_ret ( size_t  inumber,
Inode node,
int  ret 
)
private

writes the node into the corresponding inode block

Parameters
inumberindex into inode table
nodethe inode to be written back to disk
retthe value that is returned by the function
Returns
returns the parameter ret
Implementation details
  • sanity check
  • find index of inode in the inode table
  • store the node into the block
  • return ret

Definition at line 587 of file fs_layer_1.cpp.

Member Data Documentation

◆ curr_dir

Directory FileSystem::curr_dir
private

Caches curr dir to save a disk-read

Definition at line 325 of file fs.h.

◆ dir_counter

vector<uint32_t> FileSystem::dir_counter
private

Stores the number of Inode contained in an Inode Block

Definition at line 214 of file fs.h.

◆ free_blocks

vector<bool> FileSystem::free_blocks
private

Stores disk pointer after successful mounting

Definition at line 212 of file fs.h.

◆ inode_counter

vector<int> FileSystem::inode_counter
private

Stores whether a block is free or not

Definition at line 213 of file fs.h.

◆ MetaData

struct SuperBlock FileSystem::MetaData
private

Stores the number of Directory contianed in a Directory Block

Definition at line 215 of file fs.h.


The documentation for this class was generated from the following files: