xref: /onnv-gate/usr/src/uts/common/fs/dev/sdev_vfsops.c (revision 10097:e33d224110c9)
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 /*
22*10097SEric.Taylor@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
232621Sllai1  * Use is subject to license terms.
242621Sllai1  */
252621Sllai1 
262621Sllai1 /*
272621Sllai1  * This is the /dev (hence, the sdev_ prefix) filesystem.
282621Sllai1  */
292621Sllai1 
302621Sllai1 #include <sys/types.h>
312621Sllai1 #include <sys/param.h>
322621Sllai1 #include <sys/sysmacros.h>
332621Sllai1 #include <sys/systm.h>
342621Sllai1 #include <sys/kmem.h>
352621Sllai1 #include <sys/time.h>
362621Sllai1 #include <sys/pathname.h>
372621Sllai1 #include <sys/vfs.h>
383898Srsb #include <sys/vfs_opreg.h>
392621Sllai1 #include <sys/vnode.h>
402621Sllai1 #include <sys/file.h>
412621Sllai1 #include <sys/stat.h>
422621Sllai1 #include <sys/uio.h>
432621Sllai1 #include <sys/stat.h>
442621Sllai1 #include <sys/errno.h>
452621Sllai1 #include <sys/cmn_err.h>
462621Sllai1 #include <sys/cred.h>
472621Sllai1 #include <sys/statvfs.h>
482621Sllai1 #include <sys/policy.h>
492621Sllai1 #include <sys/mount.h>
502621Sllai1 #include <sys/debug.h>
512621Sllai1 #include <sys/modctl.h>
522621Sllai1 #include <sys/mkdev.h>
532621Sllai1 #include <fs/fs_subr.h>
542621Sllai1 #include <sys/fs/sdev_impl.h>
552621Sllai1 #include <sys/fs/snode.h>
562621Sllai1 #include <sys/fs/dv_node.h>
572621Sllai1 #include <sys/sunndi.h>
582621Sllai1 #include <sys/mntent.h>
592621Sllai1 
602621Sllai1 /*
612621Sllai1  * /dev vfs operations.
622621Sllai1  */
632621Sllai1 
642621Sllai1 /*
652621Sllai1  * globals
662621Sllai1  */
672621Sllai1 struct sdev_data *sdev_origins; /* mount info for origins under /dev */
682729Sllai1 kmutex_t sdev_lock; /* used for mount/unmount/rename synchronization */
692621Sllai1 
702621Sllai1 /*
712621Sllai1  * static
722621Sllai1  */
732621Sllai1 static major_t devmajor;	/* the fictitious major we live on */
742621Sllai1 static major_t devminor;	/* the fictitious minor of this instance */
752621Sllai1 static struct sdev_data *sdev_mntinfo = NULL;	/* linked list of instances */
763133Sjg 
773133Sjg /* LINTED E_STATIC_UNUSED */		/* useful for debugging */
782621Sllai1 static struct vnode *sdev_stale_attrvp; /* stale root attrvp after remount */
792621Sllai1 
802621Sllai1 static int sdev_mount(struct vfs *, struct vnode *, struct mounta *,
812621Sllai1     struct cred *);
822621Sllai1 static int sdev_unmount(struct vfs *, int, struct cred *);
832621Sllai1 static int sdev_root(struct vfs *, struct vnode **);
842621Sllai1 static int sdev_statvfs(struct vfs *, struct statvfs64 *);
852621Sllai1 static void sdev_insert_mntinfo(struct sdev_data *);
862621Sllai1 static int devinit(int, char *);
872621Sllai1 
882621Sllai1 static vfsdef_t sdev_vfssw = {
892621Sllai1 	VFSDEF_VERSION,
902621Sllai1 	"dev",		/* type name string */
912621Sllai1 	devinit,	/* init routine */
922621Sllai1 	VSW_CANREMOUNT,	/* flags */
932621Sllai1 	NULL		/* mount options table prototype */
942621Sllai1 };
952621Sllai1 
962621Sllai1 
972621Sllai1 /*
982621Sllai1  * Module linkage information
992621Sllai1  */
1002621Sllai1 static struct modlfs modlfs = {
1017862SRichard.Bean@Sun.COM 	&mod_fsops, "/dev filesystem", &sdev_vfssw
1022621Sllai1 };
1032621Sllai1 
1042621Sllai1 static struct modlinkage modlinkage = {
1052621Sllai1 	MODREV_1, (void *)&modlfs, NULL
1062621Sllai1 };
1072621Sllai1 
1082621Sllai1 int
_init(void)1092621Sllai1 _init(void)
1102621Sllai1 {
1112621Sllai1 	int e;
1122621Sllai1 
1132621Sllai1 	mutex_init(&sdev_lock, NULL, MUTEX_DEFAULT, NULL);
1142621Sllai1 	sdev_node_cache_init();
1152621Sllai1 	sdev_devfsadm_lockinit();
1162621Sllai1 	if ((e = mod_install(&modlinkage)) != 0) {
1172621Sllai1 		sdev_devfsadm_lockdestroy();
1182621Sllai1 		sdev_node_cache_fini();
1192621Sllai1 		mutex_destroy(&sdev_lock);
1202621Sllai1 		return (e);
1212621Sllai1 	}
1222621Sllai1 	return (0);
1232621Sllai1 }
1242621Sllai1 
1252621Sllai1 /*
1262621Sllai1  * dev module remained loaded for the global /dev instance
1272621Sllai1  */
1282621Sllai1 int
_fini(void)1292621Sllai1 _fini(void)
1302621Sllai1 {
1312621Sllai1 	return (EBUSY);
1322621Sllai1 }
1332621Sllai1 
1342621Sllai1 int
_info(struct modinfo * modinfop)1352621Sllai1 _info(struct modinfo *modinfop)
1362621Sllai1 {
1372621Sllai1 	return (mod_info(&modlinkage, modinfop));
1382621Sllai1 }
1392621Sllai1 
1402621Sllai1 /*ARGSUSED*/
1412621Sllai1 static int
devinit(int fstype,char * name)1422621Sllai1 devinit(int fstype, char *name)
1432621Sllai1 {
1442621Sllai1 	static const fs_operation_def_t dev_vfsops_tbl[] = {
1453898Srsb 		VFSNAME_MOUNT,		{ .vfs_mount = sdev_mount },
1463898Srsb 		VFSNAME_UNMOUNT,	{ .vfs_unmount = sdev_unmount },
1473898Srsb 		VFSNAME_ROOT, 		{ .vfs_root = sdev_root },
1483898Srsb 		VFSNAME_STATVFS,	{ .vfs_statvfs = sdev_statvfs },
1493898Srsb 		NULL,			NULL
1502621Sllai1 	};
1512621Sllai1 
1522621Sllai1 	int	error;
1532621Sllai1 	extern major_t getudev(void);
1542621Sllai1 
1552621Sllai1 	devtype = fstype;
1562621Sllai1 
1572621Sllai1 	error = vfs_setfsops(fstype, dev_vfsops_tbl, NULL);
1582621Sllai1 	if (error != 0) {
1592621Sllai1 		cmn_err(CE_WARN, "devinit: bad vfs ops tbl");
1602621Sllai1 		return (error);
1612621Sllai1 	}
1622621Sllai1 
1632621Sllai1 	error = vn_make_ops("dev", sdev_vnodeops_tbl, &sdev_vnodeops);
1642621Sllai1 	if (error != 0) {
1652621Sllai1 		(void) vfs_freevfsops_by_type(fstype);
1662621Sllai1 		cmn_err(CE_WARN, "devinit: bad vnode ops tbl");
1672621Sllai1 		return (error);
1682621Sllai1 	}
1692621Sllai1 
1702621Sllai1 	if ((devmajor = getudev()) == (major_t)-1) {
1712621Sllai1 		cmn_err(CE_WARN, "%s: can't get unique dev", sdev_vfssw.name);
1722621Sllai1 		return (1);
1732621Sllai1 	}
1742621Sllai1 
1752621Sllai1 	/* initialize negative cache */
1762621Sllai1 	sdev_ncache_init();
1772621Sllai1 
1782621Sllai1 	return (0);
1792621Sllai1 }
1802621Sllai1 
1812621Sllai1 /*
1822621Sllai1  * Both mount point and backing store directory name are
1832621Sllai1  * passed in from userland
1842621Sllai1  */
1852621Sllai1 static int
sdev_mount(struct vfs * vfsp,struct vnode * mvp,struct mounta * uap,struct cred * cr)1862621Sllai1 sdev_mount(struct vfs *vfsp, struct vnode *mvp, struct mounta *uap,
1872621Sllai1     struct cred *cr)
1882621Sllai1 {
1892621Sllai1 	struct sdev_data *sdev_data;
1902621Sllai1 	struct vnode *avp;
1912621Sllai1 	struct sdev_node *dv;
1922621Sllai1 	struct sdev_mountargs *args = NULL;
1932621Sllai1 	int	error = 0;
1942621Sllai1 	dev_t	devdev;
1952621Sllai1 
1962621Sllai1 	/*
1972621Sllai1 	 * security check
1982621Sllai1 	 */
1992621Sllai1 	if ((secpolicy_fs_mount(cr, mvp, vfsp) != 0) ||
2002621Sllai1 	    (secpolicy_sys_devices(cr) != 0))
2012621Sllai1 		return (EPERM);
2022621Sllai1 
2032621Sllai1 	/*
2042621Sllai1 	 * Sanity check the mount point
2052621Sllai1 	 */
2062621Sllai1 	if (mvp->v_type != VDIR)
2072621Sllai1 		return (ENOTDIR);
2082621Sllai1 
2092621Sllai1 	/*
2102621Sllai1 	 * Sanity Check for overlay mount.
2112621Sllai1 	 */
2122621Sllai1 	mutex_enter(&mvp->v_lock);
2132621Sllai1 	if ((uap->flags & MS_OVERLAY) == 0 &&
2142621Sllai1 	    (uap->flags & MS_REMOUNT) == 0 &&
2152621Sllai1 	    (mvp->v_count > 1 || (mvp->v_flag & VROOT))) {
2162621Sllai1 		mutex_exit(&mvp->v_lock);
2172621Sllai1 		return (EBUSY);
2182621Sllai1 	}
2192621Sllai1 	mutex_exit(&mvp->v_lock);
2202621Sllai1 
2212621Sllai1 	args = kmem_zalloc(sizeof (*args), KM_SLEEP);
2222621Sllai1 
2232621Sllai1 	if ((uap->flags & MS_DATA) &&
2242621Sllai1 	    (uap->datalen != 0 && uap->dataptr != NULL)) {
2252621Sllai1 		/* copy in the arguments */
2262621Sllai1 		if (error = sdev_copyin_mountargs(uap, args))
2272621Sllai1 			goto cleanup;
2282621Sllai1 	}
2292621Sllai1 
2302621Sllai1 	/*
2312621Sllai1 	 * Sanity check the backing store
2322621Sllai1 	 */
2332621Sllai1 	if (args->sdev_attrdir) {
2342621Sllai1 		/* user supplied an attribute store */
2352621Sllai1 		if (error = lookupname((char *)(uintptr_t)args->sdev_attrdir,
2362621Sllai1 		    UIO_USERSPACE, FOLLOW, NULLVPP, &avp)) {
2372621Sllai1 			cmn_err(CE_NOTE, "/dev fs: lookup on attribute "
2382621Sllai1 			    "directory %s failed",
2392621Sllai1 			    (char *)(uintptr_t)args->sdev_attrdir);
2402621Sllai1 			goto cleanup;
2412621Sllai1 		}
2422621Sllai1 
2432621Sllai1 		if (avp->v_type != VDIR) {
2442621Sllai1 			VN_RELE(avp);
2452621Sllai1 			error = ENOTDIR;
2462621Sllai1 			goto cleanup;
2472621Sllai1 		}
2482621Sllai1 	} else {
2492621Sllai1 		/* use mountp as the attribute store */
2502621Sllai1 		avp = mvp;
2512621Sllai1 		VN_HOLD(avp);
2522621Sllai1 	}
2532621Sllai1 
2542621Sllai1 	mutex_enter(&sdev_lock);
2552621Sllai1 
2562621Sllai1 	/*
2572621Sllai1 	 * handling installation
2582621Sllai1 	 */
2592621Sllai1 	if (uap->flags & MS_REMOUNT) {
2602621Sllai1 		sdev_data = (struct sdev_data *)vfsp->vfs_data;
2612621Sllai1 		ASSERT(sdev_data);
2622621Sllai1 
2632621Sllai1 		dv = sdev_data->sdev_root;
2642621Sllai1 		ASSERT(dv == dv->sdev_dotdot);
2652621Sllai1 
2662621Sllai1 		/*
2672621Sllai1 		 * mark all existing sdev_nodes (except root node) stale
2682621Sllai1 		 */
2692621Sllai1 		sdev_stale(dv);
2702621Sllai1 
2712621Sllai1 		/* Reset previous mountargs */
2722621Sllai1 		if (sdev_data->sdev_mountargs) {
2732621Sllai1 			kmem_free(sdev_data->sdev_mountargs,
2742621Sllai1 			    sizeof (struct sdev_mountargs));
2752621Sllai1 		}
2762621Sllai1 		sdev_data->sdev_mountargs = args;
2772621Sllai1 		args = NULL;		/* so it won't be freed below */
2782621Sllai1 
2792621Sllai1 		sdev_stale_attrvp = dv->sdev_attrvp;
2802621Sllai1 		dv->sdev_attrvp = avp;
2812621Sllai1 		vfsp->vfs_mtime = ddi_get_time();
2822621Sllai1 
2832621Sllai1 		mutex_exit(&sdev_lock);
2842621Sllai1 		goto cleanup;				/* we're done */
2852621Sllai1 	}
2862621Sllai1 
2872621Sllai1 	/*
2882621Sllai1 	 * Create and initialize the vfs-private data.
2892621Sllai1 	 */
2902621Sllai1 	devdev = makedevice(devmajor, devminor);
2912621Sllai1 	while (vfs_devismounted(devdev)) {
2922621Sllai1 		devminor = (devminor + 1) & MAXMIN32;
2932621Sllai1 
2942621Sllai1 		/*
2952621Sllai1 		 * All the minor numbers are used up.
2962621Sllai1 		 */
2972621Sllai1 		if (devminor == 0) {
2982621Sllai1 			mutex_exit(&sdev_lock);
2992621Sllai1 			VN_RELE(avp);
3002621Sllai1 			error = ENODEV;
3012621Sllai1 			goto cleanup;
3022621Sllai1 		}
3032621Sllai1 
3042621Sllai1 		devdev = makedevice(devmajor, devminor);
3052621Sllai1 	}
3062621Sllai1 
3072621Sllai1 	dv = sdev_mkroot(vfsp, devdev, mvp, avp, cr);
3082621Sllai1 	sdev_data = kmem_zalloc(sizeof (struct sdev_data), KM_SLEEP);
3092621Sllai1 	vfsp->vfs_dev = devdev;
3102621Sllai1 	vfsp->vfs_data = (caddr_t)sdev_data;
3112621Sllai1 	vfsp->vfs_fstype = devtype;
3122621Sllai1 	vfsp->vfs_bsize = DEV_BSIZE;
3132621Sllai1 	vfsp->vfs_mtime = ddi_get_time();
3142621Sllai1 	vfs_make_fsid(&vfsp->vfs_fsid, vfsp->vfs_dev, devtype);
3152621Sllai1 
3162621Sllai1 	ASSERT(dv == dv->sdev_dotdot);
3172621Sllai1 
3182621Sllai1 	sdev_data->sdev_vfsp = vfsp;
3192621Sllai1 	sdev_data->sdev_root = dv;
3202621Sllai1 	sdev_data->sdev_mountargs = args;
3212621Sllai1 
3222621Sllai1 	/* get acl flavor from attribute dir */
3232621Sllai1 	if (VOP_PATHCONF(avp, _PC_ACL_ENABLED, &sdev_data->sdev_acl_flavor,
3245331Samw 	    kcred, NULL) != 0 || sdev_data->sdev_acl_flavor == 0)
3252621Sllai1 		sdev_data->sdev_acl_flavor = _ACL_ACLENT_ENABLED;
3262621Sllai1 
3272621Sllai1 	args = NULL;			/* so it won't be freed below */
3282621Sllai1 	sdev_insert_mntinfo(sdev_data);
3292621Sllai1 	mutex_exit(&sdev_lock);
3302621Sllai1 
3312621Sllai1 	if (!SDEV_IS_GLOBAL(dv)) {
3322621Sllai1 		ASSERT(sdev_origins);
3332621Sllai1 		dv->sdev_flags &= ~SDEV_GLOBAL;
3342621Sllai1 		dv->sdev_origin = sdev_origins->sdev_root;
3352621Sllai1 	} else {
3362621Sllai1 		sdev_ncache_setup();
3373843Sjg 		rw_enter(&dv->sdev_contents, RW_WRITER);
3383843Sjg 		sdev_filldir_dynamic(dv);
3393843Sjg 		rw_exit(&dv->sdev_contents);
3402621Sllai1 	}
3412621Sllai1 
3422621Sllai1 	sdev_update_timestamps(dv->sdev_attrvp,
3437862SRichard.Bean@Sun.COM 	    cr, AT_CTIME|AT_MTIME|AT_ATIME);
3442621Sllai1 
3452621Sllai1 cleanup:
3462621Sllai1 	if (args)
3472621Sllai1 		kmem_free(args, sizeof (*args));
3482621Sllai1 	return (error);
3492621Sllai1 }
3502621Sllai1 
3512621Sllai1 /*
3522621Sllai1  * unmounting the non-global /dev instances, e.g. when deleting a Kevlar zone.
3532621Sllai1  */
3542621Sllai1 static int
sdev_unmount(struct vfs * vfsp,int flag,struct cred * cr)3552621Sllai1 sdev_unmount(struct vfs *vfsp, int flag, struct cred *cr)
3562621Sllai1 {
3572621Sllai1 	struct sdev_node *dv;
3582621Sllai1 	int error;
3592621Sllai1 	struct sdev_data *sdev_data, *prev, *next;
3602621Sllai1 
3612621Sllai1 	/*
3622621Sllai1 	 * enforce the security policies
3632621Sllai1 	 */
3642621Sllai1 	if ((secpolicy_fs_unmount(cr, vfsp) != 0) ||
3652621Sllai1 	    (secpolicy_sys_devices(cr) != 0))
3662621Sllai1 		return (EPERM);
3672621Sllai1 
3682621Sllai1 	if (flag & MS_FORCE)
3692621Sllai1 		return (ENOTSUP);
3702621Sllai1 
3712621Sllai1 	mutex_enter(&sdev_lock);
3722621Sllai1 	dv = VFSTOSDEVFS(vfsp)->sdev_root;
3732621Sllai1 	ASSERT(dv == dv->sdev_dotdot);
3742621Sllai1 	if (SDEVTOV(dv)->v_count > 1) {
3752621Sllai1 		mutex_exit(&sdev_lock);
3762621Sllai1 		return (EBUSY);
3772621Sllai1 	}
3782621Sllai1 
3792621Sllai1 	/*
3802621Sllai1 	 * global instance remains mounted
3812621Sllai1 	 */
3822621Sllai1 	if (SDEV_IS_GLOBAL(dv)) {
3832621Sllai1 		mutex_exit(&sdev_lock);
3842621Sllai1 		return (EBUSY);
3852621Sllai1 	}
3862621Sllai1 	mutex_exit(&sdev_lock);
3872621Sllai1 
3882621Sllai1 	/* verify the v_count */
3892621Sllai1 	if ((error = sdev_cleandir(dv, NULL, 0)) != 0) {
3902621Sllai1 		return (error);
3912621Sllai1 	}
3922621Sllai1 	ASSERT(SDEVTOV(dv)->v_count == 1);
3932621Sllai1 
3942621Sllai1 	/* release hold on root node and destroy it */
3952621Sllai1 	SDEV_RELE(dv);
3962621Sllai1 	dv->sdev_nlink -= 2;
3972621Sllai1 	sdev_nodedestroy(dv, 0);
3982621Sllai1 
3992621Sllai1 	sdev_data = (struct sdev_data *)vfsp->vfs_data;
4002621Sllai1 	vfsp->vfs_data = (caddr_t)0;
4012621Sllai1 
4022621Sllai1 	/*
4032621Sllai1 	 * XXX separate it into sdev_delete_mntinfo() if useful
4042621Sllai1 	 */
4052621Sllai1 	mutex_enter(&sdev_lock);
4062621Sllai1 	prev = sdev_data->sdev_prev;
4072621Sllai1 	next = sdev_data->sdev_next;
4082621Sllai1 	if (prev)
4092621Sllai1 		prev->sdev_next = next;
4102621Sllai1 	else
4112621Sllai1 		sdev_mntinfo = next;
4122621Sllai1 	if (next)
4132621Sllai1 		next->sdev_prev = prev;
4142621Sllai1 	mutex_exit(&sdev_lock);
4152621Sllai1 
4162621Sllai1 	if (sdev_data->sdev_mountargs) {
4172621Sllai1 		kmem_free(sdev_data->sdev_mountargs,
4182621Sllai1 		    sizeof (struct sdev_mountargs));
4192621Sllai1 	}
4202621Sllai1 	kmem_free(sdev_data, sizeof (struct sdev_data));
4212621Sllai1 	return (0);
4222621Sllai1 }
4232621Sllai1 
4242621Sllai1 /*
4252621Sllai1  * return root vnode for given vfs
4262621Sllai1  */
4272621Sllai1 static int
sdev_root(struct vfs * vfsp,struct vnode ** vpp)4282621Sllai1 sdev_root(struct vfs *vfsp, struct vnode **vpp)
4292621Sllai1 {
4302621Sllai1 	*vpp = SDEVTOV(VFSTOSDEVFS(vfsp)->sdev_root);
4312621Sllai1 	VN_HOLD(*vpp);
4322621Sllai1 	return (0);
4332621Sllai1 }
4342621Sllai1 
4352621Sllai1 /*
4362621Sllai1  * return 'generic superblock' information to userland.
4372621Sllai1  *
4382621Sllai1  * not much that we can usefully admit to here
4392621Sllai1  */
4402621Sllai1 static int
sdev_statvfs(struct vfs * vfsp,struct statvfs64 * sbp)4412621Sllai1 sdev_statvfs(struct vfs *vfsp, struct statvfs64 *sbp)
4422621Sllai1 {
4432621Sllai1 	dev32_t d32;
4442621Sllai1 
4452621Sllai1 	bzero(sbp, sizeof (*sbp));
4462621Sllai1 	sbp->f_frsize = sbp->f_bsize = vfsp->vfs_bsize;
4472621Sllai1 	sbp->f_files = kmem_cache_stat(sdev_node_cache, "alloc");
4482621Sllai1 
4492621Sllai1 	/* no illusions that free/avail files is relevant to dev */
4502621Sllai1 	sbp->f_ffree = 0;
4512621Sllai1 	sbp->f_favail = 0;
4522621Sllai1 
4532621Sllai1 	/* no illusions that blocks are relevant to devfs */
4542621Sllai1 	sbp->f_bfree = 0;
4552621Sllai1 	sbp->f_bavail = 0;
4562621Sllai1 	sbp->f_blocks = 0;
4572621Sllai1 
4582621Sllai1 	(void) cmpldev(&d32, vfsp->vfs_dev);
4592621Sllai1 	sbp->f_fsid = d32;
4602621Sllai1 	(void) strcpy(sbp->f_basetype, vfssw[devtype].vsw_name);
4612621Sllai1 	sbp->f_flag = vf_to_stf(vfsp->vfs_flag);
4622621Sllai1 	sbp->f_namemax = MAXNAMELEN - 1;
4632621Sllai1 	(void) strcpy(sbp->f_fstr, "dev");
4642621Sllai1 
4652621Sllai1 	return (0);
4662621Sllai1 }
4672621Sllai1 
4682621Sllai1 static void
sdev_insert_mntinfo(struct sdev_data * data)4692621Sllai1 sdev_insert_mntinfo(struct sdev_data *data)
4702621Sllai1 {
4712621Sllai1 	ASSERT(mutex_owned(&sdev_lock));
4722621Sllai1 	data->sdev_next = sdev_mntinfo;
4732621Sllai1 	data->sdev_prev = NULL;
4742621Sllai1 	if (sdev_mntinfo) {
4752621Sllai1 		sdev_mntinfo->sdev_prev = data;
4762621Sllai1 	} else {
4772621Sllai1 		sdev_origins = data;
4782621Sllai1 	}
4792621Sllai1 	sdev_mntinfo = data;
4802621Sllai1 }
4812621Sllai1 
4822621Sllai1 struct sdev_data *
sdev_find_mntinfo(char * mntpt)4832621Sllai1 sdev_find_mntinfo(char *mntpt)
4842621Sllai1 {
4852621Sllai1 	struct sdev_data *mntinfo;
4862621Sllai1 
4872621Sllai1 	mutex_enter(&sdev_lock);
4882621Sllai1 	mntinfo = sdev_mntinfo;
4892621Sllai1 	while (mntinfo) {
4902621Sllai1 		if (strcmp(mntpt, mntinfo->sdev_root->sdev_name) == 0) {
4912621Sllai1 			SDEVTOV(mntinfo->sdev_root)->v_count++;
4922621Sllai1 			break;
4932621Sllai1 		}
4942621Sllai1 		mntinfo = mntinfo->sdev_next;
4952621Sllai1 	}
4962621Sllai1 	mutex_exit(&sdev_lock);
4972621Sllai1 	return (mntinfo);
4982621Sllai1 }
4992621Sllai1 
5002621Sllai1 void
sdev_mntinfo_rele(struct sdev_data * mntinfo)5012621Sllai1 sdev_mntinfo_rele(struct sdev_data *mntinfo)
5022621Sllai1 {
5032621Sllai1 	mutex_enter(&sdev_lock);
5042621Sllai1 	SDEVTOV(mntinfo->sdev_root)->v_count--;
5052621Sllai1 	mutex_exit(&sdev_lock);
5062621Sllai1 }
507