This is a course project of CUHK CSCI5550 (Spring 2020).
ToyFS manages the basic structures of a Unix File System (superblock, inode-bitmap, datablock-bitmap, inodes and datablocks) in block devices (e.g., a USB drive). ToyFS uses Linux direct I/O to bypass the page cache in Linux kernel, and maintains a block cache in user space.
ToyFS is based on FUSE. Install dependencies by $ apt install fuse libfuse-dev
- superblock.size_ibmap = 196608; // 4 pages = 384 blocks = 196608 bytes = 1572864 bits
- superblock.size_dbmap = 196608; // 4 pages = 384 blocks = 196608 bytes = 1572864 bits
- superblock.size_inode = 32; // 32 bytes
- superblock.size_filename = 12; // size of filename
- superblock.root_inum = 0; // root directory inode number
- superblock.num_disk_ptrs_per_inode = 4; // number of data block pointers per inode
- Hard code block device file path to my_io.h, e.g.,
const char* device_path = "/dev/sdb1"; - Plug in block device and change the mode of block device file to 777, e.g.,
$ sudo chmod 777 /dev/sdb1 $ cd /path/to/toyfs$ make- Create a directory for mounting toyfs, e.g.:
$ mkdir mnt - Mount toyfs on the mounting point, e.g.:
$ ./toyfs -f mnt - Create another shell and cd to toyfs mounting point, e.g.:
$ cd /path/to/toyfs/mnt
Currently ToyFS works well with cd, cp, cp -r, ls, mkdir, touch, echo "string" >> file, cat, rmdir, rm, hard link ln, soft link ln -s