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