FUSE

Introduction

During development, it is common that certain files will need to be mounted to the file system. When assets or other read-only files are mounted, this can be done with the VFS. However, in cases where the file is, for instance, a binary, the VFS is not a viable option. This is because the VFS mounts files as input streams, and a binary needs to be visible to the kernel to run. In circumstances such as these, KOS comes packaged with a FUSE (File System in User Space) filesystem. This allows users to mount KABs directly into the local native filesystem.

Like many of the tools present in KOS, the FUSE filesystem comes with an accompanying service; FuseService. This service can be autowired, and has only two functions, mounting and unmounting KABs into and from the FUSE filesystem. Included in the service are a variety of methods to enable the user to do this. Below is an example of how one might mount an adapter KAB in KOS:

Notice that when a KAB is mounted into the FUSE filesystem, a FuseMount is returned. A FuseMount is an abstraction used to describe a mounting point within FUSE. It stores, and makes accessible to the user, the node on which the KAB is mounted, whether said KAB has been mounted, the KabFile itself along with its id, and finally the name of the mounting point. The name of the mounting point can be specified as has been done in the example above. Alternatively, one can choose not to specify the mounting point name, in which case the name will default to the KAB’s String id.

Because KOS is multi-node, it also provides a means of mounting KABs that are on separate nodes. to do this, all that is necessary is for the user to specify the NodeId like so:

Unmounting a KAB is similarly simple. All one needs to do is pass the FuseMount to the unmount() method like so:

unmountAll(NodeId nodeId). As the name may imply, this allows users to unmount all the KABs on the node specified by the NodeId.

To see more variations on how users can mount and unmount KABs from the FUSE filesystem, one can review the javadocs for the FuseService and FuseMount here.