int
ukfs_modload(const char *fname)
int
ukfs_modload_dir(const char *dirname)
ssize_t
ukfs_vfstypes(char *buf, size_t buflen)
struct ukfs *
ukfs_mount(const char *vfsname, const char *devpath, const char *mountpath, int mntflags, void *arg, size_t alen)
struct ukfs *
ukfs_mount_disk(const char *vfsname, const char *devpath, int partition, const char *mountpath, int mntflags, void *arg, size_t alen)
int
ukfs_release(struct ukfs *ukfs, int flags)
ukfs_init() intializes the library and must be called once per process using
ukfs.
ukfs_modload() is used at runtime to dynamically load a library which contains a file system module. For this to succeed, the
rump(3) library and the module targetted must be compiled with compatible kernel versions and the application must be dynamically linked. Additionally, since this routine does not handle dependencies, all the dependencies of the library must be loaded beforehand. The routine returns -1 for fatal error, 0 for dependency failure and 1 for success.
ukfs_modload_dir() loads all
rump(3) file system modules in directory
dirname. It looks for libraries which begin with
librumpfs_ and end in
.so. The routine tries to handle dependencies by retrying to load libraries which failed due to dependencies.
ukfs_modload_dir() returns the number of vfs modules loaded or sets errno and returns -1 in case of a fatal error in directory searching. In case a fatal error occurs after some modules have already been loaded, the number of loaded module is returned. Fatal errors in loading the modules themselves are ignored and
ukfs_modload() should be used directly if finegrained error reporting is desired.
It should be noted that the above routines affect the whole process, not just a specific instance of
ukfs. It is preferable to call them from only one thread, as the underlying dynamic library interfaces may not be threadsafe.
ukfs_vfstypes() queries the available file system types and returns a nul-terminated list of types separated by spaces in
buf. The format of the list is equivalent to the one returned by
sysctl(3) on the name
vfs.generic.fstypes. The function returns the length of the string without the trailing nul or -1 for error. Notably, the return value 0 means there are no file systems available. If there is not enough room in the caller's buffer for all file system types, as many as fit will be returned.
ukfs_mount() intializes a file system image. The handle resulting from the operation is passed to all other routines and identifies the instance of the mount analoguous to what a pathname specifies in a normally mounted file system. The parameters are the following:
vfsname
Name of the file system to be used, e.g. MOUNT_FFS.
devpath
Path of file system image. It can be either a regular file, device or, if the file system does not support the concept of a device, an abitrary string, e.g. network address.
mountpath
Path where the file system is mounted to. This parameter is used only by the file system being mounted. Most of the time UKFS_DEFAULTMP is the correct path.
mntflags
Flags as passed to the
mount(2) system call, for example
MNT_RDONLY. In addition to generic parameters, file system specific parameters such as
MNT_LOG (ffs) may be passed here.
arg
File system private argument structure. This is passed directly to the file system. It must match what vfsname expects.
alen
Size of said structure.
The
ukfs_mount_disk() function must be used to mount disk-based file systems. It takes the same arguments as
ukfs_mount(), except for an additional argument signifying the
partition number. If the image
devpath contains a disklabel, this value specifies the number of the partition within the image used as the file system backend. If
devpath does not contain a disklabel, the value
UKFS_PARTITION_NONE must be used to signal that the file system backend is the entire image.
ukfs_release() unmounts the file system and releases the resources associated with
ukfs. The return value signals the return value of the unmount operation. If non-zero,
ukfs will continue to remain valid. The possible values for flags are:
UKFS_RELFLAG_NOUNMOUNT
Do not unmount file system, just release ukfs handle. Release always succeeds.
UKFS_RELFLAG_FORCE
Forcefully unmount the file system. This means that any busy nodes (due to e.g. ukfs_chdir()) will be ignored. Release always succeeds.