SimpleFS
A Simple File Sytem implementation including Disk and Shell Layers
Classes
fs.h File Reference

Interface for the FileSystem layer. More...

#include "sfs/disk.h"
#include <cstring>
#include <vector>
#include <stdint.h>
Include dependency graph for fs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  FileSystem
 FileSytem Class. Contains fs layer to access and store disk blocks. Used by sfssh (shell) to provide access to the end-user. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Detailed Description

Interface for the FileSystem layer.

Author
Rudra Desai (rudra.nosp@m.d200.nosp@m.@gmai.nosp@m.l.co.nosp@m.m) & Kairav Shah (shahk.nosp@m.aira.nosp@m.v1702.nosp@m.@gma.nosp@m.il.co.nosp@m.m)
Date
2020-12-09

Definition in file fs.h.


Class Documentation

◆ 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

◆ 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::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::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::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