This project leads on to a project in key-value storage modeled after Level-DB. We will use the user's interface to the file system, and hook it into our own file system using a system called FUSE. This project introduces,
Unix has mountable file systems. This means that the overall file tree can be comprised of different file systems. The passage from one file system to another is at an object that looks to the user like a directory, but it is a mount point. A mount point node is marked with the root of the filesystem which should begin at that directory.
FUSE allows user programs to be the destination of a mount point. By registering on a directory, FUSE intercepts all file requests on a path passing through that directory and packages up the request as a call into the user program. The user program provides a response by call-by-reference parameters, and the return value.
The hello fuse file system is an example Fuse filesystem. It mounts on a particular mount location, and answers all queries from the program. There is no disk or other memory system involved, other than the memory of the program implementing the hello fuse file system. When asked, it responds with a completely fixed directory contents; and when the hello file is read, it responds with the contents of a string in the memory of the hello-fuse program. When the file is written, it overwrites this string with a new string.
FUSE requires a continuously running program to service the filesystem calls that get routed to the Fuse File System. This is a sort of server, for the service of the filesystem, that the operating system contacts when there is work to do in the FUSE file system.
The calls into the FUSE server are done by a main program providing the kernel with a menu of functions. When there is work to do, the kernel calls the function associated with the sort of work required. There is a call back for read a file, or write a file, as well as to list a directory, remove a file from a directory. Every operation that can be done on a filesystem is represented by a function in the callback table.
In the above box names like fs_read were used. It is the name of a function and in hello-fuse.c that name is hello_read instead.
Since all but write is implemented, the makefile target that tests just for read should work out of the box. This only runs in Linux!, so you will need an AWS image, or run multipass on your local machine.
You will need the developer package to program with FUSE, and there is a makefile target that shows you how to install that package.
The quick test will mount hello-fuse on a mount point and go ahead and test reading, then unmount from the mount point. This is just a quick way to do things.
In general, you will need to have two shells. In one run hello-fuse with the -d option, to linger without exiting hello-fuse, getting the debug output. In the other shell you can send file requests to the hello fuse file system to see if it is working.
ubuntu:~$ sudo apt-get update ubuntu:~$ sudo apt-get install build-essential ubuntu:~$ sudo apt-get install libfuse-dev ubuntu:~$ sudo apt-get install pkg-config ubuntu:~$ git config --global user.name "__githubname__" ubuntu:~$ git config --global user.email "__githubemial__" ubuntu:~$ git config --global credential.helper store ubuntu:~$ git clone https://github.com/csc421-251/__projectrepo__ Username for 'https://github.com': ...your_github_name..... Password for 'https://ojo-r@github.com': .....your_classic_token...... ubuntu:~$ cd __projectrepo__ ubuntu@ip:~/__projectrepo__$ make onesteptest gcc -Wall hello-fuse.c `pkg-config fuse --cflags --libs` -o hello-fuse mkdir mnt ./hello-fuse mnt ls -la mnt total 4 drwxrwxr-x 4 ubuntu ubuntu 4096 Oct 24 02:24 .. -rw-rw-rw- 1 root root 12 Jan 1 1970 hello cat mnt/hello Hello Fuse! fusermount -u mnt ubuntu@ip:~/__projectrepo__$
Your job is to make writing work by writing the necessary code.
author: burton rosenberg
created: 19 oct 2020
update: 23 oct 2024