Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
GETVFSENT(3)		 BSD Library Functions Manual		  GETVFSENT(3)

NAME
     getvfsent,	setvfsent, endvfsent, vfsisloadable, vfsload --	manage virtual
     filesystem	modules

SYNOPSIS
     #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);

DESCRIPTION
     The getvfsent() function provides convenient access to a list of in-
     stalled virtual filesystem	modules	managed	by the kernel.	It steps
     through the list of filesystems one at a time.  A null pointer is re-
     turned 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, of which none are	currently defined

     The setvfsent() and endvfsent() 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 re-
     trieval 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 vfsisloadable() function returns a non-zero value if a	later call to
     vfsload(name) is likely to	succeed.  We say ``likely'' because the	condi-
     tions checked by vfsisloadable() are only a small subset of the condi-
     tions necessary for vfsload() to succeed.	In particular, vfsisloadable()
     checks that /dev/lkm is present and can be	opened for writing, and	that
     ~name_mod.o can be	found in one of	the directories	designated for LKMs.

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

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

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

     3.	  sufficient temporary file space is available and writable in one of
	  ${TMPDIR}, /var/tmp, or /tmp.

     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);

RETURN VALUES
     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 unmodi-
     fied.

     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 docu-
     mented for	fork(2), waitpid(2), chdir(2), or execlp(3), or	the return
     status of the modload(8) program, which is	not currently particularly
     useful but	eventually will	be.  In	addition, if modload(8)	exits on a
     signal, vfsload() will fail and set errno to EINVAL.

ENVIRONMENT
     TMPDIR   location for temporary file created by modload(8)	on behalf of
	      vfsload().
     LKMDIR   alternate	directory for vfsisloadable() and vfsload() to search
	      for loadable modules.

SEE ALSO
     mount(2), modload(8), mount(8)

BUGS
     The return	value of the modload(8)	command	isn't particularly useful when
     interpreted as an errno value (or anything	else, for that matter).

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

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

BSD			      September	24, 1994			   BSD

NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ENVIRONMENT | SEE ALSO | BUGS | AUTHORS | HISTORY

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=vfsload&sektion=3&manpath=FreeBSD+3.2-RELEASE>

home | help