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