Query around filesystems development


I’ve been eyeing btrfs filesystem development and had few queries regarding it. From the develop docs: File systems overview — Haiku internals documentation and previous GSoC posts, there seemed to be two tools through which filesystems can be worked on: fs_shell (btrfs_shell) and userlandfs.

I’m unable to understand how these two work from the docs page above. Particularly below doubts:

  1. How and where to run above cmds? Do we have to compile and run it inside Haiku or is it possible to run on host linux system?
  2. How are tests on other fs run if the Haiku has only a BE fs partition mounted?

I’ll be happy to update the developer docs if someone can share the cmds used to run above tools.


fs_shell can be run anywhere as part of the haiku buildsystem. There is an implementation of it for most filesystems. In particular, bfs_shell is what we use in the buildsystem to create the resulting filesystem image when building Haiku.

It is run using jam (our build tool), on any platform (Haiku or another supported one such as Linux).

There is an example for XFS here: The XFS File System — Haiku internals documentation which you can probably adjust for use with other filesystems (replace “xfs” with the name of the filesystem you’re working with).

userlandfs, on the other hand, is run inside Haiku. It is similar to FUSE on Linux but it allows to test code meant to be run inside the Haiku kernel. So, the same filesystem can be run either in userspace (as a normal application, allowing to use a debugger and other tools, andn ot bringing the whole system down if it crashes), or in kernel space as a driver. Of course it is possible to run Haiku itself in a virtual machine on top of another OS (qemu would be my preferred choice for this).

For running userlandfs, first you need to build your filesystem as an userlandfs add-on, and add it to the Haiku image. Then you use the mount command to mount your test disk image:

mount -t userlandfs -p "<client FS> <client FS params>" <device> <mount point>

where <device> will be either an actual device (/dev/disk/…) or a disk image file. <mount point> will be where you want to mount it (an empty directory), and <client FS> is the filesystem name. For example:

mount -t userlandfs -p "ufs2" /boot/home/Desktop/FreeBSDImage.ufs2 /tmp/testmount

Few of the filesystems have been adjusted for use with userlandfs, but you can see how its done here: userlandfs « file_systems « kernel « add-ons « tests « src - haiku - Haiku's main repository and maybe try to add support for more of them.

To run the tests (either with fs_shell or userlandfs), you will need a filesystem image of the filesystem you’re working with. You can either create one on another OS and fill it manually with some files, or you can find existing ones. For example, the UFS2 filesystem could be tested using a FreeBSD disk image.