xref: /freebsd/sys/kern/vfs_init.c (revision fdafd315ad0d0f28a11b9fb4476a9ab059c62b92)
19454b2d8SWarner Losh /*-
251369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
351369649SPedro F. Giffuni  *
4df8bae1dSRodney W. Grimes  * Copyright (c) 1989, 1993
5df8bae1dSRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
6df8bae1dSRodney W. Grimes  *
7df8bae1dSRodney W. Grimes  * This code is derived from software contributed
8df8bae1dSRodney W. Grimes  * to Berkeley by John Heidemann of the UCLA Ficus project.
9df8bae1dSRodney W. Grimes  *
10df8bae1dSRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
11df8bae1dSRodney W. Grimes  * modification, are permitted provided that the following conditions
12df8bae1dSRodney W. Grimes  * are met:
13df8bae1dSRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
14df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
15df8bae1dSRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
16df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
17df8bae1dSRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
1869a28758SEd Maste  * 3. Neither the name of the University nor the names of its contributors
19df8bae1dSRodney W. Grimes  *    may be used to endorse or promote products derived from this software
20df8bae1dSRodney W. Grimes  *    without specific prior written permission.
21df8bae1dSRodney W. Grimes  *
22df8bae1dSRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23df8bae1dSRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24df8bae1dSRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25df8bae1dSRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26df8bae1dSRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27df8bae1dSRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28df8bae1dSRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29df8bae1dSRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30df8bae1dSRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31df8bae1dSRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32df8bae1dSRodney W. Grimes  * SUCH DAMAGE.
33df8bae1dSRodney W. Grimes  */
34df8bae1dSRodney W. Grimes 
35df8bae1dSRodney W. Grimes #include <sys/param.h>
36f23b4c91SGarrett Wollman #include <sys/systm.h>
374d30adc4SRick Macklem #include <sys/fnv_hash.h>
380e5c6bd4SJamie Gritton #include <sys/jail.h>
39c901836cSGarrett Wollman #include <sys/kernel.h>
4032ba8e93SPoul-Henning Kamp #include <sys/linker.h>
41df8bae1dSRodney W. Grimes #include <sys/mount.h>
4232ba8e93SPoul-Henning Kamp #include <sys/proc.h>
43168f4ee0SKonstantin Belousov #include <sys/sx.h>
44edd32c2dSJohn Baldwin #include <sys/syscallsubr.h>
45e99ea9ecSBruce Evans #include <sys/sysctl.h>
46df8bae1dSRodney W. Grimes #include <sys/vnode.h>
47df8bae1dSRodney W. Grimes #include <sys/malloc.h>
48df8bae1dSRodney W. Grimes 
49ebbfc2f8SPoul-Henning Kamp static int	vfs_register(struct vfsconf *);
50ebbfc2f8SPoul-Henning Kamp static int	vfs_unregister(struct vfsconf *);
512b14f991SJulian Elischer 
52a1c995b6SPoul-Henning Kamp MALLOC_DEFINE(M_VNODE, "vnodes", "Dynamically allocated vnodes");
53a1c995b6SPoul-Henning Kamp 
542b14f991SJulian Elischer /*
55138e514cSPeter Wemm  * The highest defined VFS number.
5699448ed1SJohn Dyson  */
57138e514cSPeter Wemm int maxvfsconf = VFS_GENERIC + 1;
58eb8e6d52SEivind Eklund 
59eb8e6d52SEivind Eklund /*
60eb8e6d52SEivind Eklund  * Single-linked list of configured VFSes.
61eb8e6d52SEivind Eklund  * New entries are added/deleted by vfs_register()/vfs_unregister()
62eb8e6d52SEivind Eklund  */
633dfe213eSPoul-Henning Kamp struct vfsconfhead vfsconf = TAILQ_HEAD_INITIALIZER(vfsconf);
64168f4ee0SKonstantin Belousov struct sx vfsconf_sx;
65168f4ee0SKonstantin Belousov SX_SYSINIT(vfsconf, &vfsconf_sx, "vfsconf");
66b676e48cSMike Smith 
67b676e48cSMike Smith /*
684d30adc4SRick Macklem  * Loader.conf variable vfs.typenumhash enables setting vfc_typenum using a hash
694d30adc4SRick Macklem  * calculation on vfc_name, so that it doesn't change when file systems are
704d30adc4SRick Macklem  * loaded in a different order. This will avoid the NFS server file handles from
714d30adc4SRick Macklem  * changing for file systems that use vfc_typenum in their fsid.
724d30adc4SRick Macklem  */
734d30adc4SRick Macklem static int	vfs_typenumhash = 1;
744d30adc4SRick Macklem SYSCTL_INT(_vfs, OID_AUTO, typenumhash, CTLFLAG_RDTUN, &vfs_typenumhash, 0,
754d30adc4SRick Macklem     "Set vfc_typenum using a hash calculation on vfc_name, so that it does not"
764d30adc4SRick Macklem     " change when file systems are loaded in a different order.");
774d30adc4SRick Macklem 
784d30adc4SRick Macklem /*
79273350adSPoul-Henning Kamp  * A Zen vnode attribute structure.
80273350adSPoul-Henning Kamp  *
81273350adSPoul-Henning Kamp  * Initialized when the first filesystem registers by vfs_register().
82273350adSPoul-Henning Kamp  */
83273350adSPoul-Henning Kamp struct vattr va_null;
84273350adSPoul-Henning Kamp 
85273350adSPoul-Henning Kamp /*
86df8bae1dSRodney W. Grimes  * vfs_init.c
87df8bae1dSRodney W. Grimes  *
88df8bae1dSRodney W. Grimes  * Allocate and fill in operations vectors.
89df8bae1dSRodney W. Grimes  *
90df8bae1dSRodney W. Grimes  * An undocumented feature of this approach to defining operations is that
91df8bae1dSRodney W. Grimes  * there can be multiple entries in vfs_opv_descs for the same operations
92df8bae1dSRodney W. Grimes  * vector. This allows third parties to extend the set of operations
93df8bae1dSRodney W. Grimes  * supported by another layer in a binary compatibile way. For example,
94df8bae1dSRodney W. Grimes  * assume that NFS needed to be modified to support Ficus. NFS has an entry
95df8bae1dSRodney W. Grimes  * (probably nfs_vnopdeop_decls) declaring all the operations NFS supports by
96df8bae1dSRodney W. Grimes  * default. Ficus could add another entry (ficus_nfs_vnodeop_decl_entensions)
97df8bae1dSRodney W. Grimes  * listing those new operations Ficus adds to NFS, all without modifying the
98df8bae1dSRodney W. Grimes  * NFS code. (Of couse, the OTW NFS protocol still needs to be munged, but
99df8bae1dSRodney W. Grimes  * that is a(whole)nother story.) This is a feature.
100df8bae1dSRodney W. Grimes  */
1014e61198eSPeter Wemm 
102df8bae1dSRodney W. Grimes /*
103df8bae1dSRodney W. Grimes  * Routines having to do with the management of the vnode table.
104df8bae1dSRodney W. Grimes  */
105df8bae1dSRodney W. Grimes 
106168f4ee0SKonstantin Belousov static struct vfsconf *
vfs_byname_locked(const char * name)107168f4ee0SKonstantin Belousov vfs_byname_locked(const char *name)
108168f4ee0SKonstantin Belousov {
109168f4ee0SKonstantin Belousov 	struct vfsconf *vfsp;
110168f4ee0SKonstantin Belousov 
111168f4ee0SKonstantin Belousov 	sx_assert(&vfsconf_sx, SA_LOCKED);
112168f4ee0SKonstantin Belousov 	if (!strcmp(name, "ffs"))
113168f4ee0SKonstantin Belousov 		name = "ufs";
114168f4ee0SKonstantin Belousov 	TAILQ_FOREACH(vfsp, &vfsconf, vfc_list) {
115168f4ee0SKonstantin Belousov 		if (!strcmp(name, vfsp->vfc_name))
116168f4ee0SKonstantin Belousov 			return (vfsp);
117168f4ee0SKonstantin Belousov 	}
118168f4ee0SKonstantin Belousov 	return (NULL);
119168f4ee0SKonstantin Belousov }
120168f4ee0SKonstantin Belousov 
1213dfe213eSPoul-Henning Kamp struct vfsconf *
vfs_byname(const char * name)1223dfe213eSPoul-Henning Kamp vfs_byname(const char *name)
1233dfe213eSPoul-Henning Kamp {
1243dfe213eSPoul-Henning Kamp 	struct vfsconf *vfsp;
1253dfe213eSPoul-Henning Kamp 
126168f4ee0SKonstantin Belousov 	vfsconf_slock();
127168f4ee0SKonstantin Belousov 	vfsp = vfs_byname_locked(name);
128168f4ee0SKonstantin Belousov 	vfsconf_sunlock();
1293dfe213eSPoul-Henning Kamp 	return (vfsp);
1303dfe213eSPoul-Henning Kamp }
1313dfe213eSPoul-Henning Kamp 
13232ba8e93SPoul-Henning Kamp struct vfsconf *
vfs_byname_kld(const char * fstype,struct thread * td,int * error)13332ba8e93SPoul-Henning Kamp vfs_byname_kld(const char *fstype, struct thread *td, int *error)
13432ba8e93SPoul-Henning Kamp {
13532ba8e93SPoul-Henning Kamp 	struct vfsconf *vfsp;
136ffc72591SJamie Gritton 	int fileid, loaded;
13732ba8e93SPoul-Henning Kamp 
13832ba8e93SPoul-Henning Kamp 	vfsp = vfs_byname(fstype);
13932ba8e93SPoul-Henning Kamp 	if (vfsp != NULL)
14032ba8e93SPoul-Henning Kamp 		return (vfsp);
14132ba8e93SPoul-Henning Kamp 
142322fb40cSJohn Baldwin 	/* Try to load the respective module. */
143edd32c2dSJohn Baldwin 	*error = kern_kldload(td, fstype, &fileid);
144ffc72591SJamie Gritton 	loaded = (*error == 0);
145ffc72591SJamie Gritton 	if (*error == EEXIST)
146ffc72591SJamie Gritton 		*error = 0;
147*3eed4803SJohn Baldwin 	if (*error) {
148*3eed4803SJohn Baldwin 		*error = ENODEV;
14932ba8e93SPoul-Henning Kamp 		return (NULL);
150*3eed4803SJohn Baldwin 	}
151edd32c2dSJohn Baldwin 
15232ba8e93SPoul-Henning Kamp 	/* Look up again to see if the VFS was loaded. */
15332ba8e93SPoul-Henning Kamp 	vfsp = vfs_byname(fstype);
15432ba8e93SPoul-Henning Kamp 	if (vfsp == NULL) {
155ffc72591SJamie Gritton 		if (loaded)
156edd32c2dSJohn Baldwin 			(void)kern_kldunload(td, fileid, LINKER_UNLOAD_FORCE);
15732ba8e93SPoul-Henning Kamp 		*error = ENODEV;
15832ba8e93SPoul-Henning Kamp 		return (NULL);
15932ba8e93SPoul-Henning Kamp 	}
16032ba8e93SPoul-Henning Kamp 	return (vfsp);
16132ba8e93SPoul-Henning Kamp }
16232ba8e93SPoul-Henning Kamp 
1638ff7fad1SKonstantin Belousov static int
vfs_mount_sigdefer(struct mount * mp)1648ff7fad1SKonstantin Belousov vfs_mount_sigdefer(struct mount *mp)
1658ff7fad1SKonstantin Belousov {
1668ff7fad1SKonstantin Belousov 	int prev_stops, rc;
1678ff7fad1SKonstantin Belousov 
1688ff7fad1SKonstantin Belousov 	TSRAW(curthread, TS_ENTER, "VFS_MOUNT", mp->mnt_vfc->vfc_name);
1698ff7fad1SKonstantin Belousov 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
1708ff7fad1SKonstantin Belousov 	rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_mount)(mp);
1718ff7fad1SKonstantin Belousov 	sigallowstop(prev_stops);
1728ff7fad1SKonstantin Belousov 	TSRAW(curthread, TS_EXIT, "VFS_MOUNT", mp->mnt_vfc->vfc_name);
1738ff7fad1SKonstantin Belousov 	return (rc);
1748ff7fad1SKonstantin Belousov }
1758ff7fad1SKonstantin Belousov 
1768ff7fad1SKonstantin Belousov static int
vfs_unmount_sigdefer(struct mount * mp,int mntflags)1778ff7fad1SKonstantin Belousov vfs_unmount_sigdefer(struct mount *mp, int mntflags)
1788ff7fad1SKonstantin Belousov {
1798ff7fad1SKonstantin Belousov 	int prev_stops, rc;
1808ff7fad1SKonstantin Belousov 
1818ff7fad1SKonstantin Belousov 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
1828ff7fad1SKonstantin Belousov 	rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_unmount)(mp, mntflags);
1838ff7fad1SKonstantin Belousov 	sigallowstop(prev_stops);
1848ff7fad1SKonstantin Belousov 	return (rc);
1858ff7fad1SKonstantin Belousov }
1868ff7fad1SKonstantin Belousov 
1878ff7fad1SKonstantin Belousov static int
vfs_root_sigdefer(struct mount * mp,int flags,struct vnode ** vpp)1888ff7fad1SKonstantin Belousov vfs_root_sigdefer(struct mount *mp, int flags, struct vnode **vpp)
1898ff7fad1SKonstantin Belousov {
1908ff7fad1SKonstantin Belousov 	int prev_stops, rc;
1918ff7fad1SKonstantin Belousov 
1928ff7fad1SKonstantin Belousov 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
1938ff7fad1SKonstantin Belousov 	rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_root)(mp, flags, vpp);
1948ff7fad1SKonstantin Belousov 	sigallowstop(prev_stops);
1958ff7fad1SKonstantin Belousov 	return (rc);
1968ff7fad1SKonstantin Belousov }
1978ff7fad1SKonstantin Belousov 
1988ff7fad1SKonstantin Belousov static int
vfs_cachedroot_sigdefer(struct mount * mp,int flags,struct vnode ** vpp)199dc20b834SMateusz Guzik vfs_cachedroot_sigdefer(struct mount *mp, int flags, struct vnode **vpp)
200dc20b834SMateusz Guzik {
201dc20b834SMateusz Guzik 	int prev_stops, rc;
202dc20b834SMateusz Guzik 
203dc20b834SMateusz Guzik 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
204dc20b834SMateusz Guzik 	rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_cachedroot)(mp, flags, vpp);
205dc20b834SMateusz Guzik 	sigallowstop(prev_stops);
206dc20b834SMateusz Guzik 	return (rc);
207dc20b834SMateusz Guzik }
208dc20b834SMateusz Guzik 
209dc20b834SMateusz Guzik static int
vfs_quotactl_sigdefer(struct mount * mp,int cmd,uid_t uid,void * arg,bool * mp_busy)210a4b07a27SJason A. Harmening vfs_quotactl_sigdefer(struct mount *mp, int cmd, uid_t uid, void *arg,
211a4b07a27SJason A. Harmening     bool *mp_busy)
2128ff7fad1SKonstantin Belousov {
2138ff7fad1SKonstantin Belousov 	int prev_stops, rc;
2148ff7fad1SKonstantin Belousov 
2158ff7fad1SKonstantin Belousov 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
216a4b07a27SJason A. Harmening 	rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_quotactl)(mp, cmd, uid, arg,
217a4b07a27SJason A. Harmening 	    mp_busy);
2188ff7fad1SKonstantin Belousov 	sigallowstop(prev_stops);
2198ff7fad1SKonstantin Belousov 	return (rc);
2208ff7fad1SKonstantin Belousov }
2218ff7fad1SKonstantin Belousov 
2228ff7fad1SKonstantin Belousov static int
vfs_statfs_sigdefer(struct mount * mp,struct statfs * sbp)2238ff7fad1SKonstantin Belousov vfs_statfs_sigdefer(struct mount *mp, struct statfs *sbp)
2248ff7fad1SKonstantin Belousov {
2258ff7fad1SKonstantin Belousov 	int prev_stops, rc;
2268ff7fad1SKonstantin Belousov 
2278ff7fad1SKonstantin Belousov 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
2288ff7fad1SKonstantin Belousov 	rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_statfs)(mp, sbp);
2298ff7fad1SKonstantin Belousov 	sigallowstop(prev_stops);
2308ff7fad1SKonstantin Belousov 	return (rc);
2318ff7fad1SKonstantin Belousov }
2328ff7fad1SKonstantin Belousov 
2338ff7fad1SKonstantin Belousov static int
vfs_sync_sigdefer(struct mount * mp,int waitfor)2348ff7fad1SKonstantin Belousov vfs_sync_sigdefer(struct mount *mp, int waitfor)
2358ff7fad1SKonstantin Belousov {
2368ff7fad1SKonstantin Belousov 	int prev_stops, rc;
2378ff7fad1SKonstantin Belousov 
2388ff7fad1SKonstantin Belousov 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
2398ff7fad1SKonstantin Belousov 	rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_sync)(mp, waitfor);
2408ff7fad1SKonstantin Belousov 	sigallowstop(prev_stops);
2418ff7fad1SKonstantin Belousov 	return (rc);
2428ff7fad1SKonstantin Belousov }
2438ff7fad1SKonstantin Belousov 
2448ff7fad1SKonstantin Belousov static int
vfs_vget_sigdefer(struct mount * mp,ino_t ino,int flags,struct vnode ** vpp)2458ff7fad1SKonstantin Belousov vfs_vget_sigdefer(struct mount *mp, ino_t ino, int flags, struct vnode **vpp)
2468ff7fad1SKonstantin Belousov {
2478ff7fad1SKonstantin Belousov 	int prev_stops, rc;
2488ff7fad1SKonstantin Belousov 
2498ff7fad1SKonstantin Belousov 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
2508ff7fad1SKonstantin Belousov 	rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_vget)(mp, ino, flags, vpp);
2518ff7fad1SKonstantin Belousov 	sigallowstop(prev_stops);
2528ff7fad1SKonstantin Belousov 	return (rc);
2538ff7fad1SKonstantin Belousov }
2548ff7fad1SKonstantin Belousov 
2558ff7fad1SKonstantin Belousov static int
vfs_fhtovp_sigdefer(struct mount * mp,struct fid * fidp,int flags,struct vnode ** vpp)2568ff7fad1SKonstantin Belousov vfs_fhtovp_sigdefer(struct mount *mp, struct fid *fidp, int flags,
2578ff7fad1SKonstantin Belousov     struct vnode **vpp)
2588ff7fad1SKonstantin Belousov {
2598ff7fad1SKonstantin Belousov 	int prev_stops, rc;
2608ff7fad1SKonstantin Belousov 
2618ff7fad1SKonstantin Belousov 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
2628ff7fad1SKonstantin Belousov 	rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_fhtovp)(mp, fidp, flags, vpp);
2638ff7fad1SKonstantin Belousov 	sigallowstop(prev_stops);
2648ff7fad1SKonstantin Belousov 	return (rc);
2658ff7fad1SKonstantin Belousov }
2668ff7fad1SKonstantin Belousov 
2678ff7fad1SKonstantin Belousov static int
vfs_checkexp_sigdefer(struct mount * mp,struct sockaddr * nam,uint64_t * exflg,struct ucred ** credp,int * numsecflavors,int * secflavors)2681f7104d7SRick Macklem vfs_checkexp_sigdefer(struct mount *mp, struct sockaddr *nam, uint64_t *exflg,
2691f7104d7SRick Macklem     struct ucred **credp, int *numsecflavors, int *secflavors)
2708ff7fad1SKonstantin Belousov {
2718ff7fad1SKonstantin Belousov 	int prev_stops, rc;
2728ff7fad1SKonstantin Belousov 
2738ff7fad1SKonstantin Belousov 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
2748ff7fad1SKonstantin Belousov 	rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_checkexp)(mp, nam, exflg, credp,
2758ff7fad1SKonstantin Belousov 	    numsecflavors, secflavors);
2768ff7fad1SKonstantin Belousov 	sigallowstop(prev_stops);
2778ff7fad1SKonstantin Belousov 	return (rc);
2788ff7fad1SKonstantin Belousov }
2798ff7fad1SKonstantin Belousov 
2808ff7fad1SKonstantin Belousov static int
vfs_extattrctl_sigdefer(struct mount * mp,int cmd,struct vnode * filename_vp,int attrnamespace,const char * attrname)2818ff7fad1SKonstantin Belousov vfs_extattrctl_sigdefer(struct mount *mp, int cmd, struct vnode *filename_vp,
2828ff7fad1SKonstantin Belousov     int attrnamespace, const char *attrname)
2838ff7fad1SKonstantin Belousov {
2848ff7fad1SKonstantin Belousov 	int prev_stops, rc;
2858ff7fad1SKonstantin Belousov 
2868ff7fad1SKonstantin Belousov 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
2878ff7fad1SKonstantin Belousov 	rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_extattrctl)(mp, cmd,
2888ff7fad1SKonstantin Belousov 	    filename_vp, attrnamespace, attrname);
2898ff7fad1SKonstantin Belousov 	sigallowstop(prev_stops);
2908ff7fad1SKonstantin Belousov 	return (rc);
2918ff7fad1SKonstantin Belousov }
2928ff7fad1SKonstantin Belousov 
2938ff7fad1SKonstantin Belousov static int
vfs_sysctl_sigdefer(struct mount * mp,fsctlop_t op,struct sysctl_req * req)2948ff7fad1SKonstantin Belousov vfs_sysctl_sigdefer(struct mount *mp, fsctlop_t op, struct sysctl_req *req)
2958ff7fad1SKonstantin Belousov {
2968ff7fad1SKonstantin Belousov 	int prev_stops, rc;
2978ff7fad1SKonstantin Belousov 
2988ff7fad1SKonstantin Belousov 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
2998ff7fad1SKonstantin Belousov 	rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_sysctl)(mp, op, req);
3008ff7fad1SKonstantin Belousov 	sigallowstop(prev_stops);
3018ff7fad1SKonstantin Belousov 	return (rc);
3028ff7fad1SKonstantin Belousov }
3038ff7fad1SKonstantin Belousov 
3048ff7fad1SKonstantin Belousov static void
vfs_susp_clean_sigdefer(struct mount * mp)3058ff7fad1SKonstantin Belousov vfs_susp_clean_sigdefer(struct mount *mp)
3068ff7fad1SKonstantin Belousov {
3078ff7fad1SKonstantin Belousov 	int prev_stops;
3088ff7fad1SKonstantin Belousov 
3098ff7fad1SKonstantin Belousov 	if (*mp->mnt_vfc->vfc_vfsops_sd->vfs_susp_clean == NULL)
3108ff7fad1SKonstantin Belousov 		return;
3118ff7fad1SKonstantin Belousov 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
3128ff7fad1SKonstantin Belousov 	(*mp->mnt_vfc->vfc_vfsops_sd->vfs_susp_clean)(mp);
3138ff7fad1SKonstantin Belousov 	sigallowstop(prev_stops);
3148ff7fad1SKonstantin Belousov }
3158ff7fad1SKonstantin Belousov 
3168ff7fad1SKonstantin Belousov static void
vfs_reclaim_lowervp_sigdefer(struct mount * mp,struct vnode * vp)3178ff7fad1SKonstantin Belousov vfs_reclaim_lowervp_sigdefer(struct mount *mp, struct vnode *vp)
3188ff7fad1SKonstantin Belousov {
3198ff7fad1SKonstantin Belousov 	int prev_stops;
3208ff7fad1SKonstantin Belousov 
3218ff7fad1SKonstantin Belousov 	if (*mp->mnt_vfc->vfc_vfsops_sd->vfs_reclaim_lowervp == NULL)
3228ff7fad1SKonstantin Belousov 		return;
3238ff7fad1SKonstantin Belousov 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
3248ff7fad1SKonstantin Belousov 	(*mp->mnt_vfc->vfc_vfsops_sd->vfs_reclaim_lowervp)(mp, vp);
3258ff7fad1SKonstantin Belousov 	sigallowstop(prev_stops);
3268ff7fad1SKonstantin Belousov }
3278ff7fad1SKonstantin Belousov 
3288ff7fad1SKonstantin Belousov static void
vfs_unlink_lowervp_sigdefer(struct mount * mp,struct vnode * vp)3298ff7fad1SKonstantin Belousov vfs_unlink_lowervp_sigdefer(struct mount *mp, struct vnode *vp)
3308ff7fad1SKonstantin Belousov {
3318ff7fad1SKonstantin Belousov 	int prev_stops;
3328ff7fad1SKonstantin Belousov 
3338ff7fad1SKonstantin Belousov 	if (*mp->mnt_vfc->vfc_vfsops_sd->vfs_unlink_lowervp == NULL)
3348ff7fad1SKonstantin Belousov 		return;
3358ff7fad1SKonstantin Belousov 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
3368ff7fad1SKonstantin Belousov 	(*(mp)->mnt_vfc->vfc_vfsops_sd->vfs_unlink_lowervp)(mp, vp);
3378ff7fad1SKonstantin Belousov 	sigallowstop(prev_stops);
3388ff7fad1SKonstantin Belousov }
3398ff7fad1SKonstantin Belousov 
3408ff7fad1SKonstantin Belousov static void
vfs_purge_sigdefer(struct mount * mp)3418ff7fad1SKonstantin Belousov vfs_purge_sigdefer(struct mount *mp)
3428ff7fad1SKonstantin Belousov {
3438ff7fad1SKonstantin Belousov 	int prev_stops;
3448ff7fad1SKonstantin Belousov 
3458ff7fad1SKonstantin Belousov 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
3468ff7fad1SKonstantin Belousov 	(*mp->mnt_vfc->vfc_vfsops_sd->vfs_purge)(mp);
3478ff7fad1SKonstantin Belousov 	sigallowstop(prev_stops);
3488ff7fad1SKonstantin Belousov }
3498ff7fad1SKonstantin Belousov 
350eca39864SKonstantin Belousov static int
vfs_report_lockf_sigdefer(struct mount * mp,struct sbuf * sb)351eca39864SKonstantin Belousov vfs_report_lockf_sigdefer(struct mount *mp, struct sbuf *sb)
352eca39864SKonstantin Belousov {
353eca39864SKonstantin Belousov 	int prev_stops, rc;
354eca39864SKonstantin Belousov 
355eca39864SKonstantin Belousov 	prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
356eca39864SKonstantin Belousov 	rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_report_lockf)(mp, sb);
357eca39864SKonstantin Belousov 	sigallowstop(prev_stops);
358eca39864SKonstantin Belousov 	return (rc);
359eca39864SKonstantin Belousov }
360eca39864SKonstantin Belousov 
3618ff7fad1SKonstantin Belousov static struct vfsops vfsops_sigdefer = {
3628ff7fad1SKonstantin Belousov 	.vfs_mount =		vfs_mount_sigdefer,
3638ff7fad1SKonstantin Belousov 	.vfs_unmount =		vfs_unmount_sigdefer,
3648ff7fad1SKonstantin Belousov 	.vfs_root =		vfs_root_sigdefer,
365dc20b834SMateusz Guzik 	.vfs_cachedroot =	vfs_cachedroot_sigdefer,
3668ff7fad1SKonstantin Belousov 	.vfs_quotactl =		vfs_quotactl_sigdefer,
3678ff7fad1SKonstantin Belousov 	.vfs_statfs =		vfs_statfs_sigdefer,
3688ff7fad1SKonstantin Belousov 	.vfs_sync =		vfs_sync_sigdefer,
3698ff7fad1SKonstantin Belousov 	.vfs_vget =		vfs_vget_sigdefer,
3708ff7fad1SKonstantin Belousov 	.vfs_fhtovp =		vfs_fhtovp_sigdefer,
3718ff7fad1SKonstantin Belousov 	.vfs_checkexp =		vfs_checkexp_sigdefer,
3728ff7fad1SKonstantin Belousov 	.vfs_extattrctl =	vfs_extattrctl_sigdefer,
3738ff7fad1SKonstantin Belousov 	.vfs_sysctl =		vfs_sysctl_sigdefer,
3748ff7fad1SKonstantin Belousov 	.vfs_susp_clean =	vfs_susp_clean_sigdefer,
3758ff7fad1SKonstantin Belousov 	.vfs_reclaim_lowervp =	vfs_reclaim_lowervp_sigdefer,
3768ff7fad1SKonstantin Belousov 	.vfs_unlink_lowervp =	vfs_unlink_lowervp_sigdefer,
3778ff7fad1SKonstantin Belousov 	.vfs_purge =		vfs_purge_sigdefer,
378eca39864SKonstantin Belousov 	.vfs_report_lockf =	vfs_report_lockf_sigdefer,
3798ff7fad1SKonstantin Belousov };
38032ba8e93SPoul-Henning Kamp 
381eb8e6d52SEivind Eklund /* Register a new filesystem type in the global table */
382ebbfc2f8SPoul-Henning Kamp static int
vfs_register(struct vfsconf * vfc)3834e61198eSPeter Wemm vfs_register(struct vfsconf *vfc)
384aa855a59SPeter Wemm {
385a199ed3cSDoug Rabson 	struct sysctl_oid *oidp;
3867652131bSPoul-Henning Kamp 	struct vfsops *vfsops;
387273350adSPoul-Henning Kamp 	static int once;
3884d30adc4SRick Macklem 	struct vfsconf *tvfc;
3894d30adc4SRick Macklem 	uint32_t hashval;
3904d30adc4SRick Macklem 	int secondpass;
391273350adSPoul-Henning Kamp 
392273350adSPoul-Henning Kamp 	if (!once) {
393273350adSPoul-Henning Kamp 		vattr_null(&va_null);
394273350adSPoul-Henning Kamp 		once = 1;
395273350adSPoul-Henning Kamp 	}
3967652131bSPoul-Henning Kamp 
3975e8c582aSPoul-Henning Kamp 	if (vfc->vfc_version != VFS_VERSION) {
3985e8c582aSPoul-Henning Kamp 		printf("ERROR: filesystem %s, unsupported ABI version %x\n",
3995e8c582aSPoul-Henning Kamp 		    vfc->vfc_name, vfc->vfc_version);
4005e8c582aSPoul-Henning Kamp 		return (EINVAL);
4015e8c582aSPoul-Henning Kamp 	}
402168f4ee0SKonstantin Belousov 	vfsconf_lock();
403168f4ee0SKonstantin Belousov 	if (vfs_byname_locked(vfc->vfc_name) != NULL) {
404168f4ee0SKonstantin Belousov 		vfsconf_unlock();
4055050aa86SKonstantin Belousov 		return (EEXIST);
406168f4ee0SKonstantin Belousov 	}
407aa855a59SPeter Wemm 
4084d30adc4SRick Macklem 	if (vfs_typenumhash != 0) {
4094d30adc4SRick Macklem 		/*
4104d30adc4SRick Macklem 		 * Calculate a hash on vfc_name to use for vfc_typenum. Unless
4114d30adc4SRick Macklem 		 * all of 1<->255 are assigned, it is limited to 8bits since
4124d30adc4SRick Macklem 		 * that is what ZFS uses from vfc_typenum and is also the
4134d30adc4SRick Macklem 		 * preferred range for vfs_getnewfsid().
4144d30adc4SRick Macklem 		 */
4154d30adc4SRick Macklem 		hashval = fnv_32_str(vfc->vfc_name, FNV1_32_INIT);
4164d30adc4SRick Macklem 		hashval &= 0xff;
4174d30adc4SRick Macklem 		secondpass = 0;
4184d30adc4SRick Macklem 		do {
4194d30adc4SRick Macklem 			/* Look for and fix any collision. */
4204d30adc4SRick Macklem 			TAILQ_FOREACH(tvfc, &vfsconf, vfc_list) {
4214d30adc4SRick Macklem 				if (hashval == tvfc->vfc_typenum) {
4224d30adc4SRick Macklem 					if (hashval == 255 && secondpass == 0) {
4234d30adc4SRick Macklem 						hashval = 1;
4244d30adc4SRick Macklem 						secondpass = 1;
4254d30adc4SRick Macklem 					} else
4264d30adc4SRick Macklem 						hashval++;
4274d30adc4SRick Macklem 					break;
4284d30adc4SRick Macklem 				}
4294d30adc4SRick Macklem 			}
4304d30adc4SRick Macklem 		} while (tvfc != NULL);
4314d30adc4SRick Macklem 		vfc->vfc_typenum = hashval;
4324d30adc4SRick Macklem 		if (vfc->vfc_typenum >= maxvfsconf)
4334d30adc4SRick Macklem 			maxvfsconf = vfc->vfc_typenum + 1;
4344d30adc4SRick Macklem 	} else
435aa855a59SPeter Wemm 		vfc->vfc_typenum = maxvfsconf++;
4363dfe213eSPoul-Henning Kamp 	TAILQ_INSERT_TAIL(&vfsconf, vfc, vfc_list);
437aa855a59SPeter Wemm 
438aa855a59SPeter Wemm 	/*
4397652131bSPoul-Henning Kamp 	 * Initialise unused ``struct vfsops'' fields, to use
4407652131bSPoul-Henning Kamp 	 * the vfs_std*() functions.  Note, we need the mount
4417652131bSPoul-Henning Kamp 	 * and unmount operations, at the least.  The check
4427652131bSPoul-Henning Kamp 	 * for vfsops available is just a debugging aid.
4437652131bSPoul-Henning Kamp 	 */
4447652131bSPoul-Henning Kamp 	KASSERT(vfc->vfc_vfsops != NULL,
4457652131bSPoul-Henning Kamp 	    ("Filesystem %s has no vfsops", vfc->vfc_name));
4467652131bSPoul-Henning Kamp 	/*
4477652131bSPoul-Henning Kamp 	 * Check the mount and unmount operations.
4487652131bSPoul-Henning Kamp 	 */
4497652131bSPoul-Henning Kamp 	vfsops = vfc->vfc_vfsops;
45020a92a18SPoul-Henning Kamp 	KASSERT(vfsops->vfs_mount != NULL,
45120a92a18SPoul-Henning Kamp 	    ("Filesystem %s has no mount op", vfc->vfc_name));
4527652131bSPoul-Henning Kamp 	KASSERT(vfsops->vfs_unmount != NULL,
4537652131bSPoul-Henning Kamp 	    ("Filesystem %s has no unmount op", vfc->vfc_name));
4547652131bSPoul-Henning Kamp 
4557652131bSPoul-Henning Kamp 	if (vfsops->vfs_root == NULL)
4567652131bSPoul-Henning Kamp 		/* return file system's root vnode */
4577652131bSPoul-Henning Kamp 		vfsops->vfs_root =	vfs_stdroot;
4587652131bSPoul-Henning Kamp 	if (vfsops->vfs_quotactl == NULL)
4597652131bSPoul-Henning Kamp 		/* quota control */
4607652131bSPoul-Henning Kamp 		vfsops->vfs_quotactl =	vfs_stdquotactl;
4617652131bSPoul-Henning Kamp 	if (vfsops->vfs_statfs == NULL)
4627652131bSPoul-Henning Kamp 		/* return file system's status */
4637652131bSPoul-Henning Kamp 		vfsops->vfs_statfs =	vfs_stdstatfs;
4647652131bSPoul-Henning Kamp 	if (vfsops->vfs_sync == NULL)
4657652131bSPoul-Henning Kamp 		/*
4667652131bSPoul-Henning Kamp 		 * flush unwritten data (nosync)
4677652131bSPoul-Henning Kamp 		 * file systems can use vfs_stdsync
4687652131bSPoul-Henning Kamp 		 * explicitly by setting it in the
4697652131bSPoul-Henning Kamp 		 * vfsop vector.
4707652131bSPoul-Henning Kamp 		 */
4717652131bSPoul-Henning Kamp 		vfsops->vfs_sync =	vfs_stdnosync;
4727652131bSPoul-Henning Kamp 	if (vfsops->vfs_vget == NULL)
4737652131bSPoul-Henning Kamp 		/* convert an inode number to a vnode */
4747652131bSPoul-Henning Kamp 		vfsops->vfs_vget =	vfs_stdvget;
4757652131bSPoul-Henning Kamp 	if (vfsops->vfs_fhtovp == NULL)
4767652131bSPoul-Henning Kamp 		/* turn an NFS file handle into a vnode */
4777652131bSPoul-Henning Kamp 		vfsops->vfs_fhtovp =	vfs_stdfhtovp;
4787652131bSPoul-Henning Kamp 	if (vfsops->vfs_checkexp == NULL)
4797652131bSPoul-Henning Kamp 		/* check if file system is exported */
4807652131bSPoul-Henning Kamp 		vfsops->vfs_checkexp =	vfs_stdcheckexp;
4817652131bSPoul-Henning Kamp 	if (vfsops->vfs_init == NULL)
4827652131bSPoul-Henning Kamp 		/* file system specific initialisation */
4837652131bSPoul-Henning Kamp 		vfsops->vfs_init =	vfs_stdinit;
4847652131bSPoul-Henning Kamp 	if (vfsops->vfs_uninit == NULL)
4857652131bSPoul-Henning Kamp 		/* file system specific uninitialisation */
4867652131bSPoul-Henning Kamp 		vfsops->vfs_uninit =	vfs_stduninit;
4877652131bSPoul-Henning Kamp 	if (vfsops->vfs_extattrctl == NULL)
4887652131bSPoul-Henning Kamp 		/* extended attribute control */
4897652131bSPoul-Henning Kamp 		vfsops->vfs_extattrctl = vfs_stdextattrctl;
49081d16e2dSAlfred Perlstein 	if (vfsops->vfs_sysctl == NULL)
49181d16e2dSAlfred Perlstein 		vfsops->vfs_sysctl = vfs_stdsysctl;
492eca39864SKonstantin Belousov 	if (vfsops->vfs_report_lockf == NULL)
493eca39864SKonstantin Belousov 		vfsops->vfs_report_lockf = vfs_report_lockf;
4947652131bSPoul-Henning Kamp 
4958ff7fad1SKonstantin Belousov 	if ((vfc->vfc_flags & VFCF_SBDRY) != 0) {
4968ff7fad1SKonstantin Belousov 		vfc->vfc_vfsops_sd = vfc->vfc_vfsops;
4978ff7fad1SKonstantin Belousov 		vfc->vfc_vfsops = &vfsops_sigdefer;
4988ff7fad1SKonstantin Belousov 	}
4998ff7fad1SKonstantin Belousov 
5000e5c6bd4SJamie Gritton 	if (vfc->vfc_flags & VFCF_JAIL)
5010e5c6bd4SJamie Gritton 		prison_add_vfs(vfc);
5020e5c6bd4SJamie Gritton 
5037652131bSPoul-Henning Kamp 	/*
504aa855a59SPeter Wemm 	 * Call init function for this VFS...
505aa855a59SPeter Wemm 	 */
5068ff7fad1SKonstantin Belousov 	if ((vfc->vfc_flags & VFCF_SBDRY) != 0)
5078ff7fad1SKonstantin Belousov 		vfc->vfc_vfsops_sd->vfs_init(vfc);
5088ff7fad1SKonstantin Belousov 	else
5098ff7fad1SKonstantin Belousov 		vfc->vfc_vfsops->vfs_init(vfc);
510168f4ee0SKonstantin Belousov 	vfsconf_unlock();
511aa855a59SPeter Wemm 
512168f4ee0SKonstantin Belousov 	/*
513168f4ee0SKonstantin Belousov 	 * If this filesystem has a sysctl node under vfs
514168f4ee0SKonstantin Belousov 	 * (i.e. vfs.xxfs), then change the oid number of that node to
515168f4ee0SKonstantin Belousov 	 * match the filesystem's type number.  This allows user code
516168f4ee0SKonstantin Belousov 	 * which uses the type number to read sysctl variables defined
517168f4ee0SKonstantin Belousov 	 * by the filesystem to continue working. Since the oids are
518168f4ee0SKonstantin Belousov 	 * in a sorted list, we need to make sure the order is
519168f4ee0SKonstantin Belousov 	 * preserved by re-registering the oid after modifying its
520168f4ee0SKonstantin Belousov 	 * number.
521168f4ee0SKonstantin Belousov 	 */
5227665e341SMateusz Guzik 	sysctl_wlock();
523d3f96f66SAlan Somers 	RB_FOREACH(oidp, sysctl_oid_list, SYSCTL_CHILDREN(&sysctl___vfs)) {
524168f4ee0SKonstantin Belousov 		if (strcmp(oidp->oid_name, vfc->vfc_name) == 0) {
525168f4ee0SKonstantin Belousov 			sysctl_unregister_oid(oidp);
526168f4ee0SKonstantin Belousov 			oidp->oid_number = vfc->vfc_typenum;
527168f4ee0SKonstantin Belousov 			sysctl_register_oid(oidp);
528168f4ee0SKonstantin Belousov 			break;
529168f4ee0SKonstantin Belousov 		}
530168f4ee0SKonstantin Belousov 	}
5317665e341SMateusz Guzik 	sysctl_wunlock();
532168f4ee0SKonstantin Belousov 
533168f4ee0SKonstantin Belousov 	return (0);
534aa855a59SPeter Wemm }
535aa855a59SPeter Wemm 
536eb8e6d52SEivind Eklund /* Remove registration of a filesystem type */
537ebbfc2f8SPoul-Henning Kamp static int
vfs_unregister(struct vfsconf * vfc)5384e61198eSPeter Wemm vfs_unregister(struct vfsconf *vfc)
539aa855a59SPeter Wemm {
5403dfe213eSPoul-Henning Kamp 	struct vfsconf *vfsp;
54169baeadcSKonstantin Belousov 	int error, maxtypenum;
542aa855a59SPeter Wemm 
543168f4ee0SKonstantin Belousov 	vfsconf_lock();
544168f4ee0SKonstantin Belousov 	vfsp = vfs_byname_locked(vfc->vfc_name);
545168f4ee0SKonstantin Belousov 	if (vfsp == NULL) {
546168f4ee0SKonstantin Belousov 		vfsconf_unlock();
547168f4ee0SKonstantin Belousov 		return (EINVAL);
548168f4ee0SKonstantin Belousov 	}
549168f4ee0SKonstantin Belousov 	if (vfsp->vfc_refcount != 0) {
550168f4ee0SKonstantin Belousov 		vfsconf_unlock();
551168f4ee0SKonstantin Belousov 		return (EBUSY);
552168f4ee0SKonstantin Belousov 	}
5538ff7fad1SKonstantin Belousov 	error = 0;
5548ff7fad1SKonstantin Belousov 	if ((vfc->vfc_flags & VFCF_SBDRY) != 0) {
5558ff7fad1SKonstantin Belousov 		if (vfc->vfc_vfsops_sd->vfs_uninit != NULL)
5568ff7fad1SKonstantin Belousov 			error = vfc->vfc_vfsops_sd->vfs_uninit(vfsp);
5578ff7fad1SKonstantin Belousov 	} else {
5581517b8d5SMarvin Ma 		if (vfc->vfc_vfsops->vfs_uninit != NULL)
5598ff7fad1SKonstantin Belousov 			error = vfc->vfc_vfsops->vfs_uninit(vfsp);
5608ff7fad1SKonstantin Belousov 	}
561168f4ee0SKonstantin Belousov 	if (error != 0) {
562168f4ee0SKonstantin Belousov 		vfsconf_unlock();
563aa855a59SPeter Wemm 		return (error);
564aa855a59SPeter Wemm 	}
5653dfe213eSPoul-Henning Kamp 	TAILQ_REMOVE(&vfsconf, vfsp, vfc_list);
566aa855a59SPeter Wemm 	maxtypenum = VFS_GENERIC;
5673dfe213eSPoul-Henning Kamp 	TAILQ_FOREACH(vfsp, &vfsconf, vfc_list)
568aa855a59SPeter Wemm 		if (maxtypenum < vfsp->vfc_typenum)
569aa855a59SPeter Wemm 			maxtypenum = vfsp->vfc_typenum;
570aa855a59SPeter Wemm 	maxvfsconf = maxtypenum + 1;
571168f4ee0SKonstantin Belousov 	vfsconf_unlock();
572168f4ee0SKonstantin Belousov 	return (0);
573aa855a59SPeter Wemm }
5744e61198eSPeter Wemm 
575eb8e6d52SEivind Eklund /*
576eb8e6d52SEivind Eklund  * Standard kernel module handling code for filesystem modules.
577eb8e6d52SEivind Eklund  * Referenced from VFS_SET().
578eb8e6d52SEivind Eklund  */
5794e61198eSPeter Wemm int
vfs_modevent(module_t mod,int type,void * data)5804ae860afSBruce Evans vfs_modevent(module_t mod, int type, void *data)
5814e61198eSPeter Wemm {
5824e61198eSPeter Wemm 	struct vfsconf *vfc;
5834e61198eSPeter Wemm 	int error = 0;
5844e61198eSPeter Wemm 
5854e61198eSPeter Wemm 	vfc = (struct vfsconf *)data;
5864e61198eSPeter Wemm 
5874e61198eSPeter Wemm 	switch (type) {
5884e61198eSPeter Wemm 	case MOD_LOAD:
5894e61198eSPeter Wemm 		if (vfc)
5904e61198eSPeter Wemm 			error = vfs_register(vfc);
5914e61198eSPeter Wemm 		break;
5924e61198eSPeter Wemm 
5934e61198eSPeter Wemm 	case MOD_UNLOAD:
5944e61198eSPeter Wemm 		if (vfc)
5954e61198eSPeter Wemm 			error = vfs_unregister(vfc);
5964e61198eSPeter Wemm 		break;
5973e019deaSPoul-Henning Kamp 	default:
5983e019deaSPoul-Henning Kamp 		error = EOPNOTSUPP;
5994e61198eSPeter Wemm 		break;
6004e61198eSPeter Wemm 	}
6014e61198eSPeter Wemm 	return (error);
6024e61198eSPeter Wemm }
603