Home | History | Annotate | Line # | Download | only in coda
coda_vfsops.c revision 1.54
      1 /*	$NetBSD: coda_vfsops.c,v 1.54 2007/01/19 14:49:08 hannken Exp $	*/
      2 
      3 /*
      4  *
      5  *             Coda: an Experimental Distributed File System
      6  *                              Release 3.1
      7  *
      8  *           Copyright (c) 1987-1998 Carnegie Mellon University
      9  *                          All Rights Reserved
     10  *
     11  * Permission  to  use, copy, modify and distribute this software and its
     12  * documentation is hereby granted,  provided  that  both  the  copyright
     13  * notice  and  this  permission  notice  appear  in  all  copies  of the
     14  * software, derivative works or  modified  versions,  and  any  portions
     15  * thereof, and that both notices appear in supporting documentation, and
     16  * that credit is given to Carnegie Mellon University  in  all  documents
     17  * and publicity pertaining to direct or indirect use of this code or its
     18  * derivatives.
     19  *
     20  * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS  KNOWN  TO  HAVE  BUGS,
     21  * SOME  OF  WHICH MAY HAVE SERIOUS CONSEQUENCES.  CARNEGIE MELLON ALLOWS
     22  * FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.   CARNEGIE  MELLON
     23  * DISCLAIMS  ANY  LIABILITY  OF  ANY  KIND  FOR  ANY  DAMAGES WHATSOEVER
     24  * RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE  OR  OF
     25  * ANY DERIVATIVE WORK.
     26  *
     27  * Carnegie  Mellon  encourages  users  of  this  software  to return any
     28  * improvements or extensions that  they  make,  and  to  grant  Carnegie
     29  * Mellon the rights to redistribute these changes without encumbrance.
     30  *
     31  * 	@(#) cfs/coda_vfsops.c,v 1.1.1.1 1998/08/29 21:26:45 rvb Exp $
     32  */
     33 
     34 /*
     35  * Mach Operating System
     36  * Copyright (c) 1989 Carnegie-Mellon University
     37  * All rights reserved.  The CMU software License Agreement specifies
     38  * the terms and conditions for use and redistribution.
     39  */
     40 
     41 /*
     42  * This code was written for the Coda file system at Carnegie Mellon
     43  * University.  Contributers include David Steere, James Kistler, and
     44  * M. Satyanarayanan.
     45  */
     46 
     47 #include <sys/cdefs.h>
     48 __KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.54 2007/01/19 14:49:08 hannken Exp $");
     49 
     50 #ifdef	_LKM
     51 #define	NVCODA 4
     52 #else
     53 #include <vcoda.h>
     54 #endif
     55 
     56 #include <sys/param.h>
     57 #include <sys/systm.h>
     58 #include <sys/sysctl.h>
     59 #include <sys/malloc.h>
     60 #include <sys/conf.h>
     61 #include <sys/namei.h>
     62 #include <sys/dirent.h>
     63 #include <sys/mount.h>
     64 #include <sys/proc.h>
     65 #include <sys/select.h>
     66 #include <sys/kauth.h>
     67 
     68 #include <coda/coda.h>
     69 #include <coda/cnode.h>
     70 #include <coda/coda_vfsops.h>
     71 #include <coda/coda_venus.h>
     72 #include <coda/coda_subr.h>
     73 #include <coda/coda_opstats.h>
     74 /* for VN_RDEV */
     75 #include <miscfs/specfs/specdev.h>
     76 
     77 MALLOC_DEFINE(M_CODA, "coda", "Coda file system structures and tables");
     78 
     79 int codadebug = 0;
     80 
     81 int coda_vfsop_print_entry = 0;
     82 #define ENTRY if(coda_vfsop_print_entry) myprintf(("Entered %s\n",__func__))
     83 
     84 struct vnode *coda_ctlvp;
     85 struct coda_mntinfo coda_mnttbl[NVCODA]; /* indexed by minor device number */
     86 
     87 /* structure to keep statistics of internally generated/satisfied calls */
     88 
     89 struct coda_op_stats coda_vfsopstats[CODA_VFSOPS_SIZE];
     90 
     91 #define MARK_ENTRY(op) (coda_vfsopstats[op].entries++)
     92 #define MARK_INT_SAT(op) (coda_vfsopstats[op].sat_intrn++)
     93 #define MARK_INT_FAIL(op) (coda_vfsopstats[op].unsat_intrn++)
     94 #define MRAK_INT_GEN(op) (coda_vfsopstats[op].gen_intrn++)
     95 
     96 extern const struct cdevsw vcoda_cdevsw;
     97 extern const struct vnodeopv_desc coda_vnodeop_opv_desc;
     98 
     99 const struct vnodeopv_desc * const coda_vnodeopv_descs[] = {
    100 	&coda_vnodeop_opv_desc,
    101 	NULL,
    102 };
    103 
    104 struct vfsops coda_vfsops = {
    105     MOUNT_CODA,
    106     coda_mount,
    107     coda_start,
    108     coda_unmount,
    109     coda_root,
    110     coda_quotactl,
    111     coda_nb_statvfs,
    112     coda_sync,
    113     coda_vget,
    114     (void *)eopnotsupp,	/* vfs_fhtovp */
    115     (void *)eopnotsupp,	/* vfs_vptofh */
    116     coda_init,
    117     NULL,		/* vfs_reinit */
    118     coda_done,
    119     (int (*)(void)) eopnotsupp,
    120     (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp,
    121     vfs_stdextattrctl,
    122     vfs_stdsuspendctl,
    123     coda_vnodeopv_descs,
    124     0,			/* vfs_refcount */
    125     { NULL, NULL },	/* vfs_list */
    126 };
    127 
    128 VFS_ATTACH(coda_vfsops);
    129 
    130 int
    131 coda_vfsopstats_init(void)
    132 {
    133 	int i;
    134 
    135 	for (i=0;i<CODA_VFSOPS_SIZE;i++) {
    136 		coda_vfsopstats[i].opcode = i;
    137 		coda_vfsopstats[i].entries = 0;
    138 		coda_vfsopstats[i].sat_intrn = 0;
    139 		coda_vfsopstats[i].unsat_intrn = 0;
    140 		coda_vfsopstats[i].gen_intrn = 0;
    141 	}
    142 
    143 	return 0;
    144 }
    145 
    146 /*
    147  * cfs mount vfsop
    148  * Set up mount info record and attach it to vfs struct.
    149  */
    150 /*ARGSUSED*/
    151 int
    152 coda_mount(struct mount *vfsp,	/* Allocated and initialized by mount(2) */
    153     const char *path,	/* path covered: ignored by the fs-layer */
    154     void *data,		/* Need to define a data type for this in netbsd? */
    155     struct nameidata *ndp,	/* Clobber this to lookup the device name */
    156     struct lwp *l)		/* The ever-famous lwp pointer */
    157 {
    158     struct vnode *dvp;
    159     struct cnode *cp;
    160     dev_t dev;
    161     struct coda_mntinfo *mi;
    162     struct vnode *rtvp;
    163     const struct cdevsw *cdev;
    164     CodaFid rootfid = INVAL_FID;
    165     CodaFid ctlfid = CTL_FID;
    166     int error;
    167 
    168     if (vfsp->mnt_flag & MNT_GETARGS)
    169 	return 0;
    170     ENTRY;
    171 
    172     coda_vfsopstats_init();
    173     coda_vnodeopstats_init();
    174 
    175     MARK_ENTRY(CODA_MOUNT_STATS);
    176     if (CODA_MOUNTED(vfsp)) {
    177 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    178 	return(EBUSY);
    179     }
    180 
    181     /* Validate mount device.  Similar to getmdev(). */
    182 
    183     NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, data, l);
    184     error = namei(ndp);
    185     dvp = ndp->ni_vp;
    186 
    187     if (error) {
    188 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    189 	return (error);
    190     }
    191     if (dvp->v_type != VCHR) {
    192 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    193 	vrele(dvp);
    194 	return(ENXIO);
    195     }
    196     dev = dvp->v_specinfo->si_rdev;
    197     vrele(dvp);
    198     cdev = cdevsw_lookup(dev);
    199     if (cdev == NULL) {
    200 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    201 	return(ENXIO);
    202     }
    203 
    204     /*
    205      * See if the device table matches our expectations.
    206      */
    207     if (cdev != &vcoda_cdevsw)
    208     {
    209 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    210 	return(ENXIO);
    211     }
    212 
    213     if (minor(dev) >= NVCODA || minor(dev) < 0) {
    214 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    215 	return(ENXIO);
    216     }
    217 
    218     /*
    219      * Initialize the mount record and link it to the vfs struct
    220      */
    221     mi = &coda_mnttbl[minor(dev)];
    222 
    223     if (!VC_OPEN(&mi->mi_vcomm)) {
    224 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    225 	return(ENODEV);
    226     }
    227 
    228     /* No initialization (here) of mi_vcomm! */
    229     vfsp->mnt_data = mi;
    230     vfsp->mnt_stat.f_fsidx.__fsid_val[0] = 0;
    231     vfsp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_CODA);
    232     vfsp->mnt_stat.f_fsid = vfsp->mnt_stat.f_fsidx.__fsid_val[0];
    233     vfsp->mnt_stat.f_namemax = MAXNAMLEN;
    234     mi->mi_vfsp = vfsp;
    235 
    236     /*
    237      * Make a root vnode to placate the Vnode interface, but don't
    238      * actually make the CODA_ROOT call to venus until the first call
    239      * to coda_root in case a server is down while venus is starting.
    240      */
    241     cp = make_coda_node(&rootfid, vfsp, VDIR);
    242     rtvp = CTOV(cp);
    243     rtvp->v_flag |= VROOT;
    244 
    245 /*  cp = make_coda_node(&ctlfid, vfsp, VCHR);
    246     The above code seems to cause a loop in the cnode links.
    247     I don't totally understand when it happens, it is caught
    248     when closing down the system.
    249  */
    250     cp = make_coda_node(&ctlfid, 0, VCHR);
    251 
    252     coda_ctlvp = CTOV(cp);
    253 
    254     /* Add vfs and rootvp to chain of vfs hanging off mntinfo */
    255     mi->mi_vfsp = vfsp;
    256     mi->mi_rootvp = rtvp;
    257 
    258     /* set filesystem block size */
    259     vfsp->mnt_stat.f_bsize = 8192;	    /* XXX -JJK */
    260     vfsp->mnt_stat.f_frsize = 8192;	    /* XXX -JJK */
    261 
    262     /* error is currently guaranteed to be zero, but in case some
    263        code changes... */
    264     CODADEBUG(1,
    265 	     myprintf(("coda_mount returned %d\n",error)););
    266     if (error)
    267 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    268     else
    269 	MARK_INT_SAT(CODA_MOUNT_STATS);
    270 
    271     return set_statvfs_info("/coda", UIO_SYSSPACE, "CODA", UIO_SYSSPACE, vfsp,
    272 	l);
    273 }
    274 
    275 int
    276 coda_start(struct mount *vfsp, int flags, struct lwp *l)
    277 {
    278     ENTRY;
    279     vftomi(vfsp)->mi_started = 1;
    280     return (0);
    281 }
    282 
    283 int
    284 coda_unmount(struct mount *vfsp, int mntflags, struct lwp *l)
    285 {
    286     struct coda_mntinfo *mi = vftomi(vfsp);
    287     int active, error = 0;
    288 
    289     ENTRY;
    290     MARK_ENTRY(CODA_UMOUNT_STATS);
    291     if (!CODA_MOUNTED(vfsp)) {
    292 	MARK_INT_FAIL(CODA_UMOUNT_STATS);
    293 	return(EINVAL);
    294     }
    295 
    296     if (mi->mi_vfsp == vfsp) {	/* We found the victim */
    297 	if (!IS_UNMOUNTING(VTOC(mi->mi_rootvp)))
    298 	    return (EBUSY); 	/* Venus is still running */
    299 
    300 #ifdef	DEBUG
    301 	printf("coda_unmount: ROOT: vp %p, cp %p\n", mi->mi_rootvp, VTOC(mi->mi_rootvp));
    302 #endif
    303 	mi->mi_started = 0;
    304 
    305 	vrele(mi->mi_rootvp);
    306 
    307 	active = coda_kill(vfsp, NOT_DOWNCALL);
    308 	mi->mi_rootvp->v_flag &= ~VROOT;
    309 	error = vflush(mi->mi_vfsp, NULLVP, FORCECLOSE);
    310 	printf("coda_unmount: active = %d, vflush active %d\n", active, error);
    311 	error = 0;
    312 
    313 	/* I'm going to take this out to allow lookups to go through. I'm
    314 	 * not sure it's important anyway. -- DCS 2/2/94
    315 	 */
    316 	/* vfsp->VFS_DATA = NULL; */
    317 
    318 	/* No more vfsp's to hold onto */
    319 	mi->mi_vfsp = NULL;
    320 	mi->mi_rootvp = NULL;
    321 
    322 	if (error)
    323 	    MARK_INT_FAIL(CODA_UMOUNT_STATS);
    324 	else
    325 	    MARK_INT_SAT(CODA_UMOUNT_STATS);
    326 
    327 	return(error);
    328     }
    329     return (EINVAL);
    330 }
    331 
    332 /*
    333  * find root of cfs
    334  */
    335 int
    336 coda_root(struct mount *vfsp, struct vnode **vpp)
    337 {
    338     struct coda_mntinfo *mi = vftomi(vfsp);
    339     int error;
    340     struct lwp *l = curlwp;    /* XXX - bnoble */
    341     CodaFid VFid;
    342     static const CodaFid invalfid = INVAL_FID;
    343 
    344     ENTRY;
    345     MARK_ENTRY(CODA_ROOT_STATS);
    346 
    347     if (vfsp == mi->mi_vfsp) {
    348     	if (memcmp(&VTOC(mi->mi_rootvp)->c_fid, &invalfid, sizeof(CodaFid)))
    349 	    { /* Found valid root. */
    350 		*vpp = mi->mi_rootvp;
    351 		/* On Mach, this is vref.  On NetBSD, VOP_LOCK */
    352 		vref(*vpp);
    353 		vn_lock(*vpp, LK_EXCLUSIVE);
    354 		MARK_INT_SAT(CODA_ROOT_STATS);
    355 		return(0);
    356 	    }
    357     }
    358 
    359     error = venus_root(vftomi(vfsp), l->l_cred, l->l_proc, &VFid);
    360 
    361     if (!error) {
    362 	/*
    363 	 * Save the new rootfid in the cnode, and rehash the cnode into the
    364 	 * cnode hash with the new fid key.
    365 	 */
    366 	coda_unsave(VTOC(mi->mi_rootvp));
    367 	VTOC(mi->mi_rootvp)->c_fid = VFid;
    368 	coda_save(VTOC(mi->mi_rootvp));
    369 
    370 	*vpp = mi->mi_rootvp;
    371 	vref(*vpp);
    372 	vn_lock(*vpp, LK_EXCLUSIVE);
    373 	MARK_INT_SAT(CODA_ROOT_STATS);
    374 	goto exit;
    375     } else if (error == ENODEV || error == EINTR) {
    376 	/* Gross hack here! */
    377 	/*
    378 	 * If Venus fails to respond to the CODA_ROOT call, coda_call returns
    379 	 * ENODEV. Return the uninitialized root vnode to allow vfs
    380 	 * operations such as unmount to continue. Without this hack,
    381 	 * there is no way to do an unmount if Venus dies before a
    382 	 * successful CODA_ROOT call is done. All vnode operations
    383 	 * will fail.
    384 	 */
    385 	*vpp = mi->mi_rootvp;
    386 	vref(*vpp);
    387 	vn_lock(*vpp, LK_EXCLUSIVE);
    388 	MARK_INT_FAIL(CODA_ROOT_STATS);
    389 	error = 0;
    390 	goto exit;
    391     } else {
    392 	CODADEBUG( CODA_ROOT, myprintf(("error %d in CODA_ROOT\n", error)); );
    393 	MARK_INT_FAIL(CODA_ROOT_STATS);
    394 
    395 	goto exit;
    396     }
    397  exit:
    398     return(error);
    399 }
    400 
    401 int
    402 coda_quotactl(struct mount *vfsp, int cmd, uid_t uid,
    403     void *arg, struct lwp *l)
    404 {
    405     ENTRY;
    406     return (EOPNOTSUPP);
    407 }
    408 
    409 /*
    410  * Get file system statistics.
    411  */
    412 int
    413 coda_nb_statvfs(struct mount *vfsp, struct statvfs *sbp, struct lwp *l)
    414 {
    415     struct coda_statfs fsstat;
    416     int error;
    417 
    418     ENTRY;
    419     MARK_ENTRY(CODA_STATFS_STATS);
    420     if (!CODA_MOUNTED(vfsp)) {
    421 /*	MARK_INT_FAIL(CODA_STATFS_STATS); */
    422 	return(EINVAL);
    423     }
    424 
    425     /* XXX - what to do about f_flags, others? --bnoble */
    426     /* Below This is what AFS does
    427     	#define NB_SFS_SIZ 0x895440
    428      */
    429     /* Note: Normal fs's have a bsize of 0x400 == 1024 */
    430 
    431     error = venus_statfs(vftomi(vfsp), l->l_cred, l, &fsstat);
    432 
    433     if (!error) {
    434 	sbp->f_bsize = 8192; /* XXX */
    435 	sbp->f_frsize = 8192; /* XXX */
    436 	sbp->f_iosize = 8192; /* XXX */
    437 	sbp->f_blocks = fsstat.f_blocks;
    438 	sbp->f_bfree  = fsstat.f_bfree;
    439 	sbp->f_bavail = fsstat.f_bavail;
    440 	sbp->f_bresvd = 0;
    441 	sbp->f_files  = fsstat.f_files;
    442 	sbp->f_ffree  = fsstat.f_ffree;
    443 	sbp->f_favail = fsstat.f_ffree;
    444 	sbp->f_fresvd = 0;
    445 	copy_statvfs_info(sbp, vfsp);
    446     }
    447 
    448     MARK_INT_SAT(CODA_STATFS_STATS);
    449     return(error);
    450 }
    451 
    452 /*
    453  * Flush any pending I/O.
    454  */
    455 int
    456 coda_sync(struct mount *vfsp, int waitfor,
    457     kauth_cred_t cred, struct lwp *l)
    458 {
    459     ENTRY;
    460     MARK_ENTRY(CODA_SYNC_STATS);
    461     MARK_INT_SAT(CODA_SYNC_STATS);
    462     return(0);
    463 }
    464 
    465 int
    466 coda_vget(struct mount *vfsp, ino_t ino,
    467     struct vnode **vpp)
    468 {
    469     ENTRY;
    470     return (EOPNOTSUPP);
    471 }
    472 
    473 /*
    474  * fhtovp is now what vget used to be in 4.3-derived systems.  For
    475  * some silly reason, vget is now keyed by a 32 bit ino_t, rather than
    476  * a type-specific fid.
    477  */
    478 int
    479 coda_fhtovp(struct mount *vfsp, struct fid *fhp, struct mbuf *nam,
    480     struct vnode **vpp, int *exflagsp,
    481     kauth_cred_t *creadanonp)
    482 {
    483     struct cfid *cfid = (struct cfid *)fhp;
    484     struct cnode *cp = 0;
    485     int error;
    486     struct lwp *l = curlwp; /* XXX -mach */
    487     CodaFid VFid;
    488     int vtype;
    489 
    490     ENTRY;
    491 
    492     MARK_ENTRY(CODA_VGET_STATS);
    493     /* Check for vget of control object. */
    494     if (IS_CTL_FID(&cfid->cfid_fid)) {
    495 	*vpp = coda_ctlvp;
    496 	vref(coda_ctlvp);
    497 	MARK_INT_SAT(CODA_VGET_STATS);
    498 	return(0);
    499     }
    500 
    501     error = venus_fhtovp(vftomi(vfsp), &cfid->cfid_fid, l->l_cred, l->l_proc, &VFid, &vtype);
    502 
    503     if (error) {
    504 	CODADEBUG(CODA_VGET, myprintf(("vget error %d\n",error));)
    505 	    *vpp = (struct vnode *)0;
    506     } else {
    507 	CODADEBUG(CODA_VGET,
    508 		 myprintf(("vget: %s type %d result %d\n",
    509 			coda_f2s(&VFid), vtype, error)); )
    510 
    511 	cp = make_coda_node(&VFid, vfsp, vtype);
    512 	*vpp = CTOV(cp);
    513     }
    514     return(error);
    515 }
    516 
    517 int
    518 coda_vptofh(struct vnode *vnp, struct fid *fidp)
    519 {
    520     ENTRY;
    521     return (EOPNOTSUPP);
    522 }
    523 
    524 void
    525 coda_init(void)
    526 {
    527     ENTRY;
    528 }
    529 
    530 void
    531 coda_done(void)
    532 {
    533     ENTRY;
    534 }
    535 
    536 SYSCTL_SETUP(sysctl_vfs_coda_setup, "sysctl vfs.coda subtree setup")
    537 {
    538 	sysctl_createv(clog, 0, NULL, NULL,
    539 		       CTLFLAG_PERMANENT,
    540 		       CTLTYPE_NODE, "vfs", NULL,
    541 		       NULL, 0, NULL, 0,
    542 		       CTL_VFS, CTL_EOL);
    543 	sysctl_createv(clog, 0, NULL, NULL,
    544 		       CTLFLAG_PERMANENT,
    545 		       CTLTYPE_NODE, "coda",
    546 		       SYSCTL_DESCR("code vfs options"),
    547 		       NULL, 0, NULL, 0,
    548 		       CTL_VFS, 18, CTL_EOL);
    549 	/*
    550 	 * XXX the "18" above could be dynamic, thereby eliminating
    551 	 * one more instance of the "number to vfs" mapping problem,
    552 	 * but "18" is the order as taken from sys/mount.h
    553 	 */
    554 
    555 /*
    556 	sysctl_createv(clog, 0, NULL, NULL,
    557 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    558 		       CTLTYPE_INT, "clusterread",
    559 		       SYSCTL_DESCR( anyone? ),
    560 		       NULL, 0, &doclusterread, 0,
    561 		       CTL_VFS, 18, FFS_CLUSTERREAD, CTL_EOL);
    562 */
    563 }
    564 
    565 /*
    566  * To allow for greater ease of use, some vnodes may be orphaned when
    567  * Venus dies.  Certain operations should still be allowed to go
    568  * through, but without propagating orphan-ness.  So this function will
    569  * get a new vnode for the file from the current run of Venus.
    570  */
    571 
    572 int
    573 getNewVnode(struct vnode **vpp)
    574 {
    575     struct cfid cfid;
    576     struct coda_mntinfo *mi = vftomi((*vpp)->v_mount);
    577 
    578     ENTRY;
    579 
    580     cfid.cfid_len = (short)sizeof(CodaFid);
    581     cfid.cfid_fid = VTOC(*vpp)->c_fid;	/* Structure assignment. */
    582     /* XXX ? */
    583 
    584     /* We're guessing that if set, the 1st element on the list is a
    585      * valid vnode to use. If not, return ENODEV as venus is dead.
    586      */
    587     if (mi->mi_vfsp == NULL)
    588 	return ENODEV;
    589 
    590     return coda_fhtovp(mi->mi_vfsp, (struct fid*)&cfid, NULL, vpp,
    591 		      NULL, NULL);
    592 }
    593 
    594 #include <ufs/ufs/quota.h>
    595 #include <ufs/ufs/ufsmount.h>
    596 /* get the mount structure corresponding to a given device.  Assume
    597  * device corresponds to a UFS. Return NULL if no device is found.
    598  */
    599 struct mount *devtomp(dev_t dev)
    600 {
    601     struct mount *mp, *nmp;
    602 
    603     for (mp = mountlist.cqh_first; mp != (void*)&mountlist; mp = nmp) {
    604 	nmp = mp->mnt_list.cqe_next;
    605 	if ((!strcmp(mp->mnt_op->vfs_name, MOUNT_UFS)) &&
    606 	    ((VFSTOUFS(mp))->um_dev == (dev_t) dev)) {
    607 	    /* mount corresponds to UFS and the device matches one we want */
    608 	    return(mp);
    609 	}
    610     }
    611     /* mount structure wasn't found */
    612     return(NULL);
    613 }
    614