xref: /illumos-gate/usr/src/uts/common/fs/sockfs/sockvfsops.c (revision 0fbb751d81ab0a7c7ddfd8d4e447e075a9f7024f)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0fbb751dSJohn Levon  * Common Development and Distribution License (the "License").
6*0fbb751dSJohn Levon  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*0fbb751dSJohn Levon  * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
237c478bd9Sstevel@tonic-gate  */
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate #include <sys/types.h>
267c478bd9Sstevel@tonic-gate #include <sys/t_lock.h>
277c478bd9Sstevel@tonic-gate #include <sys/param.h>
287c478bd9Sstevel@tonic-gate #include <sys/systm.h>
297c478bd9Sstevel@tonic-gate #include <sys/buf.h>
307c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
317c478bd9Sstevel@tonic-gate #include <sys/debug.h>
327c478bd9Sstevel@tonic-gate #include <sys/errno.h>
337c478bd9Sstevel@tonic-gate #include <sys/vfs.h>
347c478bd9Sstevel@tonic-gate #include <sys/swap.h>
357c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
367c478bd9Sstevel@tonic-gate #include <sys/cred.h>
377c478bd9Sstevel@tonic-gate #include <sys/thread.h>
387c478bd9Sstevel@tonic-gate #include <sys/zone.h>
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #include <fs/fs_subr.h>
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #include <sys/stream.h>
437c478bd9Sstevel@tonic-gate #include <sys/socket.h>
447c478bd9Sstevel@tonic-gate #include <sys/stropts.h>
457c478bd9Sstevel@tonic-gate #include <sys/socketvar.h>
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate /*
487c478bd9Sstevel@tonic-gate  * This is the loadable module wrapper.
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate static zone_key_t sockfs_zone_key;
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate static vfsdef_t vfw = {
557c478bd9Sstevel@tonic-gate 	VFSDEF_VERSION,
567c478bd9Sstevel@tonic-gate 	"sockfs",
577c478bd9Sstevel@tonic-gate 	sockinit,
58*0fbb751dSJohn Levon 	VSW_ZMOUNT,
597c478bd9Sstevel@tonic-gate 	NULL
607c478bd9Sstevel@tonic-gate };
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate extern struct mod_ops mod_fsops;
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  * Module linkage information for the kernel.
667c478bd9Sstevel@tonic-gate  */
677c478bd9Sstevel@tonic-gate static struct modlfs modlfs = {
687c478bd9Sstevel@tonic-gate 	&mod_fsops, "filesystem for sockfs", &vfw
697c478bd9Sstevel@tonic-gate };
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = {
727c478bd9Sstevel@tonic-gate 	MODREV_1, (void *)&modlfs, NULL
737c478bd9Sstevel@tonic-gate };
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate int
_init(void)767c478bd9Sstevel@tonic-gate _init(void)
777c478bd9Sstevel@tonic-gate {
787c478bd9Sstevel@tonic-gate 	int ret;
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate 	/*
817c478bd9Sstevel@tonic-gate 	 * We want to be informed each time a zone is created or
827c478bd9Sstevel@tonic-gate 	 * destroyed in the kernel, so we can maintain per-zone
837c478bd9Sstevel@tonic-gate 	 * kstat. sock_kstat_init() will also be called for the
847c478bd9Sstevel@tonic-gate 	 * global zone, without us having to special case it here.
857c478bd9Sstevel@tonic-gate 	 */
867c478bd9Sstevel@tonic-gate 	zone_key_create(&sockfs_zone_key,
877c478bd9Sstevel@tonic-gate 	    sock_kstat_init, NULL, sock_kstat_fini);
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate 	if ((ret = mod_install(&modlinkage)) != 0) {
907c478bd9Sstevel@tonic-gate 		(void) zone_key_delete(sockfs_zone_key);
917c478bd9Sstevel@tonic-gate 	}
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate 	return (ret);
947c478bd9Sstevel@tonic-gate }
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate int
_info(struct modinfo * modinfop)977c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop)
987c478bd9Sstevel@tonic-gate {
997c478bd9Sstevel@tonic-gate 	return (mod_info(&modlinkage, modinfop));
1007c478bd9Sstevel@tonic-gate }
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate int
_fini(void)1037c478bd9Sstevel@tonic-gate _fini(void)
1047c478bd9Sstevel@tonic-gate {
1057c478bd9Sstevel@tonic-gate 	/* zone_key_delete(sockfs_zone_key); - if we were ever to be unloaded */
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate 	return (EBUSY);
1087c478bd9Sstevel@tonic-gate }
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate /*
1117c478bd9Sstevel@tonic-gate  * N.B.
1127c478bd9Sstevel@tonic-gate  * No _fini routine. This module cannot be unloaded once loaded.
1137c478bd9Sstevel@tonic-gate  * The NO_UNLOAD_STUB in modstub.s must change if this module ever
1147c478bd9Sstevel@tonic-gate  * is modified to become unloadable.
1157c478bd9Sstevel@tonic-gate  */
116