xref: /illumos-gate/usr/src/uts/common/os/vfs_conf.c (revision 2d6eb4a5e0a47d30189497241345dc5466bb68ab)
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
5facf4a8dSllai1  * Common Development and Distribution License (the "License").
6facf4a8dSllai1  * 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*4bff34e3Sthurlow  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #include <sys/types.h>
277c478bd9Sstevel@tonic-gate #include <sys/param.h>
287c478bd9Sstevel@tonic-gate #include <sys/vfs.h>
297c478bd9Sstevel@tonic-gate #include <sys/t_lock.h>
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate extern int swapinit(int fstype, char *name);
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /*
347c478bd9Sstevel@tonic-gate  * WARNING: THE POSITIONS OF FILESYSTEM TYPES IN THIS TABLE SHOULD NOT
357c478bd9Sstevel@tonic-gate  * BE CHANGED. These positions are used in generating fsids and
367c478bd9Sstevel@tonic-gate  * fhandles.  Thus, changing positions will cause a server to change
377c478bd9Sstevel@tonic-gate  * the fhandle it gives out for a file.  It is okay to reuse formerly
387c478bd9Sstevel@tonic-gate  * used slots, just be sure that we're not going to start supporting
397c478bd9Sstevel@tonic-gate  * the former owner of the slot again.
407c478bd9Sstevel@tonic-gate  *
417c478bd9Sstevel@tonic-gate  * Since there's been some question about whether the above comment is
427c478bd9Sstevel@tonic-gate  * true, let's provide more detail.  Most filesystems call
437c478bd9Sstevel@tonic-gate  * vfs_make_fsid with two arguments that go into making the fsid: the
447c478bd9Sstevel@tonic-gate  * dev number, and the fs type number - which is the offset of the
457c478bd9Sstevel@tonic-gate  * filesystem's entry in the below table.  If you would like to check
467c478bd9Sstevel@tonic-gate  * if the position of the filesystem in this table still affects the
477c478bd9Sstevel@tonic-gate  * fsid, just check what arguments filesystems are calling
487c478bd9Sstevel@tonic-gate  * vfs_make_fsid with.
497c478bd9Sstevel@tonic-gate  *
507c478bd9Sstevel@tonic-gate  * The scenario we're trying to prevent here is:
517c478bd9Sstevel@tonic-gate  *
527c478bd9Sstevel@tonic-gate  * NFS server gets upgraded to new kernel version with different vfssw
537c478bd9Sstevel@tonic-gate  * Clients are -not- rebooted, still retain filehandles
547c478bd9Sstevel@tonic-gate  * NFS server boots up and now the fsid of an exported fs is different
557c478bd9Sstevel@tonic-gate  *  --> Clients get stale file handle errors
567c478bd9Sstevel@tonic-gate  */
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate struct vfssw vfssw[] = {
597c478bd9Sstevel@tonic-gate 	{ "BADVFS" },				/* invalid */
607c478bd9Sstevel@tonic-gate 	{ "specfs" },				/* SPECFS */
617c478bd9Sstevel@tonic-gate 	{ "ufs" },				/* UFS */
627c478bd9Sstevel@tonic-gate 	{ "fifofs" },				/* FIFOFS */
637c478bd9Sstevel@tonic-gate 	{ "namefs" },				/* NAMEFS */
647c478bd9Sstevel@tonic-gate 	{ "proc" },				/* PROCFS */
657c478bd9Sstevel@tonic-gate 	{ "samfs" },				/* QFS */
667c478bd9Sstevel@tonic-gate 	{ "nfs" },				/* NFS Version 2 */
677c478bd9Sstevel@tonic-gate 	{ "zfs" },				/* ZFS */
687c478bd9Sstevel@tonic-gate 	{ "hsfs" },				/* HSFS */
697c478bd9Sstevel@tonic-gate 	{ "lofs" },				/* LOFS */
707c478bd9Sstevel@tonic-gate 	{ "tmpfs" },				/* TMPFS */
717c478bd9Sstevel@tonic-gate 	{ "fd" },				/* FDFS */
727c478bd9Sstevel@tonic-gate 	{ "pcfs" },				/* PCFS */
737c478bd9Sstevel@tonic-gate 	{ "swapfs", swapinit },			/* SWAPFS */
747c478bd9Sstevel@tonic-gate 	{ "mntfs" },				/* MNTFS */
757c478bd9Sstevel@tonic-gate 	{ "devfs" },				/* DEVFS */
76facf4a8dSllai1 	{ "dev" },				/* DEV */
777c478bd9Sstevel@tonic-gate 	{ "ctfs" },				/* CONTRACTFS */
787c478bd9Sstevel@tonic-gate 	{ "objfs" },				/* OBJFS */
79a237e38eSth199096 	{ "sharefs" },				/* SHAREFS */
80986fd29aSsetje 	{ "dcfs" },				/* DCFS */
81*4bff34e3Sthurlow 	{ "smbfs" },				/* SMBFS */
827c478bd9Sstevel@tonic-gate 	{ "" },					/* reserved for loadable fs */
837c478bd9Sstevel@tonic-gate 	{ "" },
847c478bd9Sstevel@tonic-gate 	{ "" },
857c478bd9Sstevel@tonic-gate 	{ "" },
867c478bd9Sstevel@tonic-gate 	{ "" },
877c478bd9Sstevel@tonic-gate 	{ "" },
887c478bd9Sstevel@tonic-gate 	{ "" },
897c478bd9Sstevel@tonic-gate 	{ "" },
907c478bd9Sstevel@tonic-gate 	{ "" },
917c478bd9Sstevel@tonic-gate 	{ "" },
927c478bd9Sstevel@tonic-gate 	{ "" },
937c478bd9Sstevel@tonic-gate 	{ "" },
947c478bd9Sstevel@tonic-gate 	{ "" },
957c478bd9Sstevel@tonic-gate };
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate const int nfstype = (sizeof (vfssw) / sizeof (vfssw[0]));
98