1 .\" $NetBSD: ukfs.3,v 1.9 2009/09/14 20:54:34 pooka Exp $
3 .\" Copyright (c) 2008 Antti Kantee. All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .Nd user kernel file system library interface
33 ukfs Library (libukfs, \-lukfs)
39 library provides direct access to file systems without having to
40 specially mount a file system.
41 Therefore, accessing a file system through
43 requires no special kernel support apart from standard POSIX functionality.
48 all kernel file systems which are supported by rump are available.
49 It allows to write utilities for accessing file systems without having
50 to duplicate file system internals knowledge already present in kernel
54 provides a high-level pathname based interface for accessing file systems.
55 If a lower level interface it desired,
57 should be used directly.
58 However, much like system calls, the interfaces of
60 are self-contained and require no tracking and release of resources.
61 The only exception is the file system handle
63 which should be released after use.
69 .Fn ukfs_modload "const char *fname"
71 .Fn ukfs_modload_dir "const char *dirname"
73 .Fn ukfs_vfstypes "char *buf" "size_t buflen"
75 .Fn ukfs_mount "const char *vfsname" "const char *devpath" \
76 "const char *mountpath" "int mntflags" "void *arg" "size_t alen"
78 .Fn ukfs_mount_disk "const char *vfsname" "const char *devpath" \
79 "int partition" "const char *mountpath" "int mntflags" \
80 "void *arg" "size_t alen"
82 .Fn ukfs_release "struct ukfs *ukfs" "int flags"
86 intializes the library and must be called once per process using
90 is used at runtime to dynamically load a library which contains a
92 For this to succeed, the
94 library and the module targetted must be compiled with compatible kernel
95 versions and the application must be dynamically linked.
96 Additionally, since this routine does not handle dependencies, all the
97 dependencies of the library must be loaded beforehand.
98 The routine returns \-1 for fatal error, 0 for dependency failure and 1
104 file system modules in directory
106 It looks for libraries which begin with
110 The routine tries to handle dependencies by retrying to load libraries
111 which failed due to dependencies.
113 returns the number of vfs modules loaded or sets errno and
114 returns \-1 in case of a fatal error in directory searching.
115 In case a fatal error occurs after some modules have already been
116 loaded, the number of loaded module is returned.
117 Fatal errors in loading the modules themselves are ignored and
119 should be used directly if finegrained error reporting is desired.
121 It should be noted that the above routines affect the whole process,
122 not just a specific instance of
124 It is preferable to call them from only one thread, as the underlying
125 dynamic library interfaces may not be threadsafe.
128 queries the available file system types and returns a nul-terminated
129 list of types separated by spaces in
131 The format of the list is equivalent to the one returned by
134 .Pa vfs.generic.fstypes .
135 The function returns the length of the string without the trailing nul
137 Notably, the return value 0 means there are no file systems available.
138 If there is not enough room in the caller's buffer for all file system
139 types, as many as fit will be returned.
142 intializes a file system image.
143 The handle resulting from the operation is passed to all other routines
144 and identifies the instance of the mount analoguous to what a pathname
145 specifies in a normally mounted file system.
146 The parameters are the following:
147 .Bl -tag -width XXX -offset indent
149 Name of the file system to be used, e.g.
152 Path of file system image.
153 It can be either a regular file, device or, if the file system does
154 not support the concept of a device, an abitrary string, e.g. network
157 Path where the file system is mounted to.
158 This parameter is used only by the file system being mounted.
163 Flags as passed to the
165 system call, for example
167 In addition to generic parameters, file system specific parameters such as
169 (ffs) may be passed here.
171 File system private argument structure.
172 This is passed directly to the file system.
177 Size of said structure.
182 function must be used to mount disk-based file systems.
183 It takes the same arguments as
185 except for an additional argument signifying the
190 contains a disklabel, this value specifies the number of the partition
191 within the image used as the file system backend.
194 does not contain a disklabel, the value
195 .Dv UKFS_PARTITION_NONE
196 must be used to signal that the file system backend is the entire
200 unmounts the file system and releases the resources associated with
202 The return value signals the return value of the unmount operation.
205 will continue to remain valid.
206 The possible values for flags are:
207 .Bl -tag -width XUKFS_RELFLAG_NOUNMOUT -offset indent
208 .It Dv UKFS_RELFLAG_NOUNMOUNT
209 Do not unmount file system, just release ukfs handle.
210 Release always succeeds.
211 .It Dv UKFS_RELFLAG_FORCE
212 Forcefully unmount the file system.
213 This means that any busy nodes (due to e.g.
216 Release always succeeds.
221 .Fn ukfs_chdir "struct ukfs *ukfs" "const char *path"
223 .Fn ukfs_getdents "struct ukfs *ukfs" "const char *dirname" "off_t *off" \
224 "uint8_t *buf" "size_t bufsize"
226 .Fn ukfs_read "struct ukfs *ukfs" "const char *filename" "off_t off" \
227 "uint8_t *buf" "size_t bufsize"
229 .Fn ukfs_write "struct ukfs *ukfs" "const char *filename" "off_t off" \
230 "uint8_t *buf" "size_t bufsize"
232 .Fn ukfs_create "struct ukfs *ukfs" "const char *filename" "mode_t mode"
234 .Fn ukfs_mknod "struct ukfs *ukfs" "const char *path" "mode_t mode" "dev_t dev"
236 .Fn ukfs_mkfifo "struct ukfs *ukfs" "const char *path" "mode_t mode"
238 .Fn ukfs_mkdir "struct ukfs *ukfs" "const char *filename" "mode_t mode"
240 .Fn ukfs_remove "struct ukfs *ukfs" "const char *filename"
242 .Fn ukfs_rmdir "struct ukfs *ukfs" "const char *filename"
244 .Fn ukfs_link "struct ukfs *ukfs" "const char *filename" "const char *f_create"
246 .Fn ukfs_symlink "struct ukfs *ukfs" "const char *filename" \
247 "const char *linkname"
249 .Fn ukfs_readlink "struct ukfs *ukfs" "const char *filename" \
250 "char *linkbuf" "size_t buflen"
252 .Fn ukfs_rename "struct ukfs *ukfs" "const char *from" "const char *to"
254 .Fn ukfs_stat "struct ukfs *ukfs" "const char *filename" \
255 "struct stat *file_stat"
257 .Fn ukfs_lstat "struct ukfs *ukfs" "const char *filename" \
258 "struct stat *file_stat"
260 .Fn ukfs_chmod "struct ukfs *ukfs" "const char *filename" "mode_t mode"
262 .Fn ukfs_lchmod "struct ukfs *ukfs" "const char *filename" "mode_t mode"
264 .Fn ukfs_chown "struct ukfs *ukfs" "const char *filename" "uid_t uid" \
267 .Fn ukfs_lchown "struct ukfs *ukfs" "const char *filename" "uid_t uid" \
270 .Fn ukfs_chflags "struct ukfs *ukfs" "const char *filename" "u_long flags"
272 .Fn ukfs_lchflags "struct ukfs *ukfs" "const char *filename" "u_long flags"
274 .Fn ukfs_utimes "struct ukfs *ukfs" "const char *filename" \
275 "const struct timeval *tptr"
277 .Fn ukfs_lutimes "struct ukfs *ukfs" "const char *filename" \
278 "const struct timeval *tptr"
281 The above routines operate like their system call counterparts and the
282 system call manual pages without the ukfs_ prefix should be referred to
283 for further information on the parameters.
285 The only call which modifies
291 in the sense that it affects the interpretation of relative paths.
292 If succesful, all relative pathnames will be resolved starting from the
294 Currently the call affects all accesses to that particular
296 but it might be later changed to be thread private.
300 .Fn ukfs_util_builddirs "struct ukfs *ukfs" "const char *pathname" "mode_t mode"
303 Builds a directory hierarchy.
306 argument may contain multiple levels of hierarchy.
307 It is not considered an error if any of the directories specified exist
316 .An Antti Kantee Aq pooka@cs.hut.fi
319 should be considered experimental technology and may change without warning.
321 On Linux, dynamically linked binaries can include support for only
322 one file system due to restrictions with the dynamic linker.
323 If more are desired, they must be loaded at runtime using
327 does not have this restriction, portable programs should load all
328 file system drivers dynamically.