1 0 stevel /* 2 0 stevel * CDDL HEADER START 3 0 stevel * 4 0 stevel * The contents of this file are subject to the terms of the 5 0 stevel * Common Development and Distribution License, Version 1.0 only 6 0 stevel * (the "License"). You may not use this file except in compliance 7 0 stevel * with the License. 8 0 stevel * 9 0 stevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 0 stevel * or http://www.opensolaris.org/os/licensing. 11 0 stevel * See the License for the specific language governing permissions 12 0 stevel * and limitations under the License. 13 0 stevel * 14 0 stevel * When distributing Covered Code, include this CDDL HEADER in each 15 0 stevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 0 stevel * If applicable, add the following below this CDDL HEADER, with the 17 0 stevel * fields enclosed by brackets "[]" replaced with your own identifying 18 0 stevel * information: Portions Copyright [yyyy] [name of copyright owner] 19 0 stevel * 20 0 stevel * CDDL HEADER END 21 0 stevel */ 22 0 stevel /* 23 0 stevel * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 0 stevel * Use is subject to license terms. 25 0 stevel */ 26 0 stevel 27 0 stevel /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 28 0 stevel /* All Rights Reserved */ 29 0 stevel 30 0 stevel /* 31 0 stevel * Portions of this source code were derived from Berkeley 4.3 BSD 32 0 stevel * under license from the Regents of the University of California. 33 0 stevel */ 34 0 stevel 35 0 stevel #pragma ident "%Z%%M% %I% %E% SMI" 36 0 stevel 37 0 stevel #include <sys/types.h> 38 0 stevel #include <sys/t_lock.h> 39 0 stevel #include <sys/param.h> 40 0 stevel #include <sys/errno.h> 41 0 stevel #include <sys/user.h> 42 0 stevel #include <sys/fstyp.h> 43 0 stevel #include <sys/kmem.h> 44 0 stevel #include <sys/systm.h> 45 0 stevel #include <sys/mount.h> 46 0 stevel #include <sys/vfs.h> 47 0 stevel #include <sys/cred.h> 48 0 stevel #include <sys/vnode.h> 49 0 stevel #include <sys/dnlc.h> 50 0 stevel #include <sys/file.h> 51 0 stevel #include <sys/time.h> 52 0 stevel #include <sys/cmn_err.h> 53 0 stevel #include <sys/swap.h> 54 0 stevel #include <sys/debug.h> 55 0 stevel #include <sys/pathname.h> 56 0 stevel #include <sys/cladm.h> 57 0 stevel 58 0 stevel /* 59 0 stevel * System calls. 60 0 stevel */ 61 0 stevel 62 0 stevel /* 63 0 stevel * "struct mounta" defined in sys/vfs.h. 64 0 stevel */ 65 0 stevel 66 0 stevel /* ARGSUSED */ 67 0 stevel int 68 0 stevel mount(long *lp, rval_t *rp) 69 0 stevel { 70 0 stevel vnode_t *vp = NULL; 71 0 stevel struct vfs *vfsp; /* dummy argument */ 72 0 stevel int error; 73 0 stevel struct mounta *uap; 74 0 stevel #if defined(_LP64) 75 0 stevel struct mounta native; 76 0 stevel 77 0 stevel /* 78 0 stevel * Make a struct mounta if we are DATAMODEL_LP64 79 0 stevel */ 80 0 stevel uap = &native; 81 0 stevel uap->spec = (char *)*lp++; 82 0 stevel uap->dir = (char *)*lp++; 83 0 stevel uap->flags = (int)*lp++; 84 0 stevel uap->fstype = (char *)*lp++; 85 0 stevel uap->dataptr = (char *)*lp++; 86 0 stevel uap->datalen = (int)*lp++; 87 0 stevel uap->optptr = (char *)*lp++; 88 0 stevel uap->optlen = (int)*lp++; 89 0 stevel #else /* !defined(_LP64) */ 90 0 stevel /* 91 0 stevel * 32 bit kernels can take a shortcut and just cast 92 0 stevel * the args array to the structure. 93 0 stevel */ 94 0 stevel uap = (struct mounta *)lp; 95 0 stevel #endif /* _LP64 */ 96 0 stevel /* 97 0 stevel * Resolve second path name (mount point). 98 0 stevel */ 99 0 stevel if (error = lookupname(uap->dir, UIO_USERSPACE, FOLLOW, NULLVPP, &vp)) 100 0 stevel return (set_errno(error)); 101 0 stevel 102 0 stevel /* 103 0 stevel * Some mount flags are disallowed through the system call interface. 104 0 stevel */ 105 0 stevel uap->flags &= MS_MASK; 106 0 stevel 107 0 stevel if ((vp->v_flag & VPXFS) && ((uap->flags & MS_GLOBAL) != MS_GLOBAL)) { 108 0 stevel /* 109 0 stevel * Clustering: if we're doing a mount onto the global 110 0 stevel * namespace, and the mount is not a global mount, return 111 0 stevel * an error. 112 0 stevel */ 113 0 stevel error = ENOTSUP; 114 0 stevel } else if (uap->flags & MS_GLOBAL) { 115 0 stevel /* 116 0 stevel * Clustering: global mount specified. 117 0 stevel */ 118 0 stevel if ((cluster_bootflags & CLUSTER_BOOTED) == 0) { 119 0 stevel /* 120 0 stevel * If we're not booted as a cluster, 121 0 stevel * global mounts are not allowed. 122 0 stevel */ 123 0 stevel error = ENOTSUP; 124 0 stevel } else { 125 0 stevel error = domount("pxfs", uap, vp, CRED(), &vfsp); 126 0 stevel if (!error) 127 0 stevel VFS_RELE(vfsp); 128 0 stevel } 129 0 stevel } else { 130 0 stevel error = domount(NULL, uap, vp, CRED(), &vfsp); 131 0 stevel if (!error) 132 0 stevel VFS_RELE(vfsp); 133 0 stevel } 134 0 stevel VN_RELE(vp); 135 0 stevel rp->r_val2 = error; 136 0 stevel return (error ? set_errno(error) : 0); 137 0 stevel } 138