This page of the tutorial explains how to build the BBFS filesystem program and use it to mount a directory.
This tutorial uses the GNU autotools system for configuration. As is the case with all autotools-based projects, you can configure and compile it by going to the top-level directory and typing
and the code should be compiled and ready to go../configure make
Unlike most software, the code from this tutorial is not intended to be installed. Consequently, I've tried to disable all the various installation targets; if I've missed one please let me know.
You mount a BBFS filesystem by running the command bbfs
(in general, a FUSE filesystem is implemented by a program, and you
mount it by running that program).
bbfs
has two required arguments: the root directory (which
contains the actual directory data) and the mount directory. The
tutorial tarball includes an example
directory, which
contains two subdirectories named rootdir
and
mountdir
. You can verify that rootdir
contains a single file named bogus.txt
, while
mountdir
is empty
Here's what it looks like when you try it:
snowball:655$ pwd /home/joseph/fuse-tutorial/example snowball:656$ ls -lR .: total 12 -rw-r--r-- 1 joseph users 185 Jun 9 15:56 Makefile drwxr-xr-x 2 joseph users 4096 Jun 12 17:16 mountdir/ drwxr-xr-x 2 joseph users 4096 Jun 12 17:16 rootdir/ ./mountdir: total 0 ./rootdir: total 4 -rw-r--r-- 1 joseph users 11 Jun 12 17:16 bogus.txt
Now, if you go into the example
directory and execute
../src/bbfs rootdir mountdir
all of the files that are really in rootdir
appear to also
be in mountdir
"
snowball:657$ ../src/bbfs rootdir/ mountdir/ about to call fuse_main snowball:658$ ls -lR .: total 40 -rw-r--r-- 1 joseph users 185 Jun 9 15:56 Makefile -rw-r--r-- 1 joseph users 25632 Jun 12 17:51 bbfs.log drwxr-xr-x 2 joseph users 4096 Jun 12 17:16 mountdir/ drwxr-xr-x 2 joseph users 4096 Jun 12 17:16 rootdir/ ./mountdir: total 4 -rw-r--r-- 1 joseph users 11 Jun 12 17:16 bogus.txt ./rootdir: total 4 -rw-r--r-- 1 joseph users 11 Jun 12 17:16 bogus.txt
But, every time you perform any file
operation in mountdir
, the operation (and a whole bunch
of both relevant and irrelevant stuff) gets logged to a new file in the
current working directory called bbfs.log
If you execute
tail -F bbfslog
in another terminal window, you can watch the operations get logged.
Finally, you can see that the operating system sees
mountdir
as a filesystem:
snowball:660$ mount | grep mountdir bbfs on /home/joseph/fuse-tutorial/example/mountdir type fuse.bbfs (rw,nosuid,nodev,relatime,user_id=1248,group_id=1005)
Finally, you can unmount the filesystem with
snowball:661$ fusermount -u mountdir
snowball:662$ ls -lR
.:
total 40
-rw-r--r-- 1 joseph users 185 Jun 9 15:56 Makefile
-rw-r--r-- 1 joseph users 27520 Jun 12 17:57 bbfs.log
drwxr-xr-x 2 joseph users 4096 Jun 12 17:16 mountdir/
drwxr-xr-x 2 joseph users 4096 Jun 12 17:16 rootdir/
./mountdir:
total 0
./rootdir:
total 4
-rw-r--r-- 1 joseph users 11 Jun 12 17:16 bogus.txt
(note that fusermount
isn't part of this tutorial
— it comes along with FUSE).
pkg-config
One thing to mention about configuring the software is the line
PKG_CHECK_MODULES(FUSE, fuse)
in configure.ac
This translates to two invocations of pkg-config
to
obtain the C compilation flags and libraries needed to compile and
link the code in the tutorial.
`pkg-config fuse --cflags`
says to use pkg-config
to determine what C
compiler flags are necessary to compile a source file that makes use
of FUSE. The back-quotes around the command are important —
they take the output of the command and insert it into the
command-line as command-line operations (note — it's important
those are back-quotes aka accent graves. They can't be forward quotes,
nor double quotes). The other place it's used,
`pkg-config fuse --libs`
gives the extra command-line arguments to link the program with
libfuse
.
An earlier version of this tutorial used these invocations directly in the Makefile, like this:
bbfs : bbfs.o log.o gcc -g -o bbfs bbfs.o log.o `pkg-config fuse --libs` bbfs.o : bbfs.c log.h params.h gcc -g -Wall `pkg-config fuse --cflags` -c bbfs.c log.o : log.c log.h params.h gcc -g -Wall `pkg-config fuse --cflags` -c log.c
Next: Callbacks and
struct fuse_operations