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