10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*12633Sjohn.levon@sun.com * Common Development and Distribution License (the "License").
6*12633Sjohn.levon@sun.com * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
22*12633Sjohn.levon@sun.com * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate */
240Sstevel@tonic-gate
250Sstevel@tonic-gate #include <sys/types.h>
260Sstevel@tonic-gate #include <sys/t_lock.h>
270Sstevel@tonic-gate #include <sys/param.h>
280Sstevel@tonic-gate #include <sys/systm.h>
290Sstevel@tonic-gate #include <sys/buf.h>
300Sstevel@tonic-gate #include <sys/cmn_err.h>
310Sstevel@tonic-gate #include <sys/debug.h>
320Sstevel@tonic-gate #include <sys/errno.h>
330Sstevel@tonic-gate #include <sys/vfs.h>
340Sstevel@tonic-gate #include <sys/swap.h>
350Sstevel@tonic-gate #include <sys/vnode.h>
360Sstevel@tonic-gate #include <sys/cred.h>
370Sstevel@tonic-gate #include <sys/thread.h>
380Sstevel@tonic-gate #include <sys/zone.h>
390Sstevel@tonic-gate
400Sstevel@tonic-gate #include <fs/fs_subr.h>
410Sstevel@tonic-gate
420Sstevel@tonic-gate #include <sys/stream.h>
430Sstevel@tonic-gate #include <sys/socket.h>
440Sstevel@tonic-gate #include <sys/stropts.h>
450Sstevel@tonic-gate #include <sys/socketvar.h>
460Sstevel@tonic-gate
470Sstevel@tonic-gate /*
480Sstevel@tonic-gate * This is the loadable module wrapper.
490Sstevel@tonic-gate */
500Sstevel@tonic-gate #include <sys/modctl.h>
510Sstevel@tonic-gate
520Sstevel@tonic-gate static zone_key_t sockfs_zone_key;
530Sstevel@tonic-gate
540Sstevel@tonic-gate static vfsdef_t vfw = {
550Sstevel@tonic-gate VFSDEF_VERSION,
560Sstevel@tonic-gate "sockfs",
570Sstevel@tonic-gate sockinit,
58*12633Sjohn.levon@sun.com VSW_ZMOUNT,
590Sstevel@tonic-gate NULL
600Sstevel@tonic-gate };
610Sstevel@tonic-gate
620Sstevel@tonic-gate extern struct mod_ops mod_fsops;
630Sstevel@tonic-gate
640Sstevel@tonic-gate /*
650Sstevel@tonic-gate * Module linkage information for the kernel.
660Sstevel@tonic-gate */
670Sstevel@tonic-gate static struct modlfs modlfs = {
680Sstevel@tonic-gate &mod_fsops, "filesystem for sockfs", &vfw
690Sstevel@tonic-gate };
700Sstevel@tonic-gate
710Sstevel@tonic-gate static struct modlinkage modlinkage = {
720Sstevel@tonic-gate MODREV_1, (void *)&modlfs, NULL
730Sstevel@tonic-gate };
740Sstevel@tonic-gate
750Sstevel@tonic-gate int
_init(void)760Sstevel@tonic-gate _init(void)
770Sstevel@tonic-gate {
780Sstevel@tonic-gate int ret;
790Sstevel@tonic-gate
800Sstevel@tonic-gate /*
810Sstevel@tonic-gate * We want to be informed each time a zone is created or
820Sstevel@tonic-gate * destroyed in the kernel, so we can maintain per-zone
830Sstevel@tonic-gate * kstat. sock_kstat_init() will also be called for the
840Sstevel@tonic-gate * global zone, without us having to special case it here.
850Sstevel@tonic-gate */
860Sstevel@tonic-gate zone_key_create(&sockfs_zone_key,
870Sstevel@tonic-gate sock_kstat_init, NULL, sock_kstat_fini);
880Sstevel@tonic-gate
890Sstevel@tonic-gate if ((ret = mod_install(&modlinkage)) != 0) {
900Sstevel@tonic-gate (void) zone_key_delete(sockfs_zone_key);
910Sstevel@tonic-gate }
920Sstevel@tonic-gate
930Sstevel@tonic-gate return (ret);
940Sstevel@tonic-gate }
950Sstevel@tonic-gate
960Sstevel@tonic-gate int
_info(struct modinfo * modinfop)970Sstevel@tonic-gate _info(struct modinfo *modinfop)
980Sstevel@tonic-gate {
990Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop));
1000Sstevel@tonic-gate }
1010Sstevel@tonic-gate
1020Sstevel@tonic-gate int
_fini(void)1030Sstevel@tonic-gate _fini(void)
1040Sstevel@tonic-gate {
1050Sstevel@tonic-gate /* zone_key_delete(sockfs_zone_key); - if we were ever to be unloaded */
1060Sstevel@tonic-gate
1070Sstevel@tonic-gate return (EBUSY);
1080Sstevel@tonic-gate }
1090Sstevel@tonic-gate
1100Sstevel@tonic-gate /*
1110Sstevel@tonic-gate * N.B.
1120Sstevel@tonic-gate * No _fini routine. This module cannot be unloaded once loaded.
1130Sstevel@tonic-gate * The NO_UNLOAD_STUB in modstub.s must change if this module ever
1140Sstevel@tonic-gate * is modified to become unloadable.
1150Sstevel@tonic-gate */
116