Compiling and Running


The only point of interest in compiling BBFS (and other FUSE filesystems) is its use of the pkg-config command. pkg-config is a system to maintain the necessary options to use a library. It appears twice: in compiling the source code, and in linking the object files.

`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

The Makefile in the src directory gives examples of using the pkg-config command.

The bbfs filesystem is compiled by going into the src subdirectory and executing the command

% make

Mounting a BBFS Filesystem

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

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. 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, if you execute the

% mount

command, one of the resulting lines of output will look something like this:

bbfs on /home/pfeiffer/fuse-tutorial/example/mountdir type fuse.bbfs (rw,nosuid,nodev,user=pfeiffer)


Finally, you can unmount the filesystem with

fusermount -u mountdir

(note that fusermount isn't part of this tutorial — it comes along with FUSE).

Next: Callbacks and struct fuse_operations

Last modified: Mon Jan 10 17:33:11 MST 2011