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