This is an implementation for a unix-like file system that exists in the user space of a Linux operating system and uses FUSE to link the filesystem with the kernel.
The file system supports 512 files with 8 megabytes of total storage. The file system does not support subdirectories or concurrent access. All files are stored in the root directory.
- ensure that the line containing fuse_wrappers.c is uncommented in the makefile
- run make
- run: ./braedon_mcdonald_sfs <dir> to mount the file system
- create and manipulate files within the mounted directory
- to unmount run: fusermount -u <dir>
The following sections provide pseudo code for the major operations of the file system
- Initialize the disk by calling init_fresh_disk(), giving it a block size of 1024 bytes and a total of 8,388,674 blocks (8 megabytes)
- Initialize the fields of the super block struct with the values described in question 1 and write it to the first block of the disk
- Initialize the fields of the struct representing the inode of the root directory and write it to the first entry of the inode table
- search the cached inode table for the next available inode number by starting at the beginning of table and find the first entry whose "valid" is set to false
- add the filename to inode mapping to the end of the cached root directory dynamic array
- write the filename to inode mapping to the end of the on-disk disk root directory. Use the free space bitmap if another block is needed to store the mapping
- initialize an inode structure for the file and write it to the appropriate entry in the cached and on disk inode tables
- Get the open file descriptor from the open file descriptor table
- Get the disk block pointed to by the descriptors write pointer. Allocate a a new block to the inode if necessary
- while there is data to write: update the current in-memory block with data from the buffer. When the block is full, write it to disk and allocate/retrieve the next block
- update the size of the file
- deallocate the data by marking all the blocks pointed to in the file's inode as free in the free space bitmap
- remove the inode to filename mapping in the cached root directory table and shift the contents so that there are no gaps in the table
- update the on-disk root directory
- if the previous step results in one less block needed to store the on-disk root directory, mark this block as free in the free space bitmap and remove its pointer in the root directory's inode
- mark the inode as invalid in the cached and on disk inode tables