User-Kernel File System Library (ukfs)


User-Kernel File System Library (ukfs)

libukfs is a library which provides pathname-based access to a file system supported by rump. Historically it was necessary due to the fact that rump system calls did not exist and ukfs took care of some of the less pleasant issues with file system use, such as name resolution.

Although much of what ukfs does could be done using rump system calls, there are still two features which set it apart:

  1. All calls are self-contained. There is no need to e.g. open a file prior to reading the contents. A single call to ukfs_read is enough.
  2. Mounting support. Most of the details having to do with mounting a file system using a process-local server are hidden within a single call to ukfs_mount.

An example of ukfs use is provided below:

fs = ukfs_mount(MOUNT_FFS, "/home/pooka/img/ffs.img", "/", 0, &args, sizeof(args));
ukfs_getdents(fs, "/", 0, buf, sizeof(buf));
ukfs_read(fs, "/etc/passwd", 0, buf, sizeof(buf));
ukfs_chdir(fs, "/etc", 0, buf, sizeof(buf));
ukfs_link(fs, "hardlink", "/linkfile");
ukfs_release(fs, 0);
      

The vision of the ukfs interface is to eventually turn into an operating system independent method for accessing file systems. However, further work is required to reach that point. For example, struct stat had a different binary layout on every platform and calling the ukfs routine cannot happen in a totally platform-agnostic manner - a reference to the correct type of struct stat must be passed.

Even in the current state of development, ukfs has already been successfully used to run NetBSD kernel file systems on Linux.

The ukfs interfaces are further documented in ukfs(3).

Source Code

You can browse the source code history online or look into src/lib/libukfs in a NetBSD source tree.