A FUSE userspace single-level file system in a file based on the first-fit linked list memory allocator presented in the book The C Programming Language by Brian Kernighan and Dennis Ritchie.
- FUSE libraries, headers, and utilities
- GCC or Clang compilers with pkg-config and GNU Make installed
- dd to generate empty file system files
Use a package manager of your OS distribution and install FUSE libraries, development files, and utilities.
Download and install the FUSE for macOS package.
Download and install the latest version of Dokany, a user mode file system library for Windows with a FUSE wrapper.
Support for Windows is lackluster. You need to generate a VS project on your own.
To compile the FUSE KRFFS program and all supporting utilities (to create, check, and defragment the file system), use the following
make
To remove compiled files
make clean
-
Create an empty 10-megabyte file
file_system.krffs
and initialize a new KRFFS file system on it with the compiledmkfs.krffs
utility.dd if=/dev/zero of=file_system.krffs bs=1048576 count=1 mkfs.krffs file_system.krffs
You can do the same by calling a helper script
./create_krffs_file_system.sh
-
Mount the file system from the
file_system.krffs
file into an empty directorymount_point
.krffs file_system.krffs mount_point
One useful option is to tell the program to print debug information for each file system operation with the
-d
flag.krffs file_system.krffs mount_point -d
You can also check the list of all FUSE options by passing just the
-h
flag.krffs -h
-
Go inside the directory
mount_point
, experiment with the file system by creating files and writing or reading data from them. Attempt to rename or remove files. Try to use unsupported operations by attempting to create a new directory.Sample commands
cd mount_point touch hello.txt echo "hello, world" > hello.txt cat hello.txt echo "#include <stdio.h>" > test.c echo "bye" > hello.txt rm hello.txt mv test.c hello.c cp hello.c hello_backup.c mkdir sample_directory nano hello_backup.c ...
-
Leave the
mount_point
directory and unmount it.cd .. sudo umount mount_point
On some systems, a
fusermount
command can be used to unmount FUSE mount points without administrative privileges.fusermount -u mount_point
Use the provided template fsck.krffs.c
and finish writing the file system
check utility. The application should go through the file system structure and
report about any data inconsistencies.
Use the provided template defrag.krffs.c
and finish writing the file
defragmentation utility that rearranges file nodes with their data to the
beginning of the disk file one by one. You can also sort the entries by their
file size or usage attributes.
In both cases, you need to research the allocation and deallocation algorithm utilized by the file system. The structure and the algorithms can be found throughout the sources of the project.
man fuse
man mount
man umount
man fusermount
man pkg-config