xref: /illumos-gate/usr/src/uts/common/fs/sockfs/sockvfsops.c (revision 581cede61ac9c14d8d4ea452562a567189eead78)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <sys/types.h>
30 #include <sys/t_lock.h>
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/buf.h>
34 #include <sys/cmn_err.h>
35 #include <sys/debug.h>
36 #include <sys/errno.h>
37 #include <sys/vfs.h>
38 #include <sys/swap.h>
39 #include <sys/vnode.h>
40 #include <sys/cred.h>
41 #include <sys/thread.h>
42 #include <sys/zone.h>
43 
44 #include <fs/fs_subr.h>
45 
46 #include <sys/stream.h>
47 #include <sys/socket.h>
48 #include <sys/stropts.h>
49 #include <sys/socketvar.h>
50 
51 /*
52  * This is the loadable module wrapper.
53  */
54 #include <sys/modctl.h>
55 
56 static zone_key_t sockfs_zone_key;
57 
58 static vfsdef_t vfw = {
59 	VFSDEF_VERSION,
60 	"sockfs",
61 	sockinit,
62 	0,
63 	NULL
64 };
65 
66 extern struct mod_ops mod_fsops;
67 
68 /*
69  * Module linkage information for the kernel.
70  */
71 static struct modlfs modlfs = {
72 	&mod_fsops, "filesystem for sockfs", &vfw
73 };
74 
75 static struct modlinkage modlinkage = {
76 	MODREV_1, (void *)&modlfs, NULL
77 };
78 
79 int
80 _init(void)
81 {
82 	int ret;
83 
84 	/*
85 	 * We want to be informed each time a zone is created or
86 	 * destroyed in the kernel, so we can maintain per-zone
87 	 * kstat. sock_kstat_init() will also be called for the
88 	 * global zone, without us having to special case it here.
89 	 */
90 	zone_key_create(&sockfs_zone_key,
91 	    sock_kstat_init, NULL, sock_kstat_fini);
92 
93 	if ((ret = mod_install(&modlinkage)) != 0) {
94 		(void) zone_key_delete(sockfs_zone_key);
95 	}
96 
97 	return (ret);
98 }
99 
100 int
101 _info(struct modinfo *modinfop)
102 {
103 	return (mod_info(&modlinkage, modinfop));
104 }
105 
106 int
107 _fini(void)
108 {
109 	/* zone_key_delete(sockfs_zone_key); - if we were ever to be unloaded */
110 
111 	return (EBUSY);
112 }
113 
114 /*
115  * N.B.
116  * No _fini routine. This module cannot be unloaded once loaded.
117  * The NO_UNLOAD_STUB in modstub.s must change if this module ever
118  * is modified to become unloadable.
119  */
120