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