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