Home | History | Annotate | Line # | Download | only in coda
coda_vfsops.c revision 1.6
      1 /*	$NetBSD: coda_vfsops.c,v 1.6 1998/12/10 02:22:52 rvb 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 /*
     48  * HISTORY
     49  * $Log: coda_vfsops.c,v $
     50  * Revision 1.6  1998/12/10 02:22:52  rvb
     51  * Commit a couple of old fixes
     52  *
     53  * Revision 1.5  1998/09/25 15:01:13  rvb
     54  * Conditionalize "stray" printouts under DIAGNOSTIC and DEBUG.
     55  * Make files compile if DEBUG is on (from  Alan Barrett).  Finally,
     56  * make coda an lkm.
     57  *
     58  * Revision 1.4  1998/09/15 02:03:00  rvb
     59  * Final piece of rename cfs->coda
     60  *
     61  * Revision 1.3  1998/09/12 15:05:49  rvb
     62  * Change cfs/CFS in symbols, strings and constants to coda/CODA
     63  * to avoid fs conflicts.
     64  *
     65  * Revision 1.2  1998/09/08 17:12:47  rvb
     66  * Pass2 complete
     67  *
     68  * Revision 1.1.1.1  1998/08/29 21:26:45  rvb
     69  * Very Preliminary Coda
     70  *
     71  * Revision 1.11  1998/08/28 18:12:22  rvb
     72  * Now it also works on FreeBSD -current.  This code will be
     73  * committed to the FreeBSD -current and NetBSD -current
     74  * trees.  It will then be tailored to the particular platform
     75  * by flushing conditional code.
     76  *
     77  * Revision 1.10  1998/08/18 17:05:19  rvb
     78  * Don't use __RCSID now
     79  *
     80  * Revision 1.9  1998/08/18 16:31:44  rvb
     81  * Sync the code for NetBSD -current; test on 1.3 later
     82  *
     83  * Revision 1.8  98/02/24  22:22:48  rvb
     84  * Fixes up mainly to flush iopen and friends
     85  *
     86  * Revision 1.7  98/01/23  11:53:45  rvb
     87  * Bring RVB_CODA1_1 to HEAD
     88  *
     89  * Revision 1.6.2.6  98/01/23  11:21:07  rvb
     90  * Sync with 2.2.5
     91  *
     92  * Revision 1.6.2.5  98/01/22  13:05:33  rvb
     93  * Move make_coda_node ctlfid later so vfsp is known
     94  *
     95  * Revision 1.6.2.4  97/12/19  14:26:05  rvb
     96  * session id
     97  *
     98  * Revision 1.6.2.3  97/12/16  12:40:11  rvb
     99  * Sync with 1.3
    100  *
    101  * Revision 1.6.2.2  97/12/10  11:40:25  rvb
    102  * No more ody
    103  *
    104  * Revision 1.6.2.1  97/12/06  17:41:24  rvb
    105  * Sync with peters coda.h
    106  *
    107  * Revision 1.6  97/12/05  10:39:21  rvb
    108  * Read CHANGES
    109  *
    110  * Revision 1.5.14.8  97/11/24  15:44:46  rvb
    111  * Final cfs_venus.c w/o macros, but one locking bug
    112  *
    113  * Revision 1.5.14.7  97/11/21  13:22:03  rvb
    114  * Catch a few coda_calls in coda_vfsops.c
    115  *
    116  * Revision 1.5.14.6  97/11/20  11:46:48  rvb
    117  * Capture current cfs_venus
    118  *
    119  * Revision 1.5.14.5  97/11/18  10:27:17  rvb
    120  * cfs_nbsd.c is DEAD!!!; integrated into cfs_vf/vnops.c
    121  * cfs_nb_foo and cfs_foo are joined
    122  *
    123  * Revision 1.5.14.4  97/11/13  22:03:01  rvb
    124  * pass2 cfs_NetBSD.h mt
    125  *
    126  * Revision 1.5.14.3  97/11/12  12:09:40  rvb
    127  * reorg pass1
    128  *
    129  * Revision 1.5.14.2  97/10/29  16:06:28  rvb
    130  * Kill DYING
    131  *
    132  * Revision 1.5.14.1  1997/10/28 23:10:17  rvb
    133  * >64Meg; venus can be killed!
    134  *
    135  * Revision 1.5  1997/01/13 17:11:07  bnoble
    136  * Coda statfs needs to return something other than -1 for blocks avail. and
    137  * files available for wabi (and other windowsish) programs to install
    138  * there correctly.
    139  *
    140  * Revision 1.4  1996/12/12 22:11:00  bnoble
    141  * Fixed the "downcall invokes venus operation" deadlock in all known cases.
    142  * There may be more
    143  *
    144  * Revision 1.3  1996/11/08 18:06:12  bnoble
    145  * Minor changes in vnode operation signature, VOP_UPDATE signature, and
    146  * some newly defined bits in the include files.
    147  *
    148  * Revision 1.2  1996/01/02 16:57:04  bnoble
    149  * Added support for Coda MiniCache and raw inode calls (final commit)
    150  *
    151  * Revision 1.1.2.1  1995/12/20 01:57:32  bnoble
    152  * Added CODA-specific files
    153  *
    154  * Revision 3.1.1.1  1995/03/04  19:08:02  bnoble
    155  * Branch for NetBSD port revisions
    156  *
    157  * Revision 3.1  1995/03/04  19:08:01  bnoble
    158  * Bump to major revision 3 to prepare for NetBSD port
    159  *
    160  * Revision 2.4  1995/02/17  16:25:22  dcs
    161  * These versions represent several changes:
    162  * 1. Allow venus to restart even if outstanding references exist.
    163  * 2. Have only one ctlvp per client, as opposed to one per mounted cfs device.d
    164  * 3. Allow ody_expand to return many members, not just one.
    165  *
    166  * Revision 2.3  94/10/14  09:58:21  dcs
    167  * Made changes 'cause sun4s have braindead compilers
    168  *
    169  * Revision 2.2  94/10/12  16:46:33  dcs
    170  * Cleaned kernel/venus interface by removing XDR junk, plus
    171  * so cleanup to allow this code to be more easily ported.
    172  *
    173  * Revision 1.3  93/05/28  16:24:29  bnoble
    174  * *** empty log message ***
    175  *
    176  * Revision 1.2  92/10/27  17:58:24  lily
    177  * merge kernel/latest and alpha/src/cfs
    178  *
    179  * Revision 2.3  92/09/30  14:16:32  mja
    180  * 	Added call to coda_flush to coda_unmount.
    181  * 	[90/12/15            dcs]
    182  *
    183  * 	Added contributors blurb.
    184  * 	[90/12/13            jjk]
    185  *
    186  * Revision 2.2  90/07/05  11:26:40  mrt
    187  * 	Created for the Coda File System.
    188  * 	[90/05/23            dcs]
    189  *
    190  * Revision 1.3  90/05/31  17:01:42  dcs
    191  * Prepare for merge with facilities kernel.
    192  *
    193  *
    194  */
    195 
    196 #ifdef	_LKM
    197 #define	NVCODA 4
    198 #else
    199 #include <vcoda.h>
    200 #endif
    201 
    202 #include <sys/param.h>
    203 #include <sys/systm.h>
    204 #include <sys/malloc.h>
    205 #include <sys/conf.h>
    206 #include <sys/namei.h>
    207 #include <sys/mount.h>
    208 #include <sys/proc.h>
    209 #include <sys/select.h>
    210 
    211 #include <coda/coda.h>
    212 #include <coda/cnode.h>
    213 #include <coda/coda_vfsops.h>
    214 #include <coda/coda_venus.h>
    215 #include <coda/coda_subr.h>
    216 #include <coda/coda_opstats.h>
    217 /* for VN_RDEV */
    218 #include <miscfs/specfs/specdev.h>
    219 
    220 int codadebug = 0;
    221 
    222 int coda_vfsop_print_entry = 0;
    223 #define ENTRY if(coda_vfsop_print_entry) myprintf(("Entered %s\n",__FUNCTION__))
    224 
    225 struct vnode *coda_ctlvp;
    226 struct coda_mntinfo coda_mnttbl[NVCODA]; /* indexed by minor device number */
    227 
    228 /* structure to keep statistics of internally generated/satisfied calls */
    229 
    230 struct coda_op_stats coda_vfsopstats[CODA_VFSOPS_SIZE];
    231 
    232 #define MARK_ENTRY(op) (coda_vfsopstats[op].entries++)
    233 #define MARK_INT_SAT(op) (coda_vfsopstats[op].sat_intrn++)
    234 #define MARK_INT_FAIL(op) (coda_vfsopstats[op].unsat_intrn++)
    235 #define MRAK_INT_GEN(op) (coda_vfsopstats[op].gen_intrn++)
    236 
    237 extern int coda_nc_initialized;     /* Set if cache has been initialized */
    238 extern int vc_nb_open __P((dev_t, int, int, struct proc *));
    239 extern struct cdevsw cdevsw[];    /* For sanity check in coda_mount */
    240 extern struct vnodeopv_desc coda_vnodeop_opv_desc;
    241 
    242 struct vnodeopv_desc *coda_vnodeopv_descs[] = {
    243 	&coda_vnodeop_opv_desc,
    244 	NULL,
    245 };
    246 
    247 struct vfsops coda_vfsops = {
    248     MOUNT_CODA,
    249     coda_mount,
    250     coda_start,
    251     coda_unmount,
    252     coda_root,
    253     coda_quotactl,
    254     coda_nb_statfs,
    255     coda_sync,
    256     coda_vget,
    257     (int (*) (struct mount *, struct fid *, struct mbuf *, struct vnode **,
    258 	      int *, struct ucred **))
    259 	eopnotsupp,
    260     (int (*) (struct vnode *, struct fid *)) eopnotsupp,
    261     coda_init,
    262     coda_sysctl,
    263     (int (*)(void)) eopnotsupp,
    264     coda_vnodeopv_descs,
    265     0
    266 };
    267 
    268 int
    269 coda_vfsopstats_init(void)
    270 {
    271 	register int i;
    272 
    273 	for (i=0;i<CODA_VFSOPS_SIZE;i++) {
    274 		coda_vfsopstats[i].opcode = i;
    275 		coda_vfsopstats[i].entries = 0;
    276 		coda_vfsopstats[i].sat_intrn = 0;
    277 		coda_vfsopstats[i].unsat_intrn = 0;
    278 		coda_vfsopstats[i].gen_intrn = 0;
    279 	}
    280 
    281 	return 0;
    282 }
    283 
    284 /*
    285  * cfs mount vfsop
    286  * Set up mount info record and attach it to vfs struct.
    287  */
    288 /*ARGSUSED*/
    289 int
    290 coda_mount(vfsp, path, data, ndp, p)
    291     struct mount *vfsp;		/* Allocated and initialized by mount(2) */
    292     const char *path;		/* path covered: ignored by the fs-layer */
    293     void *data;			/* Need to define a data type for this in netbsd? */
    294     struct nameidata *ndp;	/* Clobber this to lookup the device name */
    295     struct proc *p;		/* The ever-famous proc pointer */
    296 {
    297     struct vnode *dvp;
    298     struct cnode *cp;
    299     dev_t dev;
    300     struct coda_mntinfo *mi;
    301     struct vnode *rootvp;
    302     ViceFid rootfid;
    303     ViceFid ctlfid;
    304     int error;
    305 
    306     ENTRY;
    307 
    308     coda_vfsopstats_init();
    309     coda_vnodeopstats_init();
    310 
    311     MARK_ENTRY(CODA_MOUNT_STATS);
    312     if (CODA_MOUNTED(vfsp)) {
    313 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    314 	return(EBUSY);
    315     }
    316 
    317     /* Validate mount device.  Similar to getmdev(). */
    318 
    319     NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, data, p);
    320     error = namei(ndp);
    321     dvp = ndp->ni_vp;
    322 
    323     if (error) {
    324 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    325 	return (error);
    326     }
    327     if (dvp->v_type != VCHR) {
    328 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    329 	vrele(dvp);
    330 	return(ENXIO);
    331     }
    332     dev = dvp->v_specinfo->si_rdev;
    333     vrele(dvp);
    334     if (major(dev) >= nchrdev || major(dev) < 0) {
    335 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    336 	return(ENXIO);
    337     }
    338 
    339     /*
    340      * See if the device table matches our expectations.
    341      */
    342     if (cdevsw[major(dev)].d_open != vc_nb_open)
    343     {
    344 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    345 	return(ENXIO);
    346     }
    347 
    348     if (minor(dev) >= NVCODA || minor(dev) < 0) {
    349 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    350 	return(ENXIO);
    351     }
    352 
    353     /*
    354      * Initialize the mount record and link it to the vfs struct
    355      */
    356     mi = &coda_mnttbl[minor(dev)];
    357 
    358     if (!VC_OPEN(&mi->mi_vcomm)) {
    359 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    360 	return(ENODEV);
    361     }
    362 
    363     /* No initialization (here) of mi_vcomm! */
    364     vfsp->mnt_data = (qaddr_t)mi;
    365     vfsp->mnt_stat.f_fsid.val[0] = 0;
    366     vfsp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_CODA);
    367     mi->mi_vfsp = vfsp;
    368 
    369     /*
    370      * Make a root vnode to placate the Vnode interface, but don't
    371      * actually make the CODA_ROOT call to venus until the first call
    372      * to coda_root in case a server is down while venus is starting.
    373      */
    374     rootfid.Volume = 0;
    375     rootfid.Vnode = 0;
    376     rootfid.Unique = 0;
    377     cp = make_coda_node(&rootfid, vfsp, VDIR);
    378     rootvp = CTOV(cp);
    379     rootvp->v_flag |= VROOT;
    380 
    381     ctlfid.Volume = CTL_VOL;
    382     ctlfid.Vnode = CTL_VNO;
    383     ctlfid.Unique = CTL_UNI;
    384 /*  cp = make_coda_node(&ctlfid, vfsp, VCHR);
    385     The above code seems to cause a loop in the cnode links.
    386     I don't totally understand when it happens, it is caught
    387     when closing down the system.
    388  */
    389     cp = make_coda_node(&ctlfid, 0, VCHR);
    390 
    391     coda_ctlvp = CTOV(cp);
    392 
    393     /* Add vfs and rootvp to chain of vfs hanging off mntinfo */
    394     mi->mi_vfsp = vfsp;
    395     mi->mi_rootvp = rootvp;
    396 
    397     /* set filesystem block size */
    398     vfsp->mnt_stat.f_bsize = 8192;	    /* XXX -JJK */
    399 
    400     /* error is currently guaranteed to be zero, but in case some
    401        code changes... */
    402     CODADEBUG(1,
    403 	     myprintf(("coda_mount returned %d\n",error)););
    404     if (error)
    405 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    406     else
    407 	MARK_INT_SAT(CODA_MOUNT_STATS);
    408 
    409     return(error);
    410 }
    411 
    412 int
    413 coda_start(vfsp, flags, p)
    414     struct mount *vfsp;
    415     int flags;
    416     struct proc *p;
    417 {
    418     ENTRY;
    419     return (0);
    420 }
    421 
    422 int
    423 coda_unmount(vfsp, mntflags, p)
    424     struct mount *vfsp;
    425     int mntflags;
    426     struct proc *p;
    427 {
    428     struct coda_mntinfo *mi = vftomi(vfsp);
    429     int active, error = 0;
    430 
    431     ENTRY;
    432     MARK_ENTRY(CODA_UMOUNT_STATS);
    433     if (!CODA_MOUNTED(vfsp)) {
    434 	MARK_INT_FAIL(CODA_UMOUNT_STATS);
    435 	return(EINVAL);
    436     }
    437 
    438     if (mi->mi_vfsp == vfsp) {	/* We found the victim */
    439 	if (!IS_UNMOUNTING(VTOC(mi->mi_rootvp)))
    440 	    return (EBUSY); 	/* Venus is still running */
    441 
    442 #ifdef	DEBUG
    443 	printf("coda_unmount: ROOT: vp %p, cp %p\n", mi->mi_rootvp, VTOC(mi->mi_rootvp));
    444 #endif
    445 	vrele(mi->mi_rootvp);
    446 
    447 	active = coda_kill(vfsp, NOT_DOWNCALL);
    448 	mi->mi_rootvp->v_flag &= ~VROOT;
    449 	error = vflush(mi->mi_vfsp, NULLVP, FORCECLOSE);
    450 	printf("coda_unmount: active = %d, vflush active %d\n", active, error);
    451 	error = 0;
    452 
    453 	/* I'm going to take this out to allow lookups to go through. I'm
    454 	 * not sure it's important anyway. -- DCS 2/2/94
    455 	 */
    456 	/* vfsp->VFS_DATA = NULL; */
    457 
    458 	/* No more vfsp's to hold onto */
    459 	mi->mi_vfsp = NULL;
    460 	mi->mi_rootvp = NULL;
    461 
    462 	if (error)
    463 	    MARK_INT_FAIL(CODA_UMOUNT_STATS);
    464 	else
    465 	    MARK_INT_SAT(CODA_UMOUNT_STATS);
    466 
    467 	return(error);
    468     }
    469     return (EINVAL);
    470 }
    471 
    472 /*
    473  * find root of cfs
    474  */
    475 int
    476 coda_root(vfsp, vpp)
    477 	struct mount *vfsp;
    478 	struct vnode **vpp;
    479 {
    480     struct coda_mntinfo *mi = vftomi(vfsp);
    481     struct vnode **result;
    482     int error;
    483     struct proc *p = curproc;    /* XXX - bnoble */
    484     ViceFid VFid;
    485 
    486     ENTRY;
    487     MARK_ENTRY(CODA_ROOT_STATS);
    488     result = NULL;
    489 
    490     if (vfsp == mi->mi_vfsp) {
    491 	if ((VTOC(mi->mi_rootvp)->c_fid.Volume != 0) ||
    492 	    (VTOC(mi->mi_rootvp)->c_fid.Vnode != 0) ||
    493 	    (VTOC(mi->mi_rootvp)->c_fid.Unique != 0))
    494 	    { /* Found valid root. */
    495 		*vpp = mi->mi_rootvp;
    496 		/* On Mach, this is vref.  On NetBSD, VOP_LOCK */
    497 		vref(*vpp);
    498 		vn_lock(*vpp, LK_EXCLUSIVE);
    499 		MARK_INT_SAT(CODA_ROOT_STATS);
    500 		return(0);
    501 	    }
    502     }
    503 
    504     error = venus_root(vftomi(vfsp), p->p_cred->pc_ucred, p, &VFid);
    505 
    506     if (!error) {
    507 	/*
    508 	 * Save the new rootfid in the cnode, and rehash the cnode into the
    509 	 * cnode hash with the new fid key.
    510 	 */
    511 	coda_unsave(VTOC(mi->mi_rootvp));
    512 	VTOC(mi->mi_rootvp)->c_fid = VFid;
    513 	coda_save(VTOC(mi->mi_rootvp));
    514 
    515 	*vpp = mi->mi_rootvp;
    516 	vref(*vpp);
    517 	vn_lock(*vpp, LK_EXCLUSIVE);
    518 	MARK_INT_SAT(CODA_ROOT_STATS);
    519 	goto exit;
    520     } else if (error == ENODEV || error == EINTR) {
    521 	/* Gross hack here! */
    522 	/*
    523 	 * If Venus fails to respond to the CODA_ROOT call, coda_call returns
    524 	 * ENODEV. Return the uninitialized root vnode to allow vfs
    525 	 * operations such as unmount to continue. Without this hack,
    526 	 * there is no way to do an unmount if Venus dies before a
    527 	 * successful CODA_ROOT call is done. All vnode operations
    528 	 * will fail.
    529 	 */
    530 	*vpp = mi->mi_rootvp;
    531 	vref(*vpp);
    532 	vn_lock(*vpp, LK_EXCLUSIVE);
    533 	MARK_INT_FAIL(CODA_ROOT_STATS);
    534 	error = 0;
    535 	goto exit;
    536     } else {
    537 	CODADEBUG( CODA_ROOT, myprintf(("error %d in CODA_ROOT\n", error)); );
    538 	MARK_INT_FAIL(CODA_ROOT_STATS);
    539 
    540 	goto exit;
    541     }
    542  exit:
    543     return(error);
    544 }
    545 
    546 int
    547 coda_quotactl(vfsp, cmd, uid, arg, p)
    548     struct mount *vfsp;
    549     int cmd;
    550     uid_t uid;
    551     caddr_t arg;
    552     struct proc *p;
    553 {
    554     ENTRY;
    555     return (EOPNOTSUPP);
    556 }
    557 
    558 /*
    559  * Get file system statistics.
    560  */
    561 int
    562 coda_nb_statfs(vfsp, sbp, p)
    563     register struct mount *vfsp;
    564     struct statfs *sbp;
    565     struct proc *p;
    566 {
    567     ENTRY;
    568 /*  MARK_ENTRY(CODA_STATFS_STATS); */
    569     if (!CODA_MOUNTED(vfsp)) {
    570 /*	MARK_INT_FAIL(CODA_STATFS_STATS);*/
    571 	return(EINVAL);
    572     }
    573 
    574     bzero(sbp, sizeof(struct statfs));
    575     /* XXX - what to do about f_flags, others? --bnoble */
    576     /* Below This is what AFS does
    577     	#define NB_SFS_SIZ 0x895440
    578      */
    579     /* Note: Normal fs's have a bsize of 0x400 == 1024 */
    580     sbp->f_type = 0;
    581     sbp->f_bsize = 8192; /* XXX */
    582     sbp->f_iosize = 8192; /* XXX */
    583 #define NB_SFS_SIZ 0x8AB75D
    584     sbp->f_blocks = NB_SFS_SIZ;
    585     sbp->f_bfree = NB_SFS_SIZ;
    586     sbp->f_bavail = NB_SFS_SIZ;
    587     sbp->f_files = NB_SFS_SIZ;
    588     sbp->f_ffree = NB_SFS_SIZ;
    589     bcopy((caddr_t)&(vfsp->mnt_stat.f_fsid), (caddr_t)&(sbp->f_fsid), sizeof (fsid_t));
    590     strncpy(sbp->f_fstypename, MOUNT_CODA, MFSNAMELEN-1);
    591     strcpy(sbp->f_mntonname, "/coda");
    592     strcpy(sbp->f_mntfromname, "CODA");
    593 /*  MARK_INT_SAT(CODA_STATFS_STATS); */
    594     return(0);
    595 }
    596 
    597 /*
    598  * Flush any pending I/O.
    599  */
    600 int
    601 coda_sync(vfsp, waitfor, cred, p)
    602     struct mount *vfsp;
    603     int    waitfor;
    604     struct ucred *cred;
    605     struct proc *p;
    606 {
    607     ENTRY;
    608     MARK_ENTRY(CODA_SYNC_STATS);
    609     MARK_INT_SAT(CODA_SYNC_STATS);
    610     return(0);
    611 }
    612 
    613 int
    614 coda_vget(vfsp, ino, vpp)
    615     struct mount *vfsp;
    616     ino_t ino;
    617     struct vnode **vpp;
    618 {
    619     ENTRY;
    620     return (EOPNOTSUPP);
    621 }
    622 
    623 /*
    624  * fhtovp is now what vget used to be in 4.3-derived systems.  For
    625  * some silly reason, vget is now keyed by a 32 bit ino_t, rather than
    626  * a type-specific fid.
    627  */
    628 int
    629 coda_fhtovp(vfsp, fhp, nam, vpp, exflagsp, creadanonp)
    630     register struct mount *vfsp;
    631     struct fid *fhp;
    632     struct mbuf *nam;
    633     struct vnode **vpp;
    634     int *exflagsp;
    635     struct ucred **creadanonp;
    636 {
    637     struct cfid *cfid = (struct cfid *)fhp;
    638     struct cnode *cp = 0;
    639     int error;
    640     struct proc *p = curproc; /* XXX -mach */
    641     ViceFid VFid;
    642     int vtype;
    643 
    644     ENTRY;
    645 
    646     MARK_ENTRY(CODA_VGET_STATS);
    647     /* Check for vget of control object. */
    648     if (IS_CTL_FID(&cfid->cfid_fid)) {
    649 	*vpp = coda_ctlvp;
    650 	vref(coda_ctlvp);
    651 	MARK_INT_SAT(CODA_VGET_STATS);
    652 	return(0);
    653     }
    654 
    655     error = venus_fhtovp(vftomi(vfsp), &cfid->cfid_fid, p->p_cred->pc_ucred, p, &VFid, &vtype);
    656 
    657     if (error) {
    658 	CODADEBUG(CODA_VGET, myprintf(("vget error %d\n",error));)
    659 	    *vpp = (struct vnode *)0;
    660     } else {
    661 	CODADEBUG(CODA_VGET,
    662 		 myprintf(("vget: vol %lx vno %lx uni %lx type %d result %d\n",
    663 			VFid.Volume, VFid.Vnode, VFid.Unique, vtype, error)); )
    664 
    665 	cp = make_coda_node(&VFid, vfsp, vtype);
    666 	*vpp = CTOV(cp);
    667     }
    668     return(error);
    669 }
    670 
    671 int
    672 coda_vptofh(vnp, fidp)
    673     struct vnode *vnp;
    674     struct fid   *fidp;
    675 {
    676     ENTRY;
    677     return (EOPNOTSUPP);
    678 }
    679 
    680 void
    681 coda_init(void)
    682 {
    683     ENTRY;
    684 }
    685 
    686 int
    687 coda_sysctl(name, namelen, oldp, oldlp, newp, newl, p)
    688 	int *name;
    689 	u_int namelen;
    690 	void *oldp;
    691 	size_t *oldlp;
    692 	void *newp;
    693 	size_t newl;
    694 	struct proc *p;
    695 {
    696 
    697 	/* all sysctl names at this level are terminal */
    698 	if (namelen != 1)
    699 		return (ENOTDIR);		/* overloaded */
    700 
    701 	switch (name[0]) {
    702 /*
    703 	case FFS_CLUSTERREAD:
    704 		return (sysctl_int(oldp, oldlp, newp, newl, &doclusterread));
    705  */
    706 	default:
    707 		return (EOPNOTSUPP);
    708 	}
    709 	/* NOTREACHED */
    710 }
    711 
    712 /*
    713  * To allow for greater ease of use, some vnodes may be orphaned when
    714  * Venus dies.  Certain operations should still be allowed to go
    715  * through, but without propagating ophan-ness.  So this function will
    716  * get a new vnode for the file from the current run of Venus.  */
    717 
    718 int
    719 getNewVnode(vpp)
    720      struct vnode **vpp;
    721 {
    722     struct cfid cfid;
    723     struct coda_mntinfo *mi = vftomi((*vpp)->v_mount);
    724 
    725     ENTRY;
    726 
    727     cfid.cfid_len = (short)sizeof(ViceFid);
    728     cfid.cfid_fid = VTOC(*vpp)->c_fid;	/* Structure assignment. */
    729     /* XXX ? */
    730 
    731     /* We're guessing that if set, the 1st element on the list is a
    732      * valid vnode to use. If not, return ENODEV as venus is dead.
    733      */
    734     if (mi->mi_vfsp == NULL)
    735 	return ENODEV;
    736 
    737     return coda_fhtovp(mi->mi_vfsp, (struct fid*)&cfid, NULL, vpp,
    738 		      NULL, NULL);
    739 }
    740 
    741 #include <ufs/ufs/quota.h>
    742 #include <ufs/ufs/ufsmount.h>
    743 /* get the mount structure corresponding to a given device.  Assume
    744  * device corresponds to a UFS. Return NULL if no device is found.
    745  */
    746 struct mount *devtomp(dev)
    747     dev_t dev;
    748 {
    749     struct mount *mp, *nmp;
    750 
    751     for (mp = mountlist.cqh_first; mp != (void*)&mountlist; mp = nmp) {
    752 	nmp = mp->mnt_list.cqe_next;
    753 	if ((!strcmp(mp->mnt_op->vfs_name, MOUNT_UFS)) &&
    754 	    ((VFSTOUFS(mp))->um_dev == (dev_t) dev)) {
    755 	    /* mount corresponds to UFS and the device matches one we want */
    756 	    return(mp);
    757 	}
    758     }
    759     /* mount structure wasn't found */
    760     return(NULL);
    761 }
    762