man.bsd.lv manual page server

Manual Page Search Parameters

GETVFSENT(3) Library Functions Manual GETVFSENT(3)

getvfsent, setvfsent, endvfsent, vfsisloadable, vfsloadmanage virtual filesystem modules

library “libc”

#include <sys/param.h>
#include <sys/mount.h>

struct ovfsconf *
getvfsent(void);

void
setvfsent(int cachelist);

void
endvfsent(void);

int
vfsisloadable(const char *name);

int
vfsload(const char *name);

The () function provides convenient access to a list of installed virtual filesystem modules managed by the kernel. It steps through the list of filesystems one at a time. A null pointer is returned when no more data is available. The fields in a “struct ovfsconf” are as follows:

vfc_name
the name of the filesystem
vfc_index
the filesystem type number assigned by the kernel and used in calls to mount(2)
vfc_refcount
the number of references to this filesystem (usually the number of mounts, but one greater for filesystems which cannot be unloaded or which are statically linked into the kernel)
vfc_flags
flag bits

The flags are defined as follows:

statically compiled into kernel
may get data over the network
writes are not implemented
data does not represent real files
aliases some other mounted FS
stores file names as Unicode

The () and () functions are used to control caching of the filesystem list, which is obtained in toto from the kernel via sysctl(3). If the cachelist parameter to setvfsent() is non-zero, the list will be retrieved only once, upon the first call to one of the retrieval functions, until endvfsent() is called to clear the cache. In general, setvfsent(1) should be called by programs using the getvfsent() function, and setvfsent(0) (which is also the default state) should be called by programs using the vfsload() function.

The () function returns a non-zero value if a later call to vfsload(name) is likely to succeed. We say “likely” because vfsisloadable() does not check any of the conditions necessary for vfsload() to succeed.

The () function attempts to load a kernel module implementing filesystem name. It returns zero if the filesystem module was successfully located and loaded, or non-zero otherwise. It should only be called in the following circumstances:

  1. () has been called and returned a non-zero value.
  2. vfsisloadable() has been called and returned a non-zero value.

Here is an example, taken from the source to mount_cd9660(8):

struct vfsconf *vfc;
int error;

/* setup code here */

error = getvfsbyname("cd9660", &vfc);
if (error && vfsisloadable("cd9660")) {
	if (vfsload("cd9660"))
		err(EX_OSERR, "vfsload(cd9660)");
	endvfsent();	/* flush cache */
	error = getvfsbyname("cd9660", &vfc);
}
if (error)
	errx(1, "cd9660 filesystem is not available");

if (mount(vfc.vfc_name, dir, mntflags, &args) < 0)
	err(1, NULL);

The getvfsent() routine returns a pointer to a static data structure when it succeeds, and returns a null pointer when it fails. On failure, errno may be set to one of the values documented for sysctl(3) or malloc(3), if a failure of that function was the cause; otherwise errno will be unmodified.

The vfsload() function returns a non-zero value on failure, or zero on success. If vfsload() fails, errno may be set to one of the values documented for kldload(2).

kldload(2), mount(2), mount(8)

The getvfsent() family of functions first appeared in FreeBSD 2.0.

The loadable filesystem support was written by Garrett A. Wollman, based on generic loadable kernel module support by Terry Lambert.

September 24, 1994 DragonFly-5.6.1