xref: /onnv-gate/usr/src/uts/common/fs/dev/sdev_vnops.c (revision 12387:e2a7d18f1d90)
12621Sllai1 /*
22621Sllai1  * CDDL HEADER START
32621Sllai1  *
42621Sllai1  * The contents of this file are subject to the terms of the
52621Sllai1  * Common Development and Distribution License (the "License").
62621Sllai1  * You may not use this file except in compliance with the License.
72621Sllai1  *
82621Sllai1  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92621Sllai1  * or http://www.opensolaris.org/os/licensing.
102621Sllai1  * See the License for the specific language governing permissions
112621Sllai1  * and limitations under the License.
122621Sllai1  *
132621Sllai1  * When distributing Covered Code, include this CDDL HEADER in each
142621Sllai1  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152621Sllai1  * If applicable, add the following below this CDDL HEADER, with the
162621Sllai1  * fields enclosed by brackets "[]" replaced with your own identifying
172621Sllai1  * information: Portions Copyright [yyyy] [name of copyright owner]
182621Sllai1  *
192621Sllai1  * CDDL HEADER END
202621Sllai1  */
212621Sllai1 /*
2212273SCasper.Dik@Sun.COM  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
232621Sllai1  */
242621Sllai1 
252621Sllai1 /*
262621Sllai1  * vnode ops for the /dev filesystem
272621Sllai1  *
282621Sllai1  * - VDIR, VCHR, CBLK, and VLNK are considered must supported files
292621Sllai1  * - VREG and VDOOR are used for some internal implementations in
302621Sllai1  *    the global zone, e.g. devname and devfsadm communication
312621Sllai1  * - other file types are unusual in this namespace and
322621Sllai1  *    not supported for now
332621Sllai1  */
342621Sllai1 
352621Sllai1 #include <sys/types.h>
362621Sllai1 #include <sys/param.h>
372621Sllai1 #include <sys/t_lock.h>
382621Sllai1 #include <sys/systm.h>
392621Sllai1 #include <sys/sysmacros.h>
402621Sllai1 #include <sys/user.h>
412621Sllai1 #include <sys/time.h>
422621Sllai1 #include <sys/vfs.h>
432621Sllai1 #include <sys/vnode.h>
443898Srsb #include <sys/vfs_opreg.h>
452621Sllai1 #include <sys/file.h>
462621Sllai1 #include <sys/fcntl.h>
472621Sllai1 #include <sys/flock.h>
482621Sllai1 #include <sys/kmem.h>
492621Sllai1 #include <sys/uio.h>
502621Sllai1 #include <sys/errno.h>
512621Sllai1 #include <sys/stat.h>
522621Sllai1 #include <sys/cred.h>
532621Sllai1 #include <sys/dirent.h>
542621Sllai1 #include <sys/pathname.h>
552621Sllai1 #include <sys/cmn_err.h>
562621Sllai1 #include <sys/debug.h>
572621Sllai1 #include <sys/policy.h>
582621Sllai1 #include <vm/hat.h>
592621Sllai1 #include <vm/seg_vn.h>
602621Sllai1 #include <vm/seg_map.h>
612621Sllai1 #include <vm/seg.h>
622621Sllai1 #include <vm/as.h>
632621Sllai1 #include <vm/page.h>
642621Sllai1 #include <sys/proc.h>
652621Sllai1 #include <sys/mode.h>
662621Sllai1 #include <sys/sunndi.h>
672621Sllai1 #include <sys/ptms.h>
682621Sllai1 #include <fs/fs_subr.h>
692621Sllai1 #include <sys/fs/dv_node.h>
702621Sllai1 #include <sys/fs/sdev_impl.h>
712621Sllai1 
722621Sllai1 /*ARGSUSED*/
732621Sllai1 static int
sdev_open(struct vnode ** vpp,int flag,struct cred * cred,caller_context_t * ct)745331Samw sdev_open(struct vnode **vpp, int flag, struct cred *cred, caller_context_t *ct)
752621Sllai1 {
762621Sllai1 	struct sdev_node *dv = VTOSDEV(*vpp);
772621Sllai1 	struct sdev_node *ddv = dv->sdev_dotdot;
782621Sllai1 	int error = 0;
792621Sllai1 
802621Sllai1 	if ((*vpp)->v_type == VDIR)
812621Sllai1 		return (0);
822621Sllai1 
832621Sllai1 	if (!SDEV_IS_GLOBAL(dv))
842621Sllai1 		return (ENOTSUP);
852621Sllai1 
8610588SEric.Taylor@Sun.COM 	if ((*vpp)->v_type == VLNK)
8710588SEric.Taylor@Sun.COM 		return (ENOENT);
882621Sllai1 	ASSERT((*vpp)->v_type == VREG);
892621Sllai1 	if ((*vpp)->v_type != VREG)
902621Sllai1 		return (ENOTSUP);
912621Sllai1 
922621Sllai1 	ASSERT(ddv);
932621Sllai1 	rw_enter(&ddv->sdev_contents, RW_READER);
942621Sllai1 	if (dv->sdev_attrvp == NULL) {
952621Sllai1 		rw_exit(&ddv->sdev_contents);
962621Sllai1 		return (ENOENT);
972621Sllai1 	}
985331Samw 	error = VOP_OPEN(&(dv->sdev_attrvp), flag, cred, ct);
992621Sllai1 	rw_exit(&ddv->sdev_contents);
1002621Sllai1 	return (error);
1012621Sllai1 }
1022621Sllai1 
1032621Sllai1 /*ARGSUSED1*/
1042621Sllai1 static int
sdev_close(struct vnode * vp,int flag,int count,offset_t offset,struct cred * cred,caller_context_t * ct)1052621Sllai1 sdev_close(struct vnode *vp, int flag, int count,
1065331Samw     offset_t offset, struct cred *cred, caller_context_t *ct)
1072621Sllai1 {
1082621Sllai1 	struct sdev_node *dv = VTOSDEV(vp);
1092621Sllai1 
1102621Sllai1 	if (vp->v_type == VDIR) {
1112621Sllai1 		cleanlocks(vp, ttoproc(curthread)->p_pid, 0);
1122621Sllai1 		cleanshares(vp, ttoproc(curthread)->p_pid);
1132621Sllai1 		return (0);
1142621Sllai1 	}
1152621Sllai1 
1162621Sllai1 	if (!SDEV_IS_GLOBAL(dv))
1172621Sllai1 		return (ENOTSUP);
1182621Sllai1 
1192621Sllai1 	ASSERT(vp->v_type == VREG);
1202621Sllai1 	if (vp->v_type != VREG)
1212621Sllai1 		return (ENOTSUP);
1222621Sllai1 
1232621Sllai1 	ASSERT(dv->sdev_attrvp);
1245331Samw 	return (VOP_CLOSE(dv->sdev_attrvp, flag, count, offset, cred, ct));
1252621Sllai1 }
1262621Sllai1 
1272621Sllai1 /*ARGSUSED*/
1282621Sllai1 static int
sdev_read(struct vnode * vp,struct uio * uio,int ioflag,struct cred * cred,struct caller_context * ct)1292621Sllai1 sdev_read(struct vnode *vp, struct uio *uio, int ioflag, struct cred *cred,
1302621Sllai1 	struct caller_context *ct)
1312621Sllai1 {
1322621Sllai1 	struct sdev_node *dv = (struct sdev_node *)VTOSDEV(vp);
1332621Sllai1 	int	error;
1342621Sllai1 
1352621Sllai1 	if (!SDEV_IS_GLOBAL(dv))
1362621Sllai1 		return (EINVAL);
1372621Sllai1 
1382621Sllai1 	if (vp->v_type == VDIR)
1392621Sllai1 		return (EISDIR);
1402621Sllai1 
1412621Sllai1 	/* only supporting regular files in /dev */
1422621Sllai1 	ASSERT(vp->v_type == VREG);
1432621Sllai1 	if (vp->v_type != VREG)
1442621Sllai1 		return (EINVAL);
1452621Sllai1 
1462621Sllai1 	ASSERT(RW_READ_HELD(&VTOSDEV(vp)->sdev_contents));
1472621Sllai1 	ASSERT(dv->sdev_attrvp);
1485331Samw 	(void) VOP_RWLOCK(dv->sdev_attrvp, 0, ct);
1492621Sllai1 	error = VOP_READ(dv->sdev_attrvp, uio, ioflag, cred, ct);
1505331Samw 	VOP_RWUNLOCK(dv->sdev_attrvp, 0, ct);
1512621Sllai1 	return (error);
1522621Sllai1 }
1532621Sllai1 
1542621Sllai1 /*ARGSUSED*/
1552621Sllai1 static int
sdev_write(struct vnode * vp,struct uio * uio,int ioflag,struct cred * cred,struct caller_context * ct)1562621Sllai1 sdev_write(struct vnode *vp, struct uio *uio, int ioflag, struct cred *cred,
1572621Sllai1 	struct caller_context *ct)
1582621Sllai1 {
1592621Sllai1 	struct sdev_node *dv = VTOSDEV(vp);
1602621Sllai1 	int	error = 0;
1612621Sllai1 
1622621Sllai1 	if (!SDEV_IS_GLOBAL(dv))
1632621Sllai1 		return (EINVAL);
1642621Sllai1 
1652621Sllai1 	if (vp->v_type == VDIR)
1662621Sllai1 		return (EISDIR);
1672621Sllai1 
1682621Sllai1 	/* only supporting regular files in /dev */
1692621Sllai1 	ASSERT(vp->v_type == VREG);
1702621Sllai1 	if (vp->v_type != VREG)
1712621Sllai1 		return (EINVAL);
1722621Sllai1 
1732621Sllai1 	ASSERT(dv->sdev_attrvp);
1742621Sllai1 
1755331Samw 	(void) VOP_RWLOCK(dv->sdev_attrvp, 1, ct);
1762621Sllai1 	error = VOP_WRITE(dv->sdev_attrvp, uio, ioflag, cred, ct);
1775331Samw 	VOP_RWUNLOCK(dv->sdev_attrvp, 1, ct);
1782621Sllai1 	if (error == 0) {
1792621Sllai1 		sdev_update_timestamps(dv->sdev_attrvp, kcred,
1802621Sllai1 		    AT_MTIME);
1812621Sllai1 	}
1822621Sllai1 	return (error);
1832621Sllai1 }
1842621Sllai1 
1852621Sllai1 /*ARGSUSED*/
1862621Sllai1 static int
sdev_ioctl(struct vnode * vp,int cmd,intptr_t arg,int flag,struct cred * cred,int * rvalp,caller_context_t * ct)1872621Sllai1 sdev_ioctl(struct vnode *vp, int cmd, intptr_t arg, int flag,
1885331Samw     struct cred *cred, int *rvalp,  caller_context_t *ct)
1892621Sllai1 {
1902621Sllai1 	struct sdev_node *dv = VTOSDEV(vp);
1912621Sllai1 
1922621Sllai1 	if (!SDEV_IS_GLOBAL(dv) || (vp->v_type == VDIR))
1932621Sllai1 		return (ENOTTY);
1942621Sllai1 
1952621Sllai1 	ASSERT(vp->v_type == VREG);
1962621Sllai1 	if (vp->v_type != VREG)
1972621Sllai1 		return (EINVAL);
1982621Sllai1 
1992621Sllai1 	ASSERT(dv->sdev_attrvp);
2005331Samw 	return (VOP_IOCTL(dv->sdev_attrvp, cmd, arg, flag, cred, rvalp, ct));
2012621Sllai1 }
2022621Sllai1 
2032621Sllai1 static int
sdev_getattr(struct vnode * vp,struct vattr * vap,int flags,struct cred * cr,caller_context_t * ct)2045331Samw sdev_getattr(struct vnode *vp, struct vattr *vap, int flags,
2055331Samw     struct cred *cr, caller_context_t *ct)
2062621Sllai1 {
2072621Sllai1 	int			error = 0;
2082621Sllai1 	struct sdev_node	*dv = VTOSDEV(vp);
2092621Sllai1 	struct sdev_node	*parent = dv->sdev_dotdot;
2102621Sllai1 
2112621Sllai1 	ASSERT(parent);
2122621Sllai1 
2132621Sllai1 	rw_enter(&parent->sdev_contents, RW_READER);
2142621Sllai1 	ASSERT(dv->sdev_attr || dv->sdev_attrvp);
2152621Sllai1 
2162621Sllai1 	/*
2172621Sllai1 	 * search order:
2182621Sllai1 	 * 	- for persistent nodes (SDEV_PERSIST): backstore
2192621Sllai1 	 *	- for non-persistent nodes: module ops if global, then memory
2202621Sllai1 	 */
2212621Sllai1 	if (dv->sdev_attrvp) {
2222621Sllai1 		rw_exit(&parent->sdev_contents);
2235331Samw 		error = VOP_GETATTR(dv->sdev_attrvp, vap, flags, cr, ct);
2242621Sllai1 		sdev_vattr_merge(dv, vap);
2252621Sllai1 	} else {
2262621Sllai1 		ASSERT(dv->sdev_attr);
2272621Sllai1 		*vap = *dv->sdev_attr;
2282621Sllai1 		sdev_vattr_merge(dv, vap);
2292621Sllai1 		rw_exit(&parent->sdev_contents);
2302621Sllai1 	}
2312621Sllai1 
2322621Sllai1 	return (error);
2332621Sllai1 }
2342621Sllai1 
2353748Sjg /*ARGSUSED4*/
2362621Sllai1 static int
sdev_setattr(struct vnode * vp,struct vattr * vap,int flags,struct cred * cred,caller_context_t * ctp)2373748Sjg sdev_setattr(struct vnode *vp, struct vattr *vap, int flags,
2383748Sjg     struct cred *cred, caller_context_t *ctp)
2392621Sllai1 {
2402621Sllai1 	return (devname_setattr_func(vp, vap, flags, cred, NULL, 0));
2412621Sllai1 }
2422621Sllai1 
2432621Sllai1 static int
sdev_getsecattr(struct vnode * vp,struct vsecattr * vsap,int flags,struct cred * cr,caller_context_t * ct)2442621Sllai1 sdev_getsecattr(struct vnode *vp, struct vsecattr *vsap, int flags,
2455331Samw     struct cred *cr, caller_context_t *ct)
2462621Sllai1 {
2472621Sllai1 	int	error;
2482621Sllai1 	struct sdev_node *dv = VTOSDEV(vp);
2492621Sllai1 	struct vnode *avp = dv->sdev_attrvp;
2502621Sllai1 
2512621Sllai1 	if (avp == NULL) {
2522621Sllai1 		/* return fs_fab_acl() if flavor matches, else do nothing */
2532621Sllai1 		if ((SDEV_ACL_FLAVOR(vp) == _ACL_ACLENT_ENABLED &&
2542621Sllai1 		    (vsap->vsa_mask & (VSA_ACLCNT | VSA_DFACLCNT))) ||
2552621Sllai1 		    (SDEV_ACL_FLAVOR(vp) == _ACL_ACE_ENABLED &&
2562621Sllai1 		    (vsap->vsa_mask & (VSA_ACECNT | VSA_ACE))))
2575331Samw 			return (fs_fab_acl(vp, vsap, flags, cr, ct));
2582621Sllai1 
2592621Sllai1 		return (ENOSYS);
2602621Sllai1 	}
2612621Sllai1 
2625331Samw 	(void) VOP_RWLOCK(avp, 1, ct);
2635331Samw 	error = VOP_GETSECATTR(avp, vsap, flags, cr, ct);
2645331Samw 	VOP_RWUNLOCK(avp, 1, ct);
2652621Sllai1 	return (error);
2662621Sllai1 }
2672621Sllai1 
2682621Sllai1 static int
sdev_setsecattr(struct vnode * vp,struct vsecattr * vsap,int flags,struct cred * cr,caller_context_t * ct)2692621Sllai1 sdev_setsecattr(struct vnode *vp, struct vsecattr *vsap, int flags,
2705331Samw     struct cred *cr, caller_context_t *ct)
2712621Sllai1 {
2722621Sllai1 	int	error;
2732621Sllai1 	struct sdev_node *dv = VTOSDEV(vp);
2742621Sllai1 	struct vnode *avp = dv->sdev_attrvp;
2752621Sllai1 
2762621Sllai1 	if (dv->sdev_state == SDEV_ZOMBIE)
2772621Sllai1 		return (0);
2782621Sllai1 
2792621Sllai1 	if (avp == NULL) {
2802621Sllai1 		if (SDEV_IS_GLOBAL(dv) && !SDEV_IS_PERSIST(dv))
2812621Sllai1 			return (fs_nosys());
2822621Sllai1 		ASSERT(dv->sdev_attr);
2832621Sllai1 		/*
2842621Sllai1 		 * if coming in directly, the acl system call will
2852621Sllai1 		 * have held the read-write lock via VOP_RWLOCK()
2862621Sllai1 		 * If coming in via specfs, specfs will have
2872621Sllai1 		 * held the rw lock on the realvp i.e. us.
2882621Sllai1 		 */
2892621Sllai1 		ASSERT(RW_WRITE_HELD(&dv->sdev_contents));
2902621Sllai1 		sdev_vattr_merge(dv, dv->sdev_attr);
2915331Samw 		error = sdev_shadow_node(dv, cr);
2922621Sllai1 		if (error) {
2932621Sllai1 			return (fs_nosys());
2942621Sllai1 		}
2952621Sllai1 
2962621Sllai1 		ASSERT(dv->sdev_attrvp);
2972621Sllai1 		/* clean out the memory copy if any */
2982621Sllai1 		if (dv->sdev_attr) {
2992621Sllai1 			kmem_free(dv->sdev_attr, sizeof (struct vattr));
3002621Sllai1 			dv->sdev_attr = NULL;
3012621Sllai1 		}
3022621Sllai1 		avp = dv->sdev_attrvp;
3032621Sllai1 	}
3042621Sllai1 	ASSERT(avp);
3052621Sllai1 
3065331Samw 	(void) VOP_RWLOCK(avp, V_WRITELOCK_TRUE, ct);
3075331Samw 	error = VOP_SETSECATTR(avp, vsap, flags, cr, ct);
3085331Samw 	VOP_RWUNLOCK(avp, V_WRITELOCK_TRUE, ct);
3092621Sllai1 	return (error);
3102621Sllai1 }
3112621Sllai1 
3122621Sllai1 int
sdev_unlocked_access(void * vdv,int mode,struct cred * cr)3132621Sllai1 sdev_unlocked_access(void *vdv, int mode, struct cred *cr)
3142621Sllai1 {
3152621Sllai1 	struct sdev_node	*dv = vdv;
3162621Sllai1 	int			shift = 0;
3172621Sllai1 	uid_t			owner = dv->sdev_attr->va_uid;
3182621Sllai1 
3192621Sllai1 	if (crgetuid(cr) != owner) {
3202621Sllai1 		shift += 3;
3212621Sllai1 		if (groupmember(dv->sdev_attr->va_gid, cr) == 0)
3222621Sllai1 			shift += 3;
3232621Sllai1 	}
3242621Sllai1 
32512273SCasper.Dik@Sun.COM 	return (secpolicy_vnode_access2(cr, SDEVTOV(dv), owner,
32612273SCasper.Dik@Sun.COM 	    dv->sdev_attr->va_mode << shift, mode));
3272621Sllai1 }
3282621Sllai1 
3292621Sllai1 static int
sdev_access(struct vnode * vp,int mode,int flags,struct cred * cr,caller_context_t * ct)3305331Samw sdev_access(struct vnode *vp, int mode, int flags, struct cred *cr,
3315331Samw     caller_context_t *ct)
3322621Sllai1 {
3332621Sllai1 	struct sdev_node	*dv = VTOSDEV(vp);
3342621Sllai1 	int ret = 0;
3352621Sllai1 
3362621Sllai1 	ASSERT(dv->sdev_attr || dv->sdev_attrvp);
3372621Sllai1 
3382621Sllai1 	if (dv->sdev_attrvp) {
3395331Samw 		ret = VOP_ACCESS(dv->sdev_attrvp, mode, flags, cr, ct);
3402621Sllai1 	} else if (dv->sdev_attr) {
3412621Sllai1 		rw_enter(&dv->sdev_contents, RW_READER);
3422621Sllai1 		ret = sdev_unlocked_access(dv, mode, cr);
3432621Sllai1 		if (ret)
3442621Sllai1 			ret = EACCES;
3452621Sllai1 		rw_exit(&dv->sdev_contents);
3462621Sllai1 	}
3472621Sllai1 
3482621Sllai1 	return (ret);
3492621Sllai1 }
3502621Sllai1 
3512621Sllai1 /*
3522621Sllai1  * Lookup
3532621Sllai1  */
3542621Sllai1 /*ARGSUSED3*/
3552621Sllai1 static int
sdev_lookup(struct vnode * dvp,char * nm,struct vnode ** vpp,struct pathname * pnp,int flags,struct vnode * rdir,struct cred * cred,caller_context_t * ct,int * direntflags,pathname_t * realpnp)3562621Sllai1 sdev_lookup(struct vnode *dvp, char *nm, struct vnode **vpp,
3575331Samw     struct pathname *pnp, int flags, struct vnode *rdir, struct cred *cred,
3585331Samw     caller_context_t *ct, int *direntflags, pathname_t *realpnp)
3592621Sllai1 {
3603843Sjg 	struct sdev_node *parent;
3613843Sjg 	int error;
3622621Sllai1 
3632621Sllai1 	parent = VTOSDEV(dvp);
3642621Sllai1 	ASSERT(parent);
3652621Sllai1 
3663843Sjg 	/* execute access is required to search the directory */
3675331Samw 	if ((error = VOP_ACCESS(dvp, VEXEC, 0, cred, ct)) != 0)
3683843Sjg 		return (error);
3693843Sjg 
3702621Sllai1 	if (!SDEV_IS_GLOBAL(parent))
3712621Sllai1 		return (prof_lookup(dvp, nm, vpp, cred));
3722621Sllai1 	return (devname_lookup_func(parent, nm, vpp, cred, NULL, 0));
3732621Sllai1 }
3742621Sllai1 
3752621Sllai1 /*ARGSUSED2*/
3762621Sllai1 static int
sdev_create(struct vnode * dvp,char * nm,struct vattr * vap,vcexcl_t excl,int mode,struct vnode ** vpp,struct cred * cred,int flag,caller_context_t * ct,vsecattr_t * vsecp)3772621Sllai1 sdev_create(struct vnode *dvp, char *nm, struct vattr *vap, vcexcl_t excl,
3785331Samw     int mode, struct vnode **vpp, struct cred *cred, int flag,
3795331Samw     caller_context_t *ct, vsecattr_t *vsecp)
3802621Sllai1 {
3812621Sllai1 	struct vnode		*vp = NULL;
3822621Sllai1 	struct vnode		*avp;
3832621Sllai1 	struct sdev_node	*parent;
3842621Sllai1 	struct sdev_node	*self = NULL;
3852621Sllai1 	int			error = 0;
3862621Sllai1 	vtype_t			type = vap->va_type;
3872621Sllai1 
3882729Sllai1 	ASSERT(type != VNON && type != VBAD);
3892621Sllai1 
3902621Sllai1 	if ((type == VFIFO) || (type == VSOCK) ||
3912621Sllai1 	    (type == VPROC) || (type == VPORT))
3922621Sllai1 		return (ENOTSUP);
3932621Sllai1 
3942621Sllai1 	parent = VTOSDEV(dvp);
3952621Sllai1 	ASSERT(parent);
3962621Sllai1 
3972621Sllai1 	rw_enter(&parent->sdev_dotdot->sdev_contents, RW_READER);
3982621Sllai1 	if (parent->sdev_state == SDEV_ZOMBIE) {
3992621Sllai1 		rw_exit(&parent->sdev_dotdot->sdev_contents);
4002621Sllai1 		return (ENOENT);
4012621Sllai1 	}
4022621Sllai1 
4032621Sllai1 	/* non-global do not allow pure node creation */
4042621Sllai1 	if (!SDEV_IS_GLOBAL(parent)) {
4052621Sllai1 		rw_exit(&parent->sdev_dotdot->sdev_contents);
4062621Sllai1 		return (prof_lookup(dvp, nm, vpp, cred));
4072621Sllai1 	}
4082621Sllai1 	rw_exit(&parent->sdev_dotdot->sdev_contents);
4092621Sllai1 
4103843Sjg 	/* execute access is required to search the directory */
4119198SJerry.Gilliam@Sun.COM 	if ((error = VOP_ACCESS(dvp, VEXEC, 0, cred, ct)) != 0)
4123843Sjg 		return (error);
4133843Sjg 
4142621Sllai1 	/* check existing name */
4155331Samw /* XXXci - We may need to translate the C-I flags on VOP_LOOKUP */
4165331Samw 	error = VOP_LOOKUP(dvp, nm, &vp, NULL, 0, NULL, cred, ct, NULL, NULL);
4172621Sllai1 
4182621Sllai1 	/* name found */
4192621Sllai1 	if (error == 0) {
4202621Sllai1 		ASSERT(vp);
4212621Sllai1 		if (excl == EXCL) {
4222621Sllai1 			error = EEXIST;
4232621Sllai1 		} else if ((vp->v_type == VDIR) && (mode & VWRITE)) {
4242621Sllai1 			/* allowing create/read-only an existing directory */
4252621Sllai1 			error = EISDIR;
4262621Sllai1 		} else {
4275686Sjg 			error = VOP_ACCESS(vp, mode, 0, cred, ct);
4282621Sllai1 		}
4292621Sllai1 
4302621Sllai1 		if (error) {
4312621Sllai1 			VN_RELE(vp);
4322621Sllai1 			return (error);
4332621Sllai1 		}
4342621Sllai1 
4352621Sllai1 		/* truncation first */
4362621Sllai1 		if ((vp->v_type == VREG) && (vap->va_mask & AT_SIZE) &&
4372621Sllai1 		    (vap->va_size == 0)) {
4382621Sllai1 			ASSERT(parent->sdev_attrvp);
4392621Sllai1 			error = VOP_CREATE(parent->sdev_attrvp,
4405331Samw 			    nm, vap, excl, mode, &avp, cred, flag, ct, vsecp);
4412621Sllai1 
4422621Sllai1 			if (error) {
4432621Sllai1 				VN_RELE(vp);
4442621Sllai1 				return (error);
4452621Sllai1 			}
4462621Sllai1 		}
4472621Sllai1 
4482621Sllai1 		sdev_update_timestamps(vp, kcred,
4492621Sllai1 		    AT_CTIME|AT_MTIME|AT_ATIME);
4502621Sllai1 		*vpp = vp;
4512621Sllai1 		return (0);
4522621Sllai1 	}
4532621Sllai1 
4542621Sllai1 	/* bail out early */
4552621Sllai1 	if (error != ENOENT)
4562621Sllai1 		return (error);
4572621Sllai1 
4589198SJerry.Gilliam@Sun.COM 	/* verify write access - compliance specifies ENXIO */
4599198SJerry.Gilliam@Sun.COM 	if ((error = VOP_ACCESS(dvp, VEXEC|VWRITE, 0, cred, ct)) != 0) {
4609198SJerry.Gilliam@Sun.COM 		if (error == EACCES)
4619198SJerry.Gilliam@Sun.COM 			error = ENXIO;
4629198SJerry.Gilliam@Sun.COM 		return (error);
4639198SJerry.Gilliam@Sun.COM 	}
4649198SJerry.Gilliam@Sun.COM 
4652621Sllai1 	/*
4662621Sllai1 	 * For memory-based (ROFS) directory:
4672621Sllai1 	 * 	- either disallow node creation;
4682621Sllai1 	 *	- or implement VOP_CREATE of its own
4692621Sllai1 	 */
4702621Sllai1 	rw_enter(&parent->sdev_contents, RW_WRITER);
4712621Sllai1 	if (!SDEV_IS_PERSIST(parent)) {
4722621Sllai1 		rw_exit(&parent->sdev_contents);
4732621Sllai1 		return (ENOTSUP);
4742621Sllai1 	}
4752621Sllai1 	ASSERT(parent->sdev_attrvp);
4762621Sllai1 	error = sdev_mknode(parent, nm, &self, vap, NULL, NULL,
4772621Sllai1 	    cred, SDEV_READY);
4782621Sllai1 	if (error) {
4792621Sllai1 		rw_exit(&parent->sdev_contents);
4802621Sllai1 		if (self)
4812621Sllai1 			SDEV_RELE(self);
4822621Sllai1 		return (error);
4832621Sllai1 	}
4842621Sllai1 	rw_exit(&parent->sdev_contents);
4852621Sllai1 
4862621Sllai1 	ASSERT(self);
4872621Sllai1 	/* take care the timestamps for the node and its parent */
4882621Sllai1 	sdev_update_timestamps(SDEVTOV(self), kcred,
4892621Sllai1 	    AT_CTIME|AT_MTIME|AT_ATIME);
4902621Sllai1 	sdev_update_timestamps(dvp, kcred, AT_MTIME|AT_ATIME);
4912621Sllai1 	if (SDEV_IS_GLOBAL(parent))
4922621Sllai1 		atomic_inc_ulong(&parent->sdev_gdir_gen);
4932621Sllai1 
4942621Sllai1 	/* wake up other threads blocked on looking up this node */
4952621Sllai1 	mutex_enter(&self->sdev_lookup_lock);
4962621Sllai1 	SDEV_UNBLOCK_OTHERS(self, SDEV_LOOKUP);
4972621Sllai1 	mutex_exit(&self->sdev_lookup_lock);
4982621Sllai1 	error = sdev_to_vp(self, vpp);
4992621Sllai1 	return (error);
5002621Sllai1 }
5012621Sllai1 
5022621Sllai1 static int
sdev_remove(struct vnode * dvp,char * nm,struct cred * cred,caller_context_t * ct,int flags)5035331Samw sdev_remove(struct vnode *dvp, char *nm, struct cred *cred,
5045331Samw     caller_context_t *ct, int flags)
5052621Sllai1 {
5062621Sllai1 	int	error;
5072621Sllai1 	struct sdev_node *parent = (struct sdev_node *)VTOSDEV(dvp);
5082621Sllai1 	struct vnode *vp = NULL;
5092621Sllai1 	struct sdev_node *dv = NULL;
5102621Sllai1 	int len;
511*12387SJerry.Gilliam@Sun.COM 	int bkstore;
5122621Sllai1 
5132621Sllai1 	/* bail out early */
5142621Sllai1 	len = strlen(nm);
5152621Sllai1 	if (nm[0] == '.') {
5162621Sllai1 		if (len == 1) {
5172621Sllai1 			return (EINVAL);
5182621Sllai1 		} else if (len == 2 && nm[1] == '.') {
5192621Sllai1 			return (EEXIST);
5202621Sllai1 		}
5212621Sllai1 	}
5222621Sllai1 
5232621Sllai1 	ASSERT(parent);
5242621Sllai1 	rw_enter(&parent->sdev_contents, RW_READER);
5252621Sllai1 	if (!SDEV_IS_GLOBAL(parent)) {
5262621Sllai1 		rw_exit(&parent->sdev_contents);
5272621Sllai1 		return (ENOTSUP);
5282621Sllai1 	}
5292621Sllai1 
5303843Sjg 	/* execute access is required to search the directory */
5315331Samw 	if ((error = VOP_ACCESS(dvp, VEXEC, 0, cred, ct)) != 0) {
5323843Sjg 		rw_exit(&parent->sdev_contents);
5333843Sjg 		return (error);
5343843Sjg 	}
5353843Sjg 
5362621Sllai1 	/* check existence first */
5372621Sllai1 	dv = sdev_cache_lookup(parent, nm);
5382621Sllai1 	if (dv == NULL) {
5392621Sllai1 		rw_exit(&parent->sdev_contents);
5402621Sllai1 		return (ENOENT);
5412621Sllai1 	}
5422621Sllai1 
5432621Sllai1 	vp = SDEVTOV(dv);
5442621Sllai1 	if ((dv->sdev_state == SDEV_INIT) ||
5452621Sllai1 	    (dv->sdev_state == SDEV_ZOMBIE)) {
5462621Sllai1 		rw_exit(&parent->sdev_contents);
5472621Sllai1 		VN_RELE(vp);
5482621Sllai1 		return (ENOENT);
5492621Sllai1 	}
5502621Sllai1 
5513843Sjg 	/* write access is required to remove an entry */
5525331Samw 	if ((error = VOP_ACCESS(dvp, VWRITE, 0, cred, ct)) != 0) {
5533843Sjg 		rw_exit(&parent->sdev_contents);
5543843Sjg 		VN_RELE(vp);
5553843Sjg 		return (error);
5563843Sjg 	}
5573843Sjg 
558*12387SJerry.Gilliam@Sun.COM 	bkstore = SDEV_IS_PERSIST(dv) ? 1 : 0;
559*12387SJerry.Gilliam@Sun.COM 	if (!rw_tryupgrade(&parent->sdev_contents)) {
560*12387SJerry.Gilliam@Sun.COM 		rw_exit(&parent->sdev_contents);
561*12387SJerry.Gilliam@Sun.COM 		rw_enter(&parent->sdev_contents, RW_WRITER);
562*12387SJerry.Gilliam@Sun.COM 	}
563*12387SJerry.Gilliam@Sun.COM 
564*12387SJerry.Gilliam@Sun.COM 	/* we do not support unlinking a non-empty directory */
565*12387SJerry.Gilliam@Sun.COM 	if (vp->v_type == VDIR && dv->sdev_nlink > 2) {
566*12387SJerry.Gilliam@Sun.COM 		rw_exit(&parent->sdev_contents);
567*12387SJerry.Gilliam@Sun.COM 		VN_RELE(vp);
568*12387SJerry.Gilliam@Sun.COM 		return (EBUSY);
569*12387SJerry.Gilliam@Sun.COM 	}
570*12387SJerry.Gilliam@Sun.COM 
5712621Sllai1 	/*
5722621Sllai1 	 * sdev_dirdelete does the real job of:
5732621Sllai1 	 *  - make sure no open ref count
5742621Sllai1 	 *  - destroying the sdev_node
5752621Sllai1 	 *  - releasing the hold on attrvp
5762621Sllai1 	 */
5772621Sllai1 	error = sdev_cache_update(parent, &dv, nm, SDEV_CACHE_DELETE);
5782621Sllai1 	rw_exit(&parent->sdev_contents);
5792621Sllai1 
5802621Sllai1 	sdcmn_err2(("sdev_remove: cache_update error %d\n", error));
5812621Sllai1 	if (error && (error != EBUSY)) {
5822621Sllai1 		/* report errors other than EBUSY */
5832621Sllai1 		VN_RELE(vp);
5842621Sllai1 	} else {
5852621Sllai1 		sdcmn_err2(("sdev_remove: cleaning node %s from cache "
5862621Sllai1 		    " with error %d\n", nm, error));
5872621Sllai1 
5882621Sllai1 		/*
5892621Sllai1 		 * best efforts clean up the backing store
5902621Sllai1 		 */
5912621Sllai1 		if (bkstore) {
5922621Sllai1 			ASSERT(parent->sdev_attrvp);
5935331Samw 			error = VOP_REMOVE(parent->sdev_attrvp, nm, cred,
5945331Samw 			    ct, flags);
5952621Sllai1 			/*
5962621Sllai1 			 * do not report BUSY error
5972621Sllai1 			 * because the backing store ref count is released
5982621Sllai1 			 * when the last ref count on the sdev_node is
5992621Sllai1 			 * released.
6002621Sllai1 			 */
6012621Sllai1 			if (error == EBUSY) {
6022621Sllai1 				sdcmn_err2(("sdev_remove: device %s is still on"
6032621Sllai1 				    "disk %s\n", nm, parent->sdev_path));
6042621Sllai1 				error = 0;
6052621Sllai1 			}
6062621Sllai1 		}
6072621Sllai1 
6082621Sllai1 		if (error == EBUSY)
6092621Sllai1 			error = 0;
6102621Sllai1 	}
6112621Sllai1 
6122621Sllai1 	return (error);
6132621Sllai1 }
6142621Sllai1 
6152621Sllai1 /*
6162621Sllai1  * Some restrictions for this file system:
6172621Sllai1  *  - both oldnm and newnm are in the scope of /dev file system,
6182621Sllai1  *    to simply the namespace management model.
6192621Sllai1  */
6205331Samw /*ARGSUSED6*/
6212621Sllai1 static int
sdev_rename(struct vnode * odvp,char * onm,struct vnode * ndvp,char * nnm,struct cred * cred,caller_context_t * ct,int flags)6222621Sllai1 sdev_rename(struct vnode *odvp, char *onm, struct vnode *ndvp, char *nnm,
6235331Samw     struct cred *cred, caller_context_t *ct, int flags)
6242621Sllai1 {
6252621Sllai1 	struct sdev_node	*fromparent = NULL;
6262621Sllai1 	struct vattr		vattr;
6272621Sllai1 	struct sdev_node	*toparent;
6282621Sllai1 	struct sdev_node	*fromdv = NULL;	/* source node */
6292729Sllai1 	struct vnode 		*ovp = NULL;	/* source vnode */
6302621Sllai1 	struct sdev_node	*todv = NULL;	/* destination node */
6312729Sllai1 	struct vnode 		*nvp = NULL;	/* destination vnode */
6322621Sllai1 	int			samedir = 0;	/* set if odvp == ndvp */
6332621Sllai1 	struct vnode		*realvp;
6342621Sllai1 	int error = 0;
6352621Sllai1 	dev_t fsid;
6362621Sllai1 	int bkstore = 0;
6372729Sllai1 	vtype_t type;
6382621Sllai1 
6392621Sllai1 	/* prevent modifying "." and ".." */
6402621Sllai1 	if ((onm[0] == '.' &&
6412729Sllai1 	    (onm[1] == '\0' || (onm[1] == '.' && onm[2] == '\0'))) ||
6422729Sllai1 	    (nnm[0] == '.' &&
6432729Sllai1 	    (nnm[1] == '\0' || (nnm[1] == '.' && nnm[2] == '\0')))) {
6442621Sllai1 		return (EINVAL);
6452621Sllai1 	}
6462621Sllai1 
6472621Sllai1 	fromparent = VTOSDEV(odvp);
6482621Sllai1 	toparent = VTOSDEV(ndvp);
6492621Sllai1 
6502621Sllai1 	/* ZOMBIE parent doesn't allow new node creation */
6512621Sllai1 	rw_enter(&fromparent->sdev_dotdot->sdev_contents, RW_READER);
6522621Sllai1 	if (fromparent->sdev_state == SDEV_ZOMBIE) {
6532621Sllai1 		rw_exit(&fromparent->sdev_dotdot->sdev_contents);
6542621Sllai1 		return (ENOENT);
6552621Sllai1 	}
6562621Sllai1 
6572621Sllai1 	/* renaming only supported for global device nodes */
6582621Sllai1 	if (!SDEV_IS_GLOBAL(fromparent)) {
6592621Sllai1 		rw_exit(&fromparent->sdev_dotdot->sdev_contents);
6602621Sllai1 		return (ENOTSUP);
6612621Sllai1 	}
6622621Sllai1 	rw_exit(&fromparent->sdev_dotdot->sdev_contents);
6632621Sllai1 
6642621Sllai1 	rw_enter(&toparent->sdev_dotdot->sdev_contents, RW_READER);
6652621Sllai1 	if (toparent->sdev_state == SDEV_ZOMBIE) {
6662621Sllai1 		rw_exit(&toparent->sdev_dotdot->sdev_contents);
6672621Sllai1 		return (ENOENT);
6682621Sllai1 	}
6692621Sllai1 	rw_exit(&toparent->sdev_dotdot->sdev_contents);
6702621Sllai1 
6712729Sllai1 	/*
6723843Sjg 	 * acquire the global lock to prevent
6732729Sllai1 	 * mount/unmount/other rename activities.
6742729Sllai1 	 */
6752729Sllai1 	mutex_enter(&sdev_lock);
6762729Sllai1 
6772621Sllai1 	/* check existence of the source node */
6785331Samw /* XXXci - We may need to translate the C-I flags on VOP_LOOKUP */
6795331Samw 	error = VOP_LOOKUP(odvp, onm, &ovp, NULL, 0, NULL, cred, ct,
6805331Samw 	    NULL, NULL);
6812621Sllai1 	if (error) {
6822621Sllai1 		sdcmn_err2(("sdev_rename: the source node %s exists\n",
6832621Sllai1 		    onm));
6842729Sllai1 		mutex_exit(&sdev_lock);
6852621Sllai1 		return (error);
6862621Sllai1 	}
6872621Sllai1 
6885331Samw 	if (VOP_REALVP(ovp, &realvp, ct) == 0) {
6892621Sllai1 		VN_HOLD(realvp);
6902621Sllai1 		VN_RELE(ovp);
6912621Sllai1 		ovp = realvp;
6922621Sllai1 	}
6932621Sllai1 
6942621Sllai1 	/* check existence of destination */
6955331Samw /* XXXci - We may need to translate the C-I flags on VOP_LOOKUP */
6965331Samw 	error = VOP_LOOKUP(ndvp, nnm, &nvp, NULL, 0, NULL, cred, ct,
6975331Samw 	    NULL, NULL);
6982621Sllai1 	if (error && (error != ENOENT)) {
6992729Sllai1 		mutex_exit(&sdev_lock);
7002621Sllai1 		VN_RELE(ovp);
7012621Sllai1 		return (error);
7022621Sllai1 	}
7032621Sllai1 
7045331Samw 	if (nvp && (VOP_REALVP(nvp, &realvp, ct) == 0)) {
7052621Sllai1 		VN_HOLD(realvp);
7062621Sllai1 		VN_RELE(nvp);
7072621Sllai1 		nvp = realvp;
7082621Sllai1 	}
7092621Sllai1 
7102621Sllai1 	/*
7112729Sllai1 	 * make sure the source and the destination are
7122729Sllai1 	 * in the same dev filesystem
7132621Sllai1 	 */
7142621Sllai1 	if (odvp != ndvp) {
7152621Sllai1 		vattr.va_mask = AT_FSID;
7165331Samw 		if (error = VOP_GETATTR(odvp, &vattr, 0, cred, ct)) {
7172729Sllai1 			mutex_exit(&sdev_lock);
7182621Sllai1 			VN_RELE(ovp);
7192621Sllai1 			return (error);
7202621Sllai1 		}
7212621Sllai1 		fsid = vattr.va_fsid;
7222621Sllai1 		vattr.va_mask = AT_FSID;
7235331Samw 		if (error = VOP_GETATTR(ndvp, &vattr, 0, cred, ct)) {
7242729Sllai1 			mutex_exit(&sdev_lock);
7252621Sllai1 			VN_RELE(ovp);
7262621Sllai1 			return (error);
7272621Sllai1 		}
7282621Sllai1 		if (fsid != vattr.va_fsid) {
7292729Sllai1 			mutex_exit(&sdev_lock);
7302621Sllai1 			VN_RELE(ovp);
7312621Sllai1 			return (EXDEV);
7322621Sllai1 		}
7332621Sllai1 	}
7342621Sllai1 
7352621Sllai1 	/* make sure the old entry can be deleted */
7365331Samw 	error = VOP_ACCESS(odvp, VWRITE, 0, cred, ct);
7372621Sllai1 	if (error) {
7382729Sllai1 		mutex_exit(&sdev_lock);
7392621Sllai1 		VN_RELE(ovp);
7402621Sllai1 		return (error);
7412621Sllai1 	}
7422621Sllai1 
7432621Sllai1 	/* make sure the destination allows creation */
7442621Sllai1 	samedir = (fromparent == toparent);
7452621Sllai1 	if (!samedir) {
7465331Samw 		error = VOP_ACCESS(ndvp, VEXEC|VWRITE, 0, cred, ct);
7472621Sllai1 		if (error) {
7482729Sllai1 			mutex_exit(&sdev_lock);
7492621Sllai1 			VN_RELE(ovp);
7502621Sllai1 			return (error);
7512621Sllai1 		}
7522621Sllai1 	}
7532621Sllai1 
7542621Sllai1 	fromdv = VTOSDEV(ovp);
7552621Sllai1 	ASSERT(fromdv);
7562621Sllai1 
7572729Sllai1 	/* destination file exists */
7582621Sllai1 	if (nvp) {
7592729Sllai1 		todv = VTOSDEV(nvp);
7602729Sllai1 		ASSERT(todv);
7612621Sllai1 	}
7622621Sllai1 
7632621Sllai1 	/*
7642621Sllai1 	 * link source to new target in the memory
7652621Sllai1 	 */
7662729Sllai1 	error = sdev_rnmnode(fromparent, fromdv, toparent, &todv, nnm, cred);
7672621Sllai1 	if (error) {
7682621Sllai1 		sdcmn_err2(("sdev_rename: renaming %s to %s failed "
7692621Sllai1 		    " with error %d\n", onm, nnm, error));
7702729Sllai1 		mutex_exit(&sdev_lock);
7712729Sllai1 		if (nvp)
7722729Sllai1 			VN_RELE(nvp);
7732621Sllai1 		VN_RELE(ovp);
7742729Sllai1 		return (error);
7752729Sllai1 	}
7762729Sllai1 
7772729Sllai1 	/*
7782729Sllai1 	 * unlink from source
7792729Sllai1 	 */
7802729Sllai1 	rw_enter(&fromparent->sdev_contents, RW_READER);
7812729Sllai1 	fromdv = sdev_cache_lookup(fromparent, onm);
7822729Sllai1 	if (fromdv == NULL) {
7832729Sllai1 		rw_exit(&fromparent->sdev_contents);
7842729Sllai1 		mutex_exit(&sdev_lock);
7852729Sllai1 		sdcmn_err2(("sdev_rename: the source is deleted already\n"));
7862729Sllai1 		return (0);
7872621Sllai1 	}
7882621Sllai1 
7892729Sllai1 	if (fromdv->sdev_state == SDEV_ZOMBIE) {
7902729Sllai1 		rw_exit(&fromparent->sdev_contents);
7912729Sllai1 		mutex_exit(&sdev_lock);
7922729Sllai1 		VN_RELE(SDEVTOV(fromdv));
7932729Sllai1 		sdcmn_err2(("sdev_rename: the source is being deleted\n"));
7942729Sllai1 		return (0);
7952729Sllai1 	}
7962729Sllai1 	rw_exit(&fromparent->sdev_contents);
7972729Sllai1 	ASSERT(SDEVTOV(fromdv) == ovp);
7982729Sllai1 	VN_RELE(ovp);
7992729Sllai1 
8002729Sllai1 	/* clean out the directory contents before it can be removed */
8012729Sllai1 	type = SDEVTOV(fromdv)->v_type;
8022729Sllai1 	if (type == VDIR) {
8032729Sllai1 		error = sdev_cleandir(fromdv, NULL, 0);
8042729Sllai1 		sdcmn_err2(("sdev_rename: cleandir finished with %d\n",
8052729Sllai1 		    error));
8062729Sllai1 		if (error == EBUSY)
8072729Sllai1 			error = 0;
8082729Sllai1 	}
8092729Sllai1 
8102729Sllai1 	rw_enter(&fromparent->sdev_contents, RW_WRITER);
8112729Sllai1 	bkstore = SDEV_IS_PERSIST(fromdv) ? 1 : 0;
8122729Sllai1 	error = sdev_cache_update(fromparent, &fromdv, onm,
8132729Sllai1 	    SDEV_CACHE_DELETE);
8142729Sllai1 
8152729Sllai1 	/* best effforts clean up the backing store */
8162729Sllai1 	if (bkstore) {
8172729Sllai1 		ASSERT(fromparent->sdev_attrvp);
8182729Sllai1 		if (type != VDIR) {
8195331Samw /* XXXci - We may need to translate the C-I flags on VOP_REMOVE */
8202729Sllai1 			error = VOP_REMOVE(fromparent->sdev_attrvp,
8215331Samw 			    onm, kcred, ct, 0);
8222729Sllai1 		} else {
8235331Samw /* XXXci - We may need to translate the C-I flags on VOP_RMDIR */
8242729Sllai1 			error = VOP_RMDIR(fromparent->sdev_attrvp,
8255331Samw 			    onm, fromparent->sdev_attrvp, kcred, ct, 0);
8262729Sllai1 		}
8272729Sllai1 
8282729Sllai1 		if (error) {
8292729Sllai1 			sdcmn_err2(("sdev_rename: device %s is "
8302729Sllai1 			    "still on disk %s\n", onm,
8312729Sllai1 			    fromparent->sdev_path));
8322729Sllai1 			error = 0;
8332729Sllai1 		}
8342729Sllai1 	}
8352729Sllai1 	rw_exit(&fromparent->sdev_contents);
8362729Sllai1 	mutex_exit(&sdev_lock);
8372729Sllai1 
8382729Sllai1 	/* once reached to this point, the rename is regarded successful */
8392729Sllai1 	return (0);
8402621Sllai1 }
8412621Sllai1 
8422621Sllai1 /*
8432621Sllai1  * dev-fs version of "ln -s path dev-name"
8442621Sllai1  *	tnm - path, e.g. /devices/... or /dev/...
8452621Sllai1  *	lnm - dev_name
8462621Sllai1  */
8475331Samw /*ARGSUSED6*/
8482621Sllai1 static int
sdev_symlink(struct vnode * dvp,char * lnm,struct vattr * tva,char * tnm,struct cred * cred,caller_context_t * ct,int flags)8492621Sllai1 sdev_symlink(struct vnode *dvp, char *lnm, struct vattr *tva,
8505331Samw     char *tnm, struct cred *cred, caller_context_t *ct, int flags)
8512621Sllai1 {
8522621Sllai1 	int error;
8532621Sllai1 	struct vnode *vp = NULL;
8542621Sllai1 	struct sdev_node *parent = (struct sdev_node *)VTOSDEV(dvp);
8552621Sllai1 	struct sdev_node *self = (struct sdev_node *)NULL;
8562621Sllai1 
8572621Sllai1 	ASSERT(parent);
8582621Sllai1 	rw_enter(&parent->sdev_dotdot->sdev_contents, RW_READER);
8592621Sllai1 	if (parent->sdev_state == SDEV_ZOMBIE) {
8602621Sllai1 		rw_exit(&parent->sdev_dotdot->sdev_contents);
8612621Sllai1 		sdcmn_err2(("sdev_symlink: parent %s is ZOMBIED \n",
8622621Sllai1 		    parent->sdev_name));
8632621Sllai1 		return (ENOENT);
8642621Sllai1 	}
8652621Sllai1 
8662621Sllai1 	if (!SDEV_IS_GLOBAL(parent)) {
8672621Sllai1 		rw_exit(&parent->sdev_dotdot->sdev_contents);
8682621Sllai1 		return (ENOTSUP);
8692621Sllai1 	}
8702621Sllai1 	rw_exit(&parent->sdev_dotdot->sdev_contents);
8712621Sllai1 
8723843Sjg 	/* execute access is required to search a directory */
8735331Samw 	if ((error = VOP_ACCESS(dvp, VEXEC, 0, cred, ct)) != 0)
8743843Sjg 		return (error);
8753843Sjg 
8762621Sllai1 	/* find existing name */
8775331Samw /* XXXci - We may need to translate the C-I flags here */
8785331Samw 	error = VOP_LOOKUP(dvp, lnm, &vp, NULL, 0, NULL, cred, ct, NULL, NULL);
8792621Sllai1 	if (error == 0) {
8802621Sllai1 		ASSERT(vp);
8812621Sllai1 		VN_RELE(vp);
8822621Sllai1 		sdcmn_err2(("sdev_symlink: node %s already exists\n", lnm));
8832621Sllai1 		return (EEXIST);
8842621Sllai1 	}
8853843Sjg 	if (error != ENOENT)
8863843Sjg 		return (error);
8872621Sllai1 
8883843Sjg 	/* write access is required to create a symlink */
8895331Samw 	if ((error = VOP_ACCESS(dvp, VWRITE, 0, cred, ct)) != 0)
8902621Sllai1 		return (error);
8912621Sllai1 
8922621Sllai1 	/* put it into memory cache */
8932621Sllai1 	rw_enter(&parent->sdev_contents, RW_WRITER);
8942621Sllai1 	error = sdev_mknode(parent, lnm, &self, tva, NULL, (void *)tnm,
8952621Sllai1 	    cred, SDEV_READY);
8962621Sllai1 	if (error) {
8972621Sllai1 		rw_exit(&parent->sdev_contents);
8982621Sllai1 		sdcmn_err2(("sdev_symlink: node %s creation failed\n", lnm));
8992621Sllai1 		if (self)
9002621Sllai1 			SDEV_RELE(self);
9012621Sllai1 
9022621Sllai1 		return (error);
9032621Sllai1 	}
9042621Sllai1 	ASSERT(self && (self->sdev_state == SDEV_READY));
9052621Sllai1 	rw_exit(&parent->sdev_contents);
9062621Sllai1 
9072621Sllai1 	/* take care the timestamps for the node and its parent */
9082621Sllai1 	sdev_update_timestamps(SDEVTOV(self), kcred,
9092621Sllai1 	    AT_CTIME|AT_MTIME|AT_ATIME);
9102621Sllai1 	sdev_update_timestamps(dvp, kcred, AT_MTIME|AT_ATIME);
9112621Sllai1 	if (SDEV_IS_GLOBAL(parent))
9122621Sllai1 		atomic_inc_ulong(&parent->sdev_gdir_gen);
9132621Sllai1 
9142621Sllai1 	/* wake up other threads blocked on looking up this node */
9152621Sllai1 	mutex_enter(&self->sdev_lookup_lock);
9162621Sllai1 	SDEV_UNBLOCK_OTHERS(self, SDEV_LOOKUP);
9172621Sllai1 	mutex_exit(&self->sdev_lookup_lock);
9182621Sllai1 	SDEV_RELE(self);	/* don't return with vnode held */
9192621Sllai1 	return (0);
9202621Sllai1 }
9212621Sllai1 
9225331Samw /*ARGSUSED6*/
9232621Sllai1 static int
sdev_mkdir(struct vnode * dvp,char * nm,struct vattr * va,struct vnode ** vpp,struct cred * cred,caller_context_t * ct,int flags,vsecattr_t * vsecp)9242621Sllai1 sdev_mkdir(struct vnode *dvp, char *nm, struct vattr *va, struct vnode **vpp,
9255331Samw     struct cred *cred, caller_context_t *ct, int flags, vsecattr_t *vsecp)
9262621Sllai1 {
9272621Sllai1 	int error;
9282621Sllai1 	struct sdev_node *parent = (struct sdev_node *)VTOSDEV(dvp);
9292621Sllai1 	struct sdev_node *self = NULL;
9302621Sllai1 	struct vnode	*vp = NULL;
9312621Sllai1 
9322621Sllai1 	ASSERT(parent && parent->sdev_dotdot);
9332621Sllai1 	rw_enter(&parent->sdev_dotdot->sdev_contents, RW_READER);
9342621Sllai1 	if (parent->sdev_state == SDEV_ZOMBIE) {
9352621Sllai1 		rw_exit(&parent->sdev_dotdot->sdev_contents);
9362621Sllai1 		return (ENOENT);
9372621Sllai1 	}
9382621Sllai1 
9392621Sllai1 	/* non-global do not allow pure directory creation */
9402621Sllai1 	if (!SDEV_IS_GLOBAL(parent)) {
9412621Sllai1 		rw_exit(&parent->sdev_dotdot->sdev_contents);
9422621Sllai1 		return (prof_lookup(dvp, nm, vpp, cred));
9432621Sllai1 	}
9442621Sllai1 	rw_exit(&parent->sdev_dotdot->sdev_contents);
9452621Sllai1 
9463843Sjg 	/* execute access is required to search the directory */
9475331Samw 	if ((error = VOP_ACCESS(dvp, VEXEC, 0, cred, ct)) != 0) {
9483843Sjg 		return (error);
9493843Sjg 	}
9503843Sjg 
9512621Sllai1 	/* find existing name */
9525331Samw /* XXXci - We may need to translate the C-I flags on VOP_LOOKUP */
9535331Samw 	error = VOP_LOOKUP(dvp, nm, &vp, NULL, 0, NULL, cred, ct, NULL, NULL);
9542621Sllai1 	if (error == 0) {
9552621Sllai1 		VN_RELE(vp);
9562621Sllai1 		return (EEXIST);
9572621Sllai1 	}
9582621Sllai1 	if (error != ENOENT)
9592621Sllai1 		return (error);
9602621Sllai1 
9613843Sjg 	/* require write access to create a directory */
9625331Samw 	if ((error = VOP_ACCESS(dvp, VWRITE, 0, cred, ct)) != 0) {
9633843Sjg 		return (error);
9643843Sjg 	}
9653843Sjg 
9662621Sllai1 	/* put it into memory */
9672621Sllai1 	rw_enter(&parent->sdev_contents, RW_WRITER);
9682621Sllai1 	error = sdev_mknode(parent, nm, &self,
9692621Sllai1 	    va, NULL, NULL, cred, SDEV_READY);
9702621Sllai1 	if (error) {
9712621Sllai1 		rw_exit(&parent->sdev_contents);
9722621Sllai1 		if (self)
9732621Sllai1 			SDEV_RELE(self);
9742621Sllai1 		return (error);
9752621Sllai1 	}
9762621Sllai1 	ASSERT(self && (self->sdev_state == SDEV_READY));
9772621Sllai1 	rw_exit(&parent->sdev_contents);
9782621Sllai1 
9792621Sllai1 	/* take care the timestamps for the node and its parent */
9802621Sllai1 	sdev_update_timestamps(SDEVTOV(self), kcred,
9812621Sllai1 	    AT_CTIME|AT_MTIME|AT_ATIME);
9822621Sllai1 	sdev_update_timestamps(dvp, kcred, AT_MTIME|AT_ATIME);
9832621Sllai1 	if (SDEV_IS_GLOBAL(parent))
9842621Sllai1 		atomic_inc_ulong(&parent->sdev_gdir_gen);
9852621Sllai1 
9862621Sllai1 	/* wake up other threads blocked on looking up this node */
9872621Sllai1 	mutex_enter(&self->sdev_lookup_lock);
9882621Sllai1 	SDEV_UNBLOCK_OTHERS(self, SDEV_LOOKUP);
9892621Sllai1 	mutex_exit(&self->sdev_lookup_lock);
9902621Sllai1 	*vpp = SDEVTOV(self);
9912621Sllai1 	return (0);
9922621Sllai1 }
9932621Sllai1 
9942621Sllai1 /*
9952621Sllai1  * allowing removing an empty directory under /dev
9962621Sllai1  */
9972621Sllai1 /*ARGSUSED*/
9982621Sllai1 static int
sdev_rmdir(struct vnode * dvp,char * nm,struct vnode * cdir,struct cred * cred,caller_context_t * ct,int flags)9995331Samw sdev_rmdir(struct vnode *dvp, char *nm, struct vnode *cdir, struct cred *cred,
10005331Samw     caller_context_t *ct, int flags)
10012621Sllai1 {
10022621Sllai1 	int error = 0;
10032621Sllai1 	struct sdev_node *parent = (struct sdev_node *)VTOSDEV(dvp);
10042621Sllai1 	struct sdev_node *self = NULL;
10052621Sllai1 	struct vnode *vp = NULL;
10062621Sllai1 
10072621Sllai1 	/* bail out early */
10082621Sllai1 	if (strcmp(nm, ".") == 0)
10092621Sllai1 		return (EINVAL);
10102621Sllai1 	if (strcmp(nm, "..") == 0)
10112621Sllai1 		return (EEXIST); /* should be ENOTEMPTY */
10122621Sllai1 
10132621Sllai1 	/* no destruction of non-global node */
10142621Sllai1 	ASSERT(parent && parent->sdev_dotdot);
10152621Sllai1 	rw_enter(&parent->sdev_dotdot->sdev_contents, RW_READER);
10162621Sllai1 	if (!SDEV_IS_GLOBAL(parent)) {
10172621Sllai1 		rw_exit(&parent->sdev_dotdot->sdev_contents);
10182621Sllai1 		return (ENOTSUP);
10192621Sllai1 	}
10202621Sllai1 	rw_exit(&parent->sdev_dotdot->sdev_contents);
10212621Sllai1 
10223843Sjg 	/* execute access is required to search the directory */
102310588SEric.Taylor@Sun.COM 	if ((error = VOP_ACCESS(dvp, VEXEC|VWRITE, 0, cred, ct)) != 0)
10243843Sjg 		return (error);
10253843Sjg 
10262621Sllai1 	/* check existing name */
10272621Sllai1 	rw_enter(&parent->sdev_contents, RW_WRITER);
10282621Sllai1 	self = sdev_cache_lookup(parent, nm);
10292621Sllai1 	if (self == NULL) {
10302621Sllai1 		rw_exit(&parent->sdev_contents);
10312621Sllai1 		return (ENOENT);
10322621Sllai1 	}
10332621Sllai1 
10342621Sllai1 	vp = SDEVTOV(self);
10352621Sllai1 	if ((self->sdev_state == SDEV_INIT) ||
10362621Sllai1 	    (self->sdev_state == SDEV_ZOMBIE)) {
10372621Sllai1 		rw_exit(&parent->sdev_contents);
10382621Sllai1 		VN_RELE(vp);
10392621Sllai1 		return (ENOENT);
10402621Sllai1 	}
10412621Sllai1 
10422621Sllai1 	/* some sanity checks */
10432621Sllai1 	if (vp == dvp || vp == cdir) {
10442621Sllai1 		rw_exit(&parent->sdev_contents);
10452621Sllai1 		VN_RELE(vp);
10462621Sllai1 		return (EINVAL);
10472621Sllai1 	}
10482621Sllai1 
10492621Sllai1 	if (vp->v_type != VDIR) {
10502621Sllai1 		rw_exit(&parent->sdev_contents);
10512621Sllai1 		VN_RELE(vp);
10522621Sllai1 		return (ENOTDIR);
10532621Sllai1 	}
10542621Sllai1 
10552621Sllai1 	if (vn_vfswlock(vp)) {
10562621Sllai1 		rw_exit(&parent->sdev_contents);
10572621Sllai1 		VN_RELE(vp);
10582621Sllai1 		return (EBUSY);
10592621Sllai1 	}
10602621Sllai1 
10612621Sllai1 	if (vn_mountedvfs(vp) != NULL) {
10622621Sllai1 		rw_exit(&parent->sdev_contents);
10632621Sllai1 		vn_vfsunlock(vp);
10642621Sllai1 		VN_RELE(vp);
10652621Sllai1 		return (EBUSY);
10662621Sllai1 	}
10672621Sllai1 
10682621Sllai1 	self = VTOSDEV(vp);
10692621Sllai1 	/* bail out on a non-empty directory */
10702621Sllai1 	rw_enter(&self->sdev_contents, RW_READER);
10712621Sllai1 	if (self->sdev_nlink > 2) {
10722621Sllai1 		rw_exit(&self->sdev_contents);
10732621Sllai1 		rw_exit(&parent->sdev_contents);
10742621Sllai1 		vn_vfsunlock(vp);
10752621Sllai1 		VN_RELE(vp);
10762621Sllai1 		return (ENOTEMPTY);
10772621Sllai1 	}
10782621Sllai1 	rw_exit(&self->sdev_contents);
10792621Sllai1 
10802621Sllai1 	/* unlink it from the directory cache */
10812621Sllai1 	error = sdev_cache_update(parent, &self, nm, SDEV_CACHE_DELETE);
10822621Sllai1 	rw_exit(&parent->sdev_contents);
10832621Sllai1 	vn_vfsunlock(vp);
10842621Sllai1 
10852621Sllai1 	if (error && (error != EBUSY)) {
10862621Sllai1 		VN_RELE(vp);
10872621Sllai1 	} else {
10882621Sllai1 		sdcmn_err2(("sdev_rmdir: cleaning node %s from directory "
10892621Sllai1 		    " cache with error %d\n", nm, error));
10902621Sllai1 
10912621Sllai1 		/* best effort to clean up the backing store */
10922621Sllai1 		if (SDEV_IS_PERSIST(parent)) {
10932621Sllai1 			ASSERT(parent->sdev_attrvp);
10942621Sllai1 			error = VOP_RMDIR(parent->sdev_attrvp, nm,
10955331Samw 			    parent->sdev_attrvp, kcred, ct, flags);
10962621Sllai1 			sdcmn_err2(("sdev_rmdir: cleaning device %s is on"
10972621Sllai1 			    " disk error %d\n", parent->sdev_path, error));
10982621Sllai1 		}
10992621Sllai1 
11002621Sllai1 		if (error == EBUSY)
11012621Sllai1 			error = 0;
11022621Sllai1 	}
11032621Sllai1 
11042621Sllai1 	return (error);
11052621Sllai1 }
11062621Sllai1 
11072621Sllai1 /*
11082621Sllai1  * read the contents of a symbolic link
11092621Sllai1  */
11102621Sllai1 static int
sdev_readlink(struct vnode * vp,struct uio * uiop,struct cred * cred,caller_context_t * ct)11115331Samw sdev_readlink(struct vnode *vp, struct uio *uiop, struct cred *cred,
11125331Samw     caller_context_t *ct)
11132621Sllai1 {
11142621Sllai1 	struct sdev_node *dv;
11152621Sllai1 	int	error = 0;
11162621Sllai1 
11172621Sllai1 	ASSERT(vp->v_type == VLNK);
11182621Sllai1 
11192621Sllai1 	dv = VTOSDEV(vp);
11202621Sllai1 
11212621Sllai1 	if (dv->sdev_attrvp) {
11222621Sllai1 		/* non-NULL attrvp implys a persisted node at READY state */
11235331Samw 		return (VOP_READLINK(dv->sdev_attrvp, uiop, cred, ct));
11242621Sllai1 	} else if (dv->sdev_symlink != NULL) {
11252621Sllai1 		/* memory nodes, e.g. local nodes */
11262621Sllai1 		rw_enter(&dv->sdev_contents, RW_READER);
11272621Sllai1 		sdcmn_err2(("sdev_readlink link is %s\n", dv->sdev_symlink));
11282621Sllai1 		error = uiomove(dv->sdev_symlink, strlen(dv->sdev_symlink),
11292621Sllai1 		    UIO_READ, uiop);
11302621Sllai1 		rw_exit(&dv->sdev_contents);
11312621Sllai1 		return (error);
11322621Sllai1 	}
11332621Sllai1 
11342621Sllai1 	return (ENOENT);
11352621Sllai1 }
11362621Sllai1 
11375331Samw /*ARGSUSED4*/
11382621Sllai1 static int
sdev_readdir(struct vnode * dvp,struct uio * uiop,struct cred * cred,int * eofp,caller_context_t * ct,int flags)11395331Samw sdev_readdir(struct vnode *dvp, struct uio *uiop, struct cred *cred, int *eofp,
11405331Samw     caller_context_t *ct, int flags)
11412621Sllai1 {
11422679Sszhou 	struct sdev_node *parent = VTOSDEV(dvp);
11433843Sjg 	int error;
11443843Sjg 
11453843Sjg 	/* execute access is required to search the directory */
11465331Samw 	if ((error = VOP_ACCESS(dvp, VEXEC, 0, cred, ct)) != 0)
11473843Sjg 		return (error);
11482679Sszhou 
11492679Sszhou 	ASSERT(parent);
11502679Sszhou 	if (!SDEV_IS_GLOBAL(parent))
11512679Sszhou 		prof_filldir(parent);
11522621Sllai1 	return (devname_readdir_func(dvp, uiop, cred, eofp, SDEV_BROWSE));
11532621Sllai1 }
11542621Sllai1 
11552621Sllai1 /*ARGSUSED1*/
11562621Sllai1 static void
sdev_inactive(struct vnode * vp,struct cred * cred,caller_context_t * ct)11575331Samw sdev_inactive(struct vnode *vp, struct cred *cred, caller_context_t *ct)
11582621Sllai1 {
11595895Syz147064 	devname_inactive_func(vp, cred, NULL);
11602621Sllai1 }
11612621Sllai1 
11625331Samw /*ARGSUSED2*/
11632621Sllai1 static int
sdev_fid(struct vnode * vp,struct fid * fidp,caller_context_t * ct)11645331Samw sdev_fid(struct vnode *vp, struct fid *fidp, caller_context_t *ct)
11652621Sllai1 {
11662621Sllai1 	struct sdev_node	*dv = VTOSDEV(vp);
11672621Sllai1 	struct sdev_fid	*sdev_fid;
11682621Sllai1 
11692621Sllai1 	if (fidp->fid_len < (sizeof (struct sdev_fid) - sizeof (ushort_t))) {
11702621Sllai1 		fidp->fid_len = sizeof (struct sdev_fid) - sizeof (ushort_t);
11712621Sllai1 		return (ENOSPC);
11722621Sllai1 	}
11732621Sllai1 
11742621Sllai1 	sdev_fid = (struct sdev_fid *)fidp;
11752621Sllai1 	bzero(sdev_fid, sizeof (struct sdev_fid));
11762621Sllai1 	sdev_fid->sdevfid_len =
11772621Sllai1 	    (int)sizeof (struct sdev_fid) - sizeof (ushort_t);
11782621Sllai1 	sdev_fid->sdevfid_ino = dv->sdev_ino;
11792621Sllai1 
11802621Sllai1 	return (0);
11812621Sllai1 }
11822621Sllai1 
11832621Sllai1 /*
11842621Sllai1  * This pair of routines bracket all VOP_READ, VOP_WRITE
11852621Sllai1  * and VOP_READDIR requests.  The contents lock stops things
11862621Sllai1  * moving around while we're looking at them.
11872621Sllai1  */
11883748Sjg /*ARGSUSED2*/
11893748Sjg static int
sdev_rwlock(struct vnode * vp,int write_flag,caller_context_t * ctp)11903748Sjg sdev_rwlock(struct vnode *vp, int write_flag, caller_context_t *ctp)
11912621Sllai1 {
11923748Sjg 	rw_enter(&VTOSDEV(vp)->sdev_contents,
11933748Sjg 	    write_flag ? RW_WRITER : RW_READER);
11943748Sjg 	return (write_flag ? V_WRITELOCK_TRUE : V_WRITELOCK_FALSE);
11952621Sllai1 }
11962621Sllai1 
11972621Sllai1 /*ARGSUSED1*/
11982621Sllai1 static void
sdev_rwunlock(struct vnode * vp,int write_flag,caller_context_t * ctp)11993748Sjg sdev_rwunlock(struct vnode *vp, int write_flag, caller_context_t *ctp)
12002621Sllai1 {
12012621Sllai1 	rw_exit(&VTOSDEV(vp)->sdev_contents);
12022621Sllai1 }
12032621Sllai1 
12042621Sllai1 /*ARGSUSED1*/
12052621Sllai1 static int
sdev_seek(struct vnode * vp,offset_t ooff,offset_t * noffp,caller_context_t * ct)12065331Samw sdev_seek(struct vnode *vp, offset_t ooff, offset_t *noffp,
12075331Samw     caller_context_t *ct)
12082621Sllai1 {
12092621Sllai1 	struct vnode *attrvp = VTOSDEV(vp)->sdev_attrvp;
12102621Sllai1 
12112621Sllai1 	ASSERT(vp->v_type != VCHR &&
12122621Sllai1 	    vp->v_type != VBLK && vp->v_type != VLNK);
12132621Sllai1 
12142621Sllai1 	if (vp->v_type == VDIR)
12155331Samw 		return (fs_seek(vp, ooff, noffp, ct));
12162621Sllai1 
12172621Sllai1 	ASSERT(attrvp);
12185331Samw 	return (VOP_SEEK(attrvp, ooff, noffp, ct));
12192621Sllai1 }
12202621Sllai1 
12212621Sllai1 /*ARGSUSED1*/
12222621Sllai1 static int
sdev_frlock(struct vnode * vp,int cmd,struct flock64 * bfp,int flag,offset_t offset,struct flk_callback * flk_cbp,struct cred * cr,caller_context_t * ct)12232621Sllai1 sdev_frlock(struct vnode *vp, int cmd, struct flock64 *bfp, int flag,
12245331Samw     offset_t offset, struct flk_callback *flk_cbp, struct cred *cr,
12255331Samw     caller_context_t *ct)
12262621Sllai1 {
12272621Sllai1 	int error;
12282621Sllai1 	struct sdev_node *dv = VTOSDEV(vp);
12292621Sllai1 
12302621Sllai1 	ASSERT(dv);
12312621Sllai1 	ASSERT(dv->sdev_attrvp);
12322621Sllai1 	error = VOP_FRLOCK(dv->sdev_attrvp, cmd, bfp, flag, offset,
12335331Samw 	    flk_cbp, cr, ct);
12342621Sllai1 
12352621Sllai1 	return (error);
12362621Sllai1 }
12372621Sllai1 
12382621Sllai1 static int
sdev_pathconf(vnode_t * vp,int cmd,ulong_t * valp,cred_t * cr,caller_context_t * ct)12395331Samw sdev_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr,
12405331Samw     caller_context_t *ct)
12412621Sllai1 {
12422621Sllai1 	switch (cmd) {
12432621Sllai1 	case _PC_ACL_ENABLED:
12442621Sllai1 		*valp = SDEV_ACL_FLAVOR(vp);
12452621Sllai1 		return (0);
12462621Sllai1 	}
12472621Sllai1 
12485331Samw 	return (fs_pathconf(vp, cmd, valp, cr, ct));
12492621Sllai1 }
12502621Sllai1 
12512621Sllai1 vnodeops_t *sdev_vnodeops;
12522621Sllai1 
12532621Sllai1 const fs_operation_def_t sdev_vnodeops_tbl[] = {
12543898Srsb 	VOPNAME_OPEN,		{ .vop_open = sdev_open },
12553898Srsb 	VOPNAME_CLOSE,		{ .vop_close = sdev_close },
12563898Srsb 	VOPNAME_READ,		{ .vop_read = sdev_read },
12573898Srsb 	VOPNAME_WRITE,		{ .vop_write = sdev_write },
12583898Srsb 	VOPNAME_IOCTL,		{ .vop_ioctl = sdev_ioctl },
12593898Srsb 	VOPNAME_GETATTR,	{ .vop_getattr = sdev_getattr },
12603898Srsb 	VOPNAME_SETATTR,	{ .vop_setattr = sdev_setattr },
12613898Srsb 	VOPNAME_ACCESS,		{ .vop_access = sdev_access },
12623898Srsb 	VOPNAME_LOOKUP,		{ .vop_lookup = sdev_lookup },
12633898Srsb 	VOPNAME_CREATE,		{ .vop_create = sdev_create },
12643898Srsb 	VOPNAME_RENAME,		{ .vop_rename = sdev_rename },
12653898Srsb 	VOPNAME_REMOVE,		{ .vop_remove = sdev_remove },
12663898Srsb 	VOPNAME_MKDIR,		{ .vop_mkdir = sdev_mkdir },
12673898Srsb 	VOPNAME_RMDIR,		{ .vop_rmdir = sdev_rmdir },
12683898Srsb 	VOPNAME_READDIR,	{ .vop_readdir = sdev_readdir },
12693898Srsb 	VOPNAME_SYMLINK,	{ .vop_symlink = sdev_symlink },
12703898Srsb 	VOPNAME_READLINK,	{ .vop_readlink = sdev_readlink },
12713898Srsb 	VOPNAME_INACTIVE,	{ .vop_inactive = sdev_inactive },
12723898Srsb 	VOPNAME_FID,		{ .vop_fid = sdev_fid },
12733898Srsb 	VOPNAME_RWLOCK,		{ .vop_rwlock = sdev_rwlock },
12743898Srsb 	VOPNAME_RWUNLOCK,	{ .vop_rwunlock = sdev_rwunlock },
12753898Srsb 	VOPNAME_SEEK,		{ .vop_seek = sdev_seek },
12763898Srsb 	VOPNAME_FRLOCK,		{ .vop_frlock = sdev_frlock },
12773898Srsb 	VOPNAME_PATHCONF,	{ .vop_pathconf = sdev_pathconf },
12783898Srsb 	VOPNAME_SETSECATTR,	{ .vop_setsecattr = sdev_setsecattr },
12793898Srsb 	VOPNAME_GETSECATTR,	{ .vop_getsecattr = sdev_getsecattr },
12803898Srsb 	NULL,			NULL
12812621Sllai1 };
12822621Sllai1 
12832621Sllai1 int sdev_vnodeops_tbl_size = sizeof (sdev_vnodeops_tbl);
1284