Home | History | Annotate | Line # | Download | only in coda
coda_vfsops.c revision 1.26.2.9
      1 /*	$NetBSD: coda_vfsops.c,v 1.26.2.9 2005/01/17 19:30:28 skrll 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.26.2.9 2005/01/17 19:30:28 skrll 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 
    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(vfsp, path, data, ndp, l)
    153     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 lwp *l;		/* The ever-famous lwp pointer */
    158 {
    159     struct vnode *dvp;
    160     struct cnode *cp;
    161     dev_t dev;
    162     struct coda_mntinfo *mi;
    163     struct vnode *rootvp;
    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, l);
    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     rootvp = CTOV(cp);
    244     rootvp->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 = rootvp;
    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 	l);
    274 }
    275 
    276 int
    277 coda_start(vfsp, flags, l)
    278     struct mount *vfsp;
    279     int flags;
    280     struct lwp *l;
    281 {
    282     ENTRY;
    283     vftomi(vfsp)->mi_started = 1;
    284     return (0);
    285 }
    286 
    287 int
    288 coda_unmount(vfsp, mntflags, l)
    289     struct mount *vfsp;
    290     int mntflags;
    291     struct lwp *l;
    292 {
    293     struct coda_mntinfo *mi = vftomi(vfsp);
    294     int active, error = 0;
    295 
    296     ENTRY;
    297     MARK_ENTRY(CODA_UMOUNT_STATS);
    298     if (!CODA_MOUNTED(vfsp)) {
    299 	MARK_INT_FAIL(CODA_UMOUNT_STATS);
    300 	return(EINVAL);
    301     }
    302 
    303     if (mi->mi_vfsp == vfsp) {	/* We found the victim */
    304 	if (!IS_UNMOUNTING(VTOC(mi->mi_rootvp)))
    305 	    return (EBUSY); 	/* Venus is still running */
    306 
    307 #ifdef	DEBUG
    308 	printf("coda_unmount: ROOT: vp %p, cp %p\n", mi->mi_rootvp, VTOC(mi->mi_rootvp));
    309 #endif
    310 	mi->mi_started = 0;
    311 
    312 	vrele(mi->mi_rootvp);
    313 
    314 	active = coda_kill(vfsp, NOT_DOWNCALL);
    315 	mi->mi_rootvp->v_flag &= ~VROOT;
    316 	error = vflush(mi->mi_vfsp, NULLVP, FORCECLOSE);
    317 	printf("coda_unmount: active = %d, vflush active %d\n", active, error);
    318 	error = 0;
    319 
    320 	/* I'm going to take this out to allow lookups to go through. I'm
    321 	 * not sure it's important anyway. -- DCS 2/2/94
    322 	 */
    323 	/* vfsp->VFS_DATA = NULL; */
    324 
    325 	/* No more vfsp's to hold onto */
    326 	mi->mi_vfsp = NULL;
    327 	mi->mi_rootvp = NULL;
    328 
    329 	if (error)
    330 	    MARK_INT_FAIL(CODA_UMOUNT_STATS);
    331 	else
    332 	    MARK_INT_SAT(CODA_UMOUNT_STATS);
    333 
    334 	return(error);
    335     }
    336     return (EINVAL);
    337 }
    338 
    339 /*
    340  * find root of cfs
    341  */
    342 int
    343 coda_root(vfsp, vpp)
    344 	struct mount *vfsp;
    345 	struct vnode **vpp;
    346 {
    347     struct coda_mntinfo *mi = vftomi(vfsp);
    348     int error;
    349     struct proc *p = curproc;    /* XXX - bnoble */
    350     CodaFid VFid;
    351     static const CodaFid invalfid = INVAL_FID;
    352 
    353     ENTRY;
    354     MARK_ENTRY(CODA_ROOT_STATS);
    355 
    356     if (vfsp == mi->mi_vfsp) {
    357     	if (memcmp(&VTOC(mi->mi_rootvp)->c_fid, &invalfid, sizeof(CodaFid)))
    358 	    { /* Found valid root. */
    359 		*vpp = mi->mi_rootvp;
    360 		/* On Mach, this is vref.  On NetBSD, VOP_LOCK */
    361 		vref(*vpp);
    362 		vn_lock(*vpp, LK_EXCLUSIVE);
    363 		MARK_INT_SAT(CODA_ROOT_STATS);
    364 		return(0);
    365 	    }
    366     }
    367 
    368     error = venus_root(vftomi(vfsp), p->p_cred->pc_ucred, p, &VFid);
    369 
    370     if (!error) {
    371 	/*
    372 	 * Save the new rootfid in the cnode, and rehash the cnode into the
    373 	 * cnode hash with the new fid key.
    374 	 */
    375 	coda_unsave(VTOC(mi->mi_rootvp));
    376 	VTOC(mi->mi_rootvp)->c_fid = VFid;
    377 	coda_save(VTOC(mi->mi_rootvp));
    378 
    379 	*vpp = mi->mi_rootvp;
    380 	vref(*vpp);
    381 	vn_lock(*vpp, LK_EXCLUSIVE);
    382 	MARK_INT_SAT(CODA_ROOT_STATS);
    383 	goto exit;
    384     } else if (error == ENODEV || error == EINTR) {
    385 	/* Gross hack here! */
    386 	/*
    387 	 * If Venus fails to respond to the CODA_ROOT call, coda_call returns
    388 	 * ENODEV. Return the uninitialized root vnode to allow vfs
    389 	 * operations such as unmount to continue. Without this hack,
    390 	 * there is no way to do an unmount if Venus dies before a
    391 	 * successful CODA_ROOT call is done. All vnode operations
    392 	 * will fail.
    393 	 */
    394 	*vpp = mi->mi_rootvp;
    395 	vref(*vpp);
    396 	vn_lock(*vpp, LK_EXCLUSIVE);
    397 	MARK_INT_FAIL(CODA_ROOT_STATS);
    398 	error = 0;
    399 	goto exit;
    400     } else {
    401 	CODADEBUG( CODA_ROOT, myprintf(("error %d in CODA_ROOT\n", error)); );
    402 	MARK_INT_FAIL(CODA_ROOT_STATS);
    403 
    404 	goto exit;
    405     }
    406  exit:
    407     return(error);
    408 }
    409 
    410 int
    411 coda_quotactl(vfsp, cmd, uid, arg, l)
    412     struct mount *vfsp;
    413     int cmd;
    414     uid_t uid;
    415     void *arg;
    416     struct lwp *l;
    417 {
    418     ENTRY;
    419     return (EOPNOTSUPP);
    420 }
    421 
    422 /*
    423  * Get file system statistics.
    424  */
    425 int
    426 coda_nb_statvfs(vfsp, sbp, l)
    427     struct mount *vfsp;
    428     struct statvfs *sbp;
    429     struct lwp *l;
    430 {
    431     struct coda_statfs fsstat;
    432     struct proc *p = l->l_proc;
    433     int error;
    434 
    435     ENTRY;
    436     MARK_ENTRY(CODA_STATFS_STATS);
    437     if (!CODA_MOUNTED(vfsp)) {
    438 /*	MARK_INT_FAIL(CODA_STATFS_STATS); */
    439 	return(EINVAL);
    440     }
    441 
    442     /* XXX - what to do about f_flags, others? --bnoble */
    443     /* Below This is what AFS does
    444     	#define NB_SFS_SIZ 0x895440
    445      */
    446     /* Note: Normal fs's have a bsize of 0x400 == 1024 */
    447 
    448     error = venus_statfs(vftomi(vfsp), p->p_cred->pc_ucred, l, &fsstat);
    449 
    450     if (!error) {
    451 	sbp->f_bsize = 8192; /* XXX */
    452 	sbp->f_frsize = 8192; /* XXX */
    453 	sbp->f_iosize = 8192; /* XXX */
    454 	sbp->f_blocks = fsstat.f_blocks;
    455 	sbp->f_bfree  = fsstat.f_bfree;
    456 	sbp->f_bavail = fsstat.f_bavail;
    457 	sbp->f_bresvd = 0;
    458 	sbp->f_files  = fsstat.f_files;
    459 	sbp->f_ffree  = fsstat.f_ffree;
    460 	sbp->f_favail = fsstat.f_ffree;
    461 	sbp->f_fresvd = 0;
    462 	copy_statvfs_info(sbp, vfsp);
    463     }
    464 
    465     MARK_INT_SAT(CODA_STATFS_STATS);
    466     return(error);
    467 }
    468 
    469 /*
    470  * Flush any pending I/O.
    471  */
    472 int
    473 coda_sync(vfsp, waitfor, cred, l)
    474     struct mount *vfsp;
    475     int    waitfor;
    476     struct ucred *cred;
    477     struct lwp *l;
    478 {
    479     ENTRY;
    480     MARK_ENTRY(CODA_SYNC_STATS);
    481     MARK_INT_SAT(CODA_SYNC_STATS);
    482     return(0);
    483 }
    484 
    485 int
    486 coda_vget(vfsp, ino, vpp)
    487     struct mount *vfsp;
    488     ino_t ino;
    489     struct vnode **vpp;
    490 {
    491     ENTRY;
    492     return (EOPNOTSUPP);
    493 }
    494 
    495 /*
    496  * fhtovp is now what vget used to be in 4.3-derived systems.  For
    497  * some silly reason, vget is now keyed by a 32 bit ino_t, rather than
    498  * a type-specific fid.
    499  */
    500 int
    501 coda_fhtovp(vfsp, fhp, nam, vpp, exflagsp, creadanonp)
    502     struct mount *vfsp;
    503     struct fid *fhp;
    504     struct mbuf *nam;
    505     struct vnode **vpp;
    506     int *exflagsp;
    507     struct ucred **creadanonp;
    508 {
    509     struct cfid *cfid = (struct cfid *)fhp;
    510     struct cnode *cp = 0;
    511     int error;
    512     struct proc *p = curproc; /* XXX -mach */
    513     CodaFid VFid;
    514     int vtype;
    515 
    516     ENTRY;
    517 
    518     MARK_ENTRY(CODA_VGET_STATS);
    519     /* Check for vget of control object. */
    520     if (IS_CTL_FID(&cfid->cfid_fid)) {
    521 	*vpp = coda_ctlvp;
    522 	vref(coda_ctlvp);
    523 	MARK_INT_SAT(CODA_VGET_STATS);
    524 	return(0);
    525     }
    526 
    527     error = venus_fhtovp(vftomi(vfsp), &cfid->cfid_fid, p->p_cred->pc_ucred, p, &VFid, &vtype);
    528 
    529     if (error) {
    530 	CODADEBUG(CODA_VGET, myprintf(("vget error %d\n",error));)
    531 	    *vpp = (struct vnode *)0;
    532     } else {
    533 	CODADEBUG(CODA_VGET,
    534 		 myprintf(("vget: %s type %d result %d\n",
    535 			coda_f2s(&VFid), vtype, error)); )
    536 
    537 	cp = make_coda_node(&VFid, vfsp, vtype);
    538 	*vpp = CTOV(cp);
    539     }
    540     return(error);
    541 }
    542 
    543 int
    544 coda_vptofh(vnp, fidp)
    545     struct vnode *vnp;
    546     struct fid   *fidp;
    547 {
    548     ENTRY;
    549     return (EOPNOTSUPP);
    550 }
    551 
    552 void
    553 coda_init(void)
    554 {
    555     ENTRY;
    556 }
    557 
    558 void
    559 coda_done(void)
    560 {
    561     ENTRY;
    562 }
    563 
    564 SYSCTL_SETUP(sysctl_vfs_coda_setup, "sysctl vfs.coda subtree setup")
    565 {
    566 	sysctl_createv(clog, 0, NULL, NULL,
    567 		       CTLFLAG_PERMANENT,
    568 		       CTLTYPE_NODE, "vfs", NULL,
    569 		       NULL, 0, NULL, 0,
    570 		       CTL_VFS, CTL_EOL);
    571 	sysctl_createv(clog, 0, NULL, NULL,
    572 		       CTLFLAG_PERMANENT,
    573 		       CTLTYPE_NODE, "coda",
    574 		       SYSCTL_DESCR("code vfs options"),
    575 		       NULL, 0, NULL, 0,
    576 		       CTL_VFS, 18, CTL_EOL);
    577 	/*
    578 	 * XXX the "18" above could be dynamic, thereby eliminating
    579 	 * one more instance of the "number to vfs" mapping problem,
    580 	 * but "18" is the order as taken from sys/mount.h
    581 	 */
    582 
    583 /*
    584 	sysctl_createv(clog, 0, NULL, NULL,
    585 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    586 		       CTLTYPE_INT, "clusterread",
    587 		       SYSCTL_DESCR( anyone? ),
    588 		       NULL, 0, &doclusterread, 0,
    589 		       CTL_VFS, 18, FFS_CLUSTERREAD, CTL_EOL);
    590 */
    591 }
    592 
    593 /*
    594  * To allow for greater ease of use, some vnodes may be orphaned when
    595  * Venus dies.  Certain operations should still be allowed to go
    596  * through, but without propagating orphan-ness.  So this function will
    597  * get a new vnode for the file from the current run of Venus.
    598  */
    599 
    600 int
    601 getNewVnode(vpp)
    602      struct vnode **vpp;
    603 {
    604     struct cfid cfid;
    605     struct coda_mntinfo *mi = vftomi((*vpp)->v_mount);
    606 
    607     ENTRY;
    608 
    609     cfid.cfid_len = (short)sizeof(CodaFid);
    610     cfid.cfid_fid = VTOC(*vpp)->c_fid;	/* Structure assignment. */
    611     /* XXX ? */
    612 
    613     /* We're guessing that if set, the 1st element on the list is a
    614      * valid vnode to use. If not, return ENODEV as venus is dead.
    615      */
    616     if (mi->mi_vfsp == NULL)
    617 	return ENODEV;
    618 
    619     return coda_fhtovp(mi->mi_vfsp, (struct fid*)&cfid, NULL, vpp,
    620 		      NULL, NULL);
    621 }
    622 
    623 #include <ufs/ufs/quota.h>
    624 #include <ufs/ufs/ufsmount.h>
    625 /* get the mount structure corresponding to a given device.  Assume
    626  * device corresponds to a UFS. Return NULL if no device is found.
    627  */
    628 struct mount *devtomp(dev)
    629     dev_t dev;
    630 {
    631     struct mount *mp, *nmp;
    632 
    633     for (mp = mountlist.cqh_first; mp != (void*)&mountlist; mp = nmp) {
    634 	nmp = mp->mnt_list.cqe_next;
    635 	if ((!strcmp(mp->mnt_op->vfs_name, MOUNT_UFS)) &&
    636 	    ((VFSTOUFS(mp))->um_dev == (dev_t) dev)) {
    637 	    /* mount corresponds to UFS and the device matches one we want */
    638 	    return(mp);
    639 	}
    640     }
    641     /* mount structure wasn't found */
    642     return(NULL);
    643 }
    644