1998-08-29 21:14:52 +00:00
|
|
|
/*
|
1998-09-02 19:09:53 +00:00
|
|
|
*
|
|
|
|
* Coda: an Experimental Distributed File System
|
|
|
|
* Release 3.1
|
|
|
|
*
|
|
|
|
* Copyright (c) 1987-1998 Carnegie Mellon University
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify and distribute this software and its
|
|
|
|
* documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation, and
|
|
|
|
* that credit is given to Carnegie Mellon University in all documents
|
|
|
|
* and publicity pertaining to direct or indirect use of this code or its
|
|
|
|
* derivatives.
|
|
|
|
*
|
|
|
|
* CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
|
|
|
|
* SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON ALLOWS
|
|
|
|
* FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON
|
|
|
|
* DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
|
|
|
|
* RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
|
|
|
|
* ANY DERIVATIVE WORK.
|
|
|
|
*
|
|
|
|
* Carnegie Mellon encourages users of this software to return any
|
|
|
|
* improvements or extensions that they make, and to grant Carnegie
|
|
|
|
* Mellon the rights to redistribute these changes without encumbrance.
|
|
|
|
*
|
1998-09-13 13:57:59 +00:00
|
|
|
* @(#) src/sys/coda/coda_vnops.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1998-09-02 19:09:53 +00:00
|
|
|
*
|
|
|
|
*/
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Mach Operating System
|
|
|
|
* Copyright (c) 1990 Carnegie-Mellon University
|
|
|
|
* Copyright (c) 1989 Carnegie-Mellon University
|
|
|
|
* All rights reserved. The CMU software License Agreement specifies
|
|
|
|
* the terms and conditions for use and redistribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code was written for the Coda file system at Carnegie Mellon
|
|
|
|
* University. Contributers include David Steere, James Kistler, and
|
|
|
|
* M. Satyanarayanan.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1998-09-02 19:09:53 +00:00
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/proc.h>
|
1998-08-29 21:14:52 +00:00
|
|
|
#include <sys/malloc.h>
|
1998-09-02 19:09:53 +00:00
|
|
|
#include <sys/mount.h>
|
1998-08-29 21:14:52 +00:00
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/acct.h>
|
|
|
|
#include <sys/file.h>
|
1998-09-02 19:09:53 +00:00
|
|
|
#include <sys/fcntl.h>
|
1998-08-29 21:14:52 +00:00
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/ioccom.h>
|
|
|
|
#include <sys/select.h>
|
|
|
|
|
1998-09-02 19:09:53 +00:00
|
|
|
#include <vm/vm.h>
|
1998-08-29 21:14:52 +00:00
|
|
|
#include <vm/vm_object.h>
|
|
|
|
#include <vm/vm_extern.h>
|
1998-09-02 19:09:53 +00:00
|
|
|
#include <vm/vm_zone.h>
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-13 13:57:59 +00:00
|
|
|
#include <coda/coda.h>
|
|
|
|
#include <coda/cnode.h>
|
|
|
|
#include <coda/coda_vnops.h>
|
|
|
|
#include <coda/coda_venus.h>
|
|
|
|
#include <coda/coda_opstats.h>
|
|
|
|
#include <coda/coda_subr.h>
|
|
|
|
#include <coda/coda_namecache.h>
|
|
|
|
#include <coda/coda_pioctl.h>
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* These flags select various performance enhancements.
|
|
|
|
*/
|
1998-09-11 18:50:17 +00:00
|
|
|
int coda_attr_cache = 1; /* Set to cache attributes in the kernel */
|
|
|
|
int coda_symlink_cache = 1; /* Set to cache symbolic link information */
|
|
|
|
int coda_access_cache = 1; /* Set to handle some access checks directly */
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* structure to keep track of vfs calls */
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
struct coda_op_stats coda_vnodeopstats[CODA_VNODEOPS_SIZE];
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
#define MARK_ENTRY(op) (coda_vnodeopstats[op].entries++)
|
|
|
|
#define MARK_INT_SAT(op) (coda_vnodeopstats[op].sat_intrn++)
|
|
|
|
#define MARK_INT_FAIL(op) (coda_vnodeopstats[op].unsat_intrn++)
|
|
|
|
#define MARK_INT_GEN(op) (coda_vnodeopstats[op].gen_intrn++)
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* What we are delaying for in printf */
|
1998-09-11 18:50:17 +00:00
|
|
|
int coda_printf_delay = 0; /* in microseconds */
|
|
|
|
int coda_vnop_print_entry = 0;
|
|
|
|
static int coda_lockdebug = 0;
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Definition of the vfs operation vector */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some NetBSD details:
|
|
|
|
*
|
1998-09-11 18:50:17 +00:00
|
|
|
* coda_start is called at the end of the mount syscall.
|
|
|
|
* coda_init is called at boot time.
|
1998-08-29 21:14:52 +00:00
|
|
|
*/
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
#define ENTRY if(coda_vnop_print_entry) myprintf(("Entered %s\n",__FUNCTION__))
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Definition of the vnode operation vector */
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
struct vnodeopv_entry_desc coda_vnodeop_entries[] = {
|
|
|
|
{ &vop_default_desc, coda_vop_error },
|
|
|
|
{ &vop_lookup_desc, coda_lookup }, /* lookup */
|
|
|
|
{ &vop_create_desc, coda_create }, /* create */
|
1998-09-25 17:38:32 +00:00
|
|
|
{ &vop_mknod_desc, coda_vop_error }, /* mknod */
|
1998-09-11 18:50:17 +00:00
|
|
|
{ &vop_open_desc, coda_open }, /* open */
|
|
|
|
{ &vop_close_desc, coda_close }, /* close */
|
|
|
|
{ &vop_access_desc, coda_access }, /* access */
|
1998-09-25 17:38:32 +00:00
|
|
|
{ &vop_getattr_desc, coda_getattr }, /* getattr */
|
|
|
|
{ &vop_setattr_desc, coda_setattr }, /* setattr */
|
1998-09-11 18:50:17 +00:00
|
|
|
{ &vop_read_desc, coda_read }, /* read */
|
|
|
|
{ &vop_write_desc, coda_write }, /* write */
|
|
|
|
{ &vop_ioctl_desc, coda_ioctl }, /* ioctl */
|
1998-09-25 17:38:32 +00:00
|
|
|
{ &vop_mmap_desc, coda_vop_error }, /* mmap */
|
1998-09-11 18:50:17 +00:00
|
|
|
{ &vop_fsync_desc, coda_fsync }, /* fsync */
|
|
|
|
{ &vop_remove_desc, coda_remove }, /* remove */
|
|
|
|
{ &vop_link_desc, coda_link }, /* link */
|
|
|
|
{ &vop_rename_desc, coda_rename }, /* rename */
|
|
|
|
{ &vop_mkdir_desc, coda_mkdir }, /* mkdir */
|
|
|
|
{ &vop_rmdir_desc, coda_rmdir }, /* rmdir */
|
1998-09-25 17:38:32 +00:00
|
|
|
{ &vop_symlink_desc, coda_symlink }, /* symlink */
|
|
|
|
{ &vop_readdir_desc, coda_readdir }, /* readdir */
|
1998-09-11 18:50:17 +00:00
|
|
|
{ &vop_readlink_desc, coda_readlink }, /* readlink */
|
|
|
|
{ &vop_inactive_desc, coda_inactive }, /* inactive */
|
1998-09-25 17:38:32 +00:00
|
|
|
{ &vop_reclaim_desc, coda_reclaim }, /* reclaim */
|
1998-09-11 18:50:17 +00:00
|
|
|
{ &vop_lock_desc, coda_lock }, /* lock */
|
|
|
|
{ &vop_unlock_desc, coda_unlock }, /* unlock */
|
|
|
|
{ &vop_bmap_desc, coda_bmap }, /* bmap */
|
|
|
|
{ &vop_strategy_desc, coda_strategy }, /* strategy */
|
1998-09-25 17:38:32 +00:00
|
|
|
{ &vop_print_desc, coda_vop_error }, /* print */
|
1998-09-11 18:50:17 +00:00
|
|
|
{ &vop_islocked_desc, coda_islocked }, /* islocked */
|
1998-09-25 17:38:32 +00:00
|
|
|
{ &vop_pathconf_desc, coda_vop_error }, /* pathconf */
|
|
|
|
{ &vop_advlock_desc, coda_vop_nop }, /* advlock */
|
|
|
|
{ &vop_bwrite_desc, coda_vop_error }, /* bwrite */
|
|
|
|
{ &vop_lease_desc, coda_vop_nop }, /* lease */
|
1998-09-02 19:09:53 +00:00
|
|
|
{ &vop_poll_desc, (vop_t *) vop_stdpoll },
|
1998-09-11 18:50:17 +00:00
|
|
|
{ &vop_getpages_desc, coda_fbsd_getpages }, /* pager intf.*/
|
|
|
|
{ &vop_putpages_desc, coda_fbsd_putpages }, /* pager intf.*/
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
#if 0
|
1998-09-02 19:09:53 +00:00
|
|
|
|
|
|
|
we need to define these someday
|
1998-08-29 21:14:52 +00:00
|
|
|
#define UFS_BLKATOFF(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_blkatoff(aa, bb, cc, dd)
|
|
|
|
#define UFS_VALLOC(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_valloc(aa, bb, cc, dd)
|
|
|
|
#define UFS_VFREE(aa, bb, cc) VFSTOUFS((aa)->v_mount)->um_vfree(aa, bb, cc)
|
|
|
|
#define UFS_TRUNCATE(aa, bb, cc, dd, ee) VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd, ee)
|
1999-01-07 16:14:19 +00:00
|
|
|
#define UFS_UPDATE(aa, bb) VFSTOUFS((aa)->v_mount)->um_update(aa, bb)
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
missing
|
|
|
|
{ &vop_reallocblks_desc, (vop_t *) ufs_missingop },
|
|
|
|
{ &vop_cachedlookup_desc, (vop_t *) ufs_lookup },
|
|
|
|
{ &vop_whiteout_desc, (vop_t *) ufs_whiteout },
|
|
|
|
#endif
|
|
|
|
{ (struct vnodeop_desc*)NULL, (int(*)(void *))NULL }
|
|
|
|
};
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
static struct vnodeopv_desc coda_vnodeop_opv_desc =
|
|
|
|
{ &coda_vnodeop_p, coda_vnodeop_entries };
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
VNODEOP_SET(coda_vnodeop_opv_desc);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* A generic panic: we were called with something we didn't define yet */
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_vop_error(void *anon) {
|
1998-08-29 21:14:52 +00:00
|
|
|
struct vnodeop_desc **desc = (struct vnodeop_desc **)anon;
|
|
|
|
|
1998-11-16 19:48:26 +00:00
|
|
|
myprintf(("coda_vop_error: Vnode operation %s called, but not defined.\n",
|
1998-08-29 21:14:52 +00:00
|
|
|
(*desc)->vdesc_name));
|
1998-11-16 19:48:26 +00:00
|
|
|
/*
|
1998-09-11 18:50:17 +00:00
|
|
|
panic("coda_vop_error");
|
1998-11-16 19:48:26 +00:00
|
|
|
*/
|
|
|
|
return EIO;
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* A generic do-nothing. For lease_check, advlock */
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_vop_nop(void *anon) {
|
1998-08-29 21:14:52 +00:00
|
|
|
struct vnodeop_desc **desc = (struct vnodeop_desc **)anon;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
if (codadebug) {
|
1998-08-29 21:14:52 +00:00
|
|
|
myprintf(("Vnode operation %s called, but unsupported\n",
|
|
|
|
(*desc)->vdesc_name));
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_vnodeopstats_init(void)
|
1998-08-29 21:14:52 +00:00
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
for(i=0;i<CODA_VNODEOPS_SIZE;i++) {
|
|
|
|
coda_vnodeopstats[i].opcode = i;
|
|
|
|
coda_vnodeopstats[i].entries = 0;
|
|
|
|
coda_vnodeopstats[i].sat_intrn = 0;
|
|
|
|
coda_vnodeopstats[i].unsat_intrn = 0;
|
|
|
|
coda_vnodeopstats[i].gen_intrn = 0;
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1998-09-11 18:50:17 +00:00
|
|
|
* coda_open calls Venus to return the device, inode pair of the cache
|
|
|
|
* file holding the data. Using iget, coda_open finds the vnode of the
|
1998-08-29 21:14:52 +00:00
|
|
|
* cache file, and then opens it.
|
|
|
|
*/
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_open(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* NetBSD can pass the O_EXCL flag in mode, even though the check
|
|
|
|
* has already happened. Venus defensively assumes that if open
|
|
|
|
* is passed the EXCL, it must be a bug. We strip the flag here.
|
|
|
|
*/
|
|
|
|
/* true args */
|
|
|
|
struct vop_open_args *ap = v;
|
|
|
|
register struct vnode **vpp = &(ap->a_vp);
|
|
|
|
struct cnode *cp = VTOC(*vpp);
|
|
|
|
int flag = ap->a_mode & (~O_EXCL);
|
|
|
|
struct ucred *cred = ap->a_cred;
|
|
|
|
struct proc *p = ap->a_p;
|
|
|
|
/* locals */
|
|
|
|
int error;
|
|
|
|
struct vnode *vp;
|
|
|
|
dev_t dev;
|
|
|
|
ino_t inode;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_OPEN_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Check for open of control file. */
|
|
|
|
if (IS_CTL_VP(*vpp)) {
|
|
|
|
/* XXX */
|
|
|
|
/* if (WRITEABLE(flag)) */
|
|
|
|
if (flag & (FWRITE | O_TRUNC | O_CREAT | O_EXCL)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_OPEN_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(EACCES);
|
|
|
|
}
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_SAT(CODA_OPEN_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
error = venus_open(vtomi((*vpp)), &cp->c_fid, flag, cred, p, &dev, &inode);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
if (!error) {
|
1999-08-08 13:22:05 +00:00
|
|
|
CODADEBUG( CODA_OPEN,myprintf(("open: dev %#lx inode %lu result %d\n",
|
|
|
|
(u_long)dev2udev(dev), (u_long)inode,
|
|
|
|
error)); )
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Translate the <device, inode> pair for the cache file into
|
|
|
|
an inode pointer. */
|
1998-09-11 18:50:17 +00:00
|
|
|
error = coda_grab_vnode(dev, inode, &vp);
|
1998-08-29 21:14:52 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
1998-09-02 19:09:53 +00:00
|
|
|
/* We get the vnode back locked. Needs unlocked */
|
|
|
|
VOP_UNLOCK(vp, 0, p);
|
1998-08-29 21:14:52 +00:00
|
|
|
/* Keep a reference until the close comes in. */
|
|
|
|
vref(*vpp);
|
|
|
|
|
|
|
|
/* Save the vnode pointer for the cache file. */
|
|
|
|
if (cp->c_ovp == NULL) {
|
|
|
|
cp->c_ovp = vp;
|
|
|
|
} else {
|
|
|
|
if (cp->c_ovp != vp)
|
1998-09-11 18:50:17 +00:00
|
|
|
panic("coda_open: cp->c_ovp != ITOV(ip)");
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
cp->c_ocount++;
|
|
|
|
|
|
|
|
/* Flush the attribute cached if writing the file. */
|
|
|
|
if (flag & FWRITE) {
|
|
|
|
cp->c_owrite++;
|
|
|
|
cp->c_flags &= ~C_VATTR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save the <device, inode> pair for the cache file to speed
|
|
|
|
up subsequent page_read's. */
|
|
|
|
cp->c_device = dev;
|
|
|
|
cp->c_inode = inode;
|
|
|
|
|
|
|
|
/* Open the cache file. */
|
|
|
|
error = VOP_OPEN(vp, flag, cred, p);
|
|
|
|
if (error) {
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_open: VOP_OPEN on container failed %d\n", error);
|
1998-08-29 21:14:52 +00:00
|
|
|
return (error);
|
|
|
|
}
|
1998-09-25 17:38:32 +00:00
|
|
|
/* grab (above) does this when it calls newvnode unless it's in the cache*/
|
1998-08-29 21:14:52 +00:00
|
|
|
if (vp->v_type == VREG) {
|
1999-01-05 18:50:03 +00:00
|
|
|
error = vfs_object_create(vp, p, cred);
|
1998-08-29 21:14:52 +00:00
|
|
|
if (error != 0) {
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_open: vfs_object_create() returns %d\n", error);
|
1998-08-29 21:14:52 +00:00
|
|
|
vput(vp);
|
|
|
|
}
|
|
|
|
}
|
1998-09-25 17:38:32 +00:00
|
|
|
|
1998-08-29 21:14:52 +00:00
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Close the cache file used for I/O and notify Venus.
|
|
|
|
*/
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_close(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_close_args *ap = v;
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct cnode *cp = VTOC(vp);
|
|
|
|
int flag = ap->a_fflag;
|
|
|
|
struct ucred *cred = ap->a_cred;
|
|
|
|
struct proc *p = ap->a_p;
|
|
|
|
/* locals */
|
|
|
|
int error;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_CLOSE_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Check for close of control file. */
|
|
|
|
if (IS_CTL_VP(vp)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_SAT(CODA_CLOSE_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IS_UNMOUNTING(cp)) {
|
|
|
|
if (cp->c_ovp) {
|
1998-09-28 20:52:58 +00:00
|
|
|
#ifdef CODA_VERBOSE
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_close: destroying container ref %d, ufs vp %p of vp %p/cp %p\n",
|
1998-08-29 21:14:52 +00:00
|
|
|
vp->v_usecount, cp->c_ovp, vp, cp);
|
1998-09-25 17:38:32 +00:00
|
|
|
#endif
|
1998-10-28 20:31:13 +00:00
|
|
|
#ifdef hmm
|
1998-08-29 21:14:52 +00:00
|
|
|
vgone(cp->c_ovp);
|
1998-10-28 20:31:13 +00:00
|
|
|
#else
|
|
|
|
VOP_CLOSE(cp->c_ovp, flag, cred, p); /* Do errors matter here? */
|
|
|
|
vrele(cp->c_ovp);
|
|
|
|
#endif
|
1998-08-29 21:14:52 +00:00
|
|
|
} else {
|
1998-09-28 20:52:58 +00:00
|
|
|
#ifdef CODA_VERBOSE
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_close: NO container vp %p/cp %p\n", vp, cp);
|
1998-09-25 17:38:32 +00:00
|
|
|
#endif
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
return ENODEV;
|
|
|
|
} else {
|
|
|
|
VOP_CLOSE(cp->c_ovp, flag, cred, p); /* Do errors matter here? */
|
|
|
|
vrele(cp->c_ovp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (--cp->c_ocount == 0)
|
|
|
|
cp->c_ovp = NULL;
|
|
|
|
|
|
|
|
if (flag & FWRITE) /* file was opened for write */
|
|
|
|
--cp->c_owrite;
|
|
|
|
|
|
|
|
error = venus_close(vtomi(vp), &cp->c_fid, flag, cred, p);
|
|
|
|
vrele(CTOV(cp));
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_CLOSE, myprintf(("close: result %d\n",error)); )
|
1998-08-29 21:14:52 +00:00
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_read(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct vop_read_args *ap = v;
|
|
|
|
|
|
|
|
ENTRY;
|
1998-09-11 18:50:17 +00:00
|
|
|
return(coda_rdwr(ap->a_vp, ap->a_uio, UIO_READ,
|
1998-08-29 21:14:52 +00:00
|
|
|
ap->a_ioflag, ap->a_cred, ap->a_uio->uio_procp));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_write(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct vop_write_args *ap = v;
|
|
|
|
|
|
|
|
ENTRY;
|
1998-09-11 18:50:17 +00:00
|
|
|
return(coda_rdwr(ap->a_vp, ap->a_uio, UIO_WRITE,
|
1998-08-29 21:14:52 +00:00
|
|
|
ap->a_ioflag, ap->a_cred, ap->a_uio->uio_procp));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_rdwr(vp, uiop, rw, ioflag, cred, p)
|
1998-08-29 21:14:52 +00:00
|
|
|
struct vnode *vp;
|
|
|
|
struct uio *uiop;
|
|
|
|
enum uio_rw rw;
|
|
|
|
int ioflag;
|
|
|
|
struct ucred *cred;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
/* upcall decl */
|
|
|
|
/* NOTE: container file operation!!! */
|
|
|
|
/* locals */
|
|
|
|
struct cnode *cp = VTOC(vp);
|
|
|
|
struct vnode *cfvp = cp->c_ovp;
|
|
|
|
int igot_internally = 0;
|
|
|
|
int opened_internally = 0;
|
|
|
|
int error = 0;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_RDWR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1999-08-08 13:22:05 +00:00
|
|
|
CODADEBUG(CODA_RDWR, myprintf(("coda_rdwr(%d, %p, %d, %lld, %d)\n", rw,
|
|
|
|
(void *)uiop->uio_iov->iov_base, uiop->uio_resid,
|
|
|
|
(long long)uiop->uio_offset, uiop->uio_segflg)); )
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Check for rdwr of control object. */
|
|
|
|
if (IS_CTL_VP(vp)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_RDWR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If file is not already open this must be a page
|
|
|
|
* {read,write} request. Iget the cache file's inode
|
|
|
|
* pointer if we still have its <device, inode> pair.
|
|
|
|
* Otherwise, we must do an internal open to derive the
|
|
|
|
* pair.
|
|
|
|
*/
|
|
|
|
if (cfvp == NULL) {
|
|
|
|
/*
|
|
|
|
* If we're dumping core, do the internal open. Otherwise
|
|
|
|
* venus won't have the correct size of the core when
|
|
|
|
* it's completely written.
|
|
|
|
*/
|
|
|
|
if (cp->c_inode != 0 && !(p && (p->p_acflag & ACORE))) {
|
|
|
|
igot_internally = 1;
|
1998-09-11 18:50:17 +00:00
|
|
|
error = coda_grab_vnode(cp->c_device, cp->c_inode, &cfvp);
|
1998-08-29 21:14:52 +00:00
|
|
|
if (error) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_RDWR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* We get the vnode back locked in both Mach and
|
|
|
|
* NetBSD. Needs unlocked
|
|
|
|
*/
|
1998-09-02 19:09:53 +00:00
|
|
|
VOP_UNLOCK(cfvp, 0, p);
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
opened_internally = 1;
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_GEN(CODA_OPEN_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
error = VOP_OPEN(vp, (rw == UIO_READ ? FREAD : FWRITE),
|
|
|
|
cred, p);
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_rdwr: Internally Opening %p\n", vp);
|
1998-08-29 21:14:52 +00:00
|
|
|
if (error) {
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_rdwr: VOP_OPEN on container failed %d\n", error);
|
1998-08-29 21:14:52 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
if (vp->v_type == VREG) {
|
1999-01-05 18:50:03 +00:00
|
|
|
error = vfs_object_create(vp, p, cred);
|
1998-08-29 21:14:52 +00:00
|
|
|
if (error != 0) {
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_rdwr: vfs_object_create() returns %d\n", error);
|
1998-08-29 21:14:52 +00:00
|
|
|
vput(vp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (error) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_RDWR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
cfvp = cp->c_ovp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Have UFS handle the call. */
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_RDWR, myprintf(("indirect rdwr: fid = (%lx.%lx.%lx), refcnt = %d\n",
|
1998-08-29 21:14:52 +00:00
|
|
|
cp->c_fid.Volume, cp->c_fid.Vnode,
|
|
|
|
cp->c_fid.Unique, CTOV(cp)->v_usecount)); )
|
|
|
|
|
1998-09-25 17:38:32 +00:00
|
|
|
|
1998-08-29 21:14:52 +00:00
|
|
|
if (rw == UIO_READ) {
|
|
|
|
error = VOP_READ(cfvp, uiop, ioflag, cred);
|
|
|
|
} else {
|
|
|
|
error = VOP_WRITE(cfvp, uiop, ioflag, cred);
|
|
|
|
/* ufs_write updates the vnode_pager_setsize for the vnode/object */
|
1998-09-25 17:38:32 +00:00
|
|
|
|
1998-08-29 21:14:52 +00:00
|
|
|
{ struct vattr attr;
|
|
|
|
|
|
|
|
if (VOP_GETATTR(cfvp, &attr, cred, p) == 0) {
|
|
|
|
vnode_pager_setsize(vp, attr.va_size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error)
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_RDWR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
else
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_SAT(CODA_RDWR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Do an internal close if necessary. */
|
|
|
|
if (opened_internally) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_GEN(CODA_CLOSE_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
(void)VOP_CLOSE(vp, (rw == UIO_READ ? FREAD : FWRITE), cred, p);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Invalidate cached attributes if writing. */
|
|
|
|
if (rw == UIO_WRITE)
|
|
|
|
cp->c_flags &= ~C_VATTR;
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_ioctl(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_ioctl_args *ap = v;
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
int com = ap->a_command;
|
|
|
|
caddr_t data = ap->a_data;
|
|
|
|
int flag = ap->a_fflag;
|
|
|
|
struct ucred *cred = ap->a_cred;
|
|
|
|
struct proc *p = ap->a_p;
|
|
|
|
/* locals */
|
|
|
|
int error;
|
|
|
|
struct vnode *tvp;
|
|
|
|
struct nameidata ndp;
|
|
|
|
struct PioctlData *iap = (struct PioctlData *)data;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_IOCTL_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_IOCTL, myprintf(("in coda_ioctl on %s\n", iap->path));)
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Don't check for operation on a dying object, for ctlvp it
|
|
|
|
shouldn't matter */
|
|
|
|
|
|
|
|
/* Must be control object to succeed. */
|
|
|
|
if (!IS_CTL_VP(vp)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_IOCTL_STATS);
|
|
|
|
CODADEBUG(CODA_IOCTL, myprintf(("coda_ioctl error: vp != ctlvp"));)
|
1998-08-29 21:14:52 +00:00
|
|
|
return (EOPNOTSUPP);
|
|
|
|
}
|
|
|
|
/* Look up the pathname. */
|
|
|
|
|
|
|
|
/* Should we use the name cache here? It would get it from
|
|
|
|
lookupname sooner or later anyway, right? */
|
|
|
|
|
1999-01-29 07:23:53 +00:00
|
|
|
NDINIT(&ndp, LOOKUP, (iap->follow ? FOLLOW : NOFOLLOW), UIO_USERSPACE, iap->path, p);
|
1998-08-29 21:14:52 +00:00
|
|
|
error = namei(&ndp);
|
|
|
|
tvp = ndp.ni_vp;
|
|
|
|
|
|
|
|
if (error) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_IOCTL_STATS);
|
|
|
|
CODADEBUG(CODA_IOCTL, myprintf(("coda_ioctl error: lookup returns %d\n",
|
1998-08-29 21:14:52 +00:00
|
|
|
error));)
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure this is a coda style cnode, but it may be a
|
|
|
|
* different vfsp
|
|
|
|
*/
|
1999-08-13 13:05:08 +00:00
|
|
|
if (tvp->v_op != coda_vnodeop_p) {
|
1998-08-29 21:14:52 +00:00
|
|
|
vrele(tvp);
|
1999-12-15 23:02:35 +00:00
|
|
|
NDFREE(&ndp, NDF_ONLY_PNBUF);
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_IOCTL_STATS);
|
|
|
|
CODADEBUG(CODA_IOCTL,
|
|
|
|
myprintf(("coda_ioctl error: %s not a coda object\n",
|
1998-08-29 21:14:52 +00:00
|
|
|
iap->path));)
|
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iap->vi.in_size > VC_MAXDATASIZE) {
|
1999-12-15 23:02:35 +00:00
|
|
|
NDFREE(&ndp, 0);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
error = venus_ioctl(vtomi(tvp), &((VTOC(tvp))->c_fid), com, flag, data, cred, p);
|
|
|
|
|
|
|
|
if (error)
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_IOCTL_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
else
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_IOCTL, myprintf(("Ioctl returns %d \n", error)); )
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
vrele(tvp);
|
1999-12-15 23:02:35 +00:00
|
|
|
NDFREE(&ndp, NDF_ONLY_PNBUF);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* To reduce the cost of a user-level venus;we cache attributes in
|
|
|
|
* the kernel. Each cnode has storage allocated for an attribute. If
|
|
|
|
* c_vattr is valid, return a reference to it. Otherwise, get the
|
|
|
|
* attributes from venus and store them in the cnode. There is some
|
|
|
|
* question if this method is a security leak. But I think that in
|
|
|
|
* order to make this call, the user must have done a lookup and
|
|
|
|
* opened the file, and therefore should already have access.
|
|
|
|
*/
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_getattr(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_getattr_args *ap = v;
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct cnode *cp = VTOC(vp);
|
|
|
|
struct vattr *vap = ap->a_vap;
|
|
|
|
struct ucred *cred = ap->a_cred;
|
|
|
|
struct proc *p = ap->a_p;
|
|
|
|
/* locals */
|
|
|
|
int error;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_GETATTR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
if (IS_UNMOUNTING(cp))
|
|
|
|
return ENODEV;
|
1998-09-02 19:09:53 +00:00
|
|
|
|
1998-08-29 21:14:52 +00:00
|
|
|
/* Check for getattr of control object. */
|
|
|
|
if (IS_CTL_VP(vp)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_GETATTR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(ENOENT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check to see if the attributes have already been cached */
|
|
|
|
if (VALID_VATTR(cp)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_GETATTR, { myprintf(("attr cache hit: (%lx.%lx.%lx)\n",
|
1998-08-29 21:14:52 +00:00
|
|
|
cp->c_fid.Volume,
|
|
|
|
cp->c_fid.Vnode,
|
|
|
|
cp->c_fid.Unique));});
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_GETATTR, if (!(codadebug & ~CODA_GETATTR))
|
1998-08-29 21:14:52 +00:00
|
|
|
print_vattr(&cp->c_vattr); );
|
|
|
|
|
|
|
|
*vap = cp->c_vattr;
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_SAT(CODA_GETATTR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
error = venus_getattr(vtomi(vp), &cp->c_fid, cred, p, vap);
|
|
|
|
|
|
|
|
if (!error) {
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_GETATTR, myprintf(("getattr miss (%lx.%lx.%lx): result %d\n",
|
1998-08-29 21:14:52 +00:00
|
|
|
cp->c_fid.Volume,
|
|
|
|
cp->c_fid.Vnode,
|
|
|
|
cp->c_fid.Unique,
|
|
|
|
error)); )
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_GETATTR, if (!(codadebug & ~CODA_GETATTR))
|
1998-08-29 21:14:52 +00:00
|
|
|
print_vattr(vap); );
|
|
|
|
|
|
|
|
{ int size = vap->va_size;
|
|
|
|
struct vnode *convp = cp->c_ovp;
|
|
|
|
if (convp != (struct vnode *)0) {
|
|
|
|
vnode_pager_setsize(convp, size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* If not open for write, store attributes in cnode */
|
1998-09-11 18:50:17 +00:00
|
|
|
if ((cp->c_owrite == 0) && (coda_attr_cache)) {
|
1998-08-29 21:14:52 +00:00
|
|
|
cp->c_vattr = *vap;
|
|
|
|
cp->c_flags |= C_VATTR;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_setattr(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_setattr_args *ap = v;
|
|
|
|
register struct vnode *vp = ap->a_vp;
|
|
|
|
struct cnode *cp = VTOC(vp);
|
|
|
|
register struct vattr *vap = ap->a_vap;
|
|
|
|
struct ucred *cred = ap->a_cred;
|
|
|
|
struct proc *p = ap->a_p;
|
|
|
|
/* locals */
|
|
|
|
int error;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_SETATTR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Check for setattr of control object. */
|
|
|
|
if (IS_CTL_VP(vp)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_SETATTR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(ENOENT);
|
|
|
|
}
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
if (codadebug & CODADBGMSK(CODA_SETATTR)) {
|
1998-08-29 21:14:52 +00:00
|
|
|
print_vattr(vap);
|
|
|
|
}
|
|
|
|
error = venus_setattr(vtomi(vp), &cp->c_fid, vap, cred, p);
|
|
|
|
|
|
|
|
if (!error)
|
|
|
|
cp->c_flags &= ~C_VATTR;
|
|
|
|
|
|
|
|
{ int size = vap->va_size;
|
|
|
|
struct vnode *convp = cp->c_ovp;
|
|
|
|
if (size != VNOVAL && convp != (struct vnode *)0) {
|
|
|
|
vnode_pager_setsize(convp, size);
|
|
|
|
}
|
|
|
|
}
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_SETATTR, myprintf(("setattr %d\n", error)); )
|
1998-08-29 21:14:52 +00:00
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_access(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_access_args *ap = v;
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct cnode *cp = VTOC(vp);
|
|
|
|
int mode = ap->a_mode;
|
|
|
|
struct ucred *cred = ap->a_cred;
|
|
|
|
struct proc *p = ap->a_p;
|
|
|
|
/* locals */
|
|
|
|
int error;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_ACCESS_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Check for access of control object. Only read access is
|
|
|
|
allowed on it. */
|
|
|
|
if (IS_CTL_VP(vp)) {
|
|
|
|
/* bogus hack - all will be marked as successes */
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_SAT(CODA_ACCESS_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(((mode & VREAD) && !(mode & (VWRITE | VEXEC)))
|
|
|
|
? 0 : EACCES);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if the file is a directory, and we are checking exec (eg lookup)
|
|
|
|
* access, and the file is in the namecache, then the user must have
|
|
|
|
* lookup access to it.
|
|
|
|
*/
|
1998-09-11 18:50:17 +00:00
|
|
|
if (coda_access_cache) {
|
1998-08-29 21:14:52 +00:00
|
|
|
if ((vp->v_type == VDIR) && (mode & VEXEC)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
if (coda_nc_lookup(cp, ".", 1, cred)) {
|
|
|
|
MARK_INT_SAT(CODA_ACCESS_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(0); /* it was in the cache */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
error = venus_access(vtomi(vp), &cp->c_fid, mode, cred, p);
|
|
|
|
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_readlink(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_readlink_args *ap = v;
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct cnode *cp = VTOC(vp);
|
|
|
|
struct uio *uiop = ap->a_uio;
|
|
|
|
struct ucred *cred = ap->a_cred;
|
|
|
|
struct proc *p = ap->a_uio->uio_procp;
|
|
|
|
/* locals */
|
|
|
|
int error;
|
|
|
|
char *str;
|
|
|
|
int len;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_READLINK_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Check for readlink of control object. */
|
|
|
|
if (IS_CTL_VP(vp)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_READLINK_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(ENOENT);
|
|
|
|
}
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
if ((coda_symlink_cache) && (VALID_SYMLINK(cp))) { /* symlink was cached */
|
1998-08-29 21:14:52 +00:00
|
|
|
uiop->uio_rw = UIO_READ;
|
|
|
|
error = uiomove(cp->c_symlink, (int)cp->c_symlen, uiop);
|
|
|
|
if (error)
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_READLINK_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
else
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_SAT(CODA_READLINK_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
error = venus_readlink(vtomi(vp), &cp->c_fid, cred, p, &str, &len);
|
|
|
|
|
|
|
|
if (!error) {
|
|
|
|
uiop->uio_rw = UIO_READ;
|
|
|
|
error = uiomove(str, len, uiop);
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
if (coda_symlink_cache) {
|
1998-08-29 21:14:52 +00:00
|
|
|
cp->c_symlink = str;
|
|
|
|
cp->c_symlen = len;
|
|
|
|
cp->c_flags |= C_SYMLINK;
|
|
|
|
} else
|
1998-09-11 18:50:17 +00:00
|
|
|
CODA_FREE(str, len);
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_READLINK, myprintf(("in readlink result %d\n",error));)
|
1998-08-29 21:14:52 +00:00
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_fsync(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_fsync_args *ap = v;
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct cnode *cp = VTOC(vp);
|
|
|
|
struct ucred *cred = ap->a_cred;
|
|
|
|
struct proc *p = ap->a_p;
|
|
|
|
/* locals */
|
|
|
|
struct vnode *convp = cp->c_ovp;
|
|
|
|
int error;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_FSYNC_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Check for fsync on an unmounting object */
|
|
|
|
/* The NetBSD kernel, in it's infinite wisdom, can try to fsync
|
|
|
|
* after an unmount has been initiated. This is a Bad Thing,
|
|
|
|
* which we have to avoid. Not a legitimate failure for stats.
|
|
|
|
*/
|
|
|
|
if (IS_UNMOUNTING(cp)) {
|
|
|
|
return(ENODEV);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for fsync of control object. */
|
|
|
|
if (IS_CTL_VP(vp)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_SAT(CODA_FSYNC_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (convp)
|
|
|
|
VOP_FSYNC(convp, cred, MNT_WAIT, p);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We see fsyncs with usecount == 1 then usecount == 0.
|
|
|
|
* For now we ignore them.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
if (!vp->v_usecount) {
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_fsync on vnode %p with %d usecount. c_flags = %x (%x)\n",
|
1998-08-29 21:14:52 +00:00
|
|
|
vp, vp->v_usecount, cp->c_flags, cp->c_flags&C_PURGING);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We can expect fsync on any vnode at all if venus is pruging it.
|
|
|
|
* Venus can't very well answer the fsync request, now can it?
|
|
|
|
* Hopefully, it won't have to, because hopefully, venus preserves
|
|
|
|
* the (possibly untrue) invariant that it never purges an open
|
|
|
|
* vnode. Hopefully.
|
|
|
|
*/
|
|
|
|
if (cp->c_flags & C_PURGING) {
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* needs research */
|
|
|
|
return 0;
|
|
|
|
error = venus_fsync(vtomi(vp), &cp->c_fid, cred, p);
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_FSYNC, myprintf(("in fsync result %d\n",error)); );
|
1998-08-29 21:14:52 +00:00
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_inactive(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* XXX - at the moment, inactive doesn't look at cred, and doesn't
|
|
|
|
have a proc pointer. Oops. */
|
|
|
|
/* true args */
|
|
|
|
struct vop_inactive_args *ap = v;
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct cnode *cp = VTOC(vp);
|
|
|
|
struct ucred *cred __attribute__((unused)) = NULL;
|
|
|
|
struct proc *p __attribute__((unused)) = curproc;
|
|
|
|
/* upcall decl */
|
|
|
|
/* locals */
|
|
|
|
|
|
|
|
/* We don't need to send inactive to venus - DCS */
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_INACTIVE_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
if (IS_CTL_VP(vp)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_SAT(CODA_INACTIVE_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_INACTIVE, myprintf(("in inactive, %lx.%lx.%lx. vfsp %p\n",
|
1998-08-29 21:14:52 +00:00
|
|
|
cp->c_fid.Volume, cp->c_fid.Vnode,
|
|
|
|
cp->c_fid.Unique, vp->v_mount));)
|
|
|
|
|
|
|
|
/* If an array has been allocated to hold the symlink, deallocate it */
|
1998-09-11 18:50:17 +00:00
|
|
|
if ((coda_symlink_cache) && (VALID_SYMLINK(cp))) {
|
1998-08-29 21:14:52 +00:00
|
|
|
if (cp->c_symlink == NULL)
|
1998-09-11 18:50:17 +00:00
|
|
|
panic("coda_inactive: null symlink pointer in cnode");
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
CODA_FREE(cp->c_symlink, cp->c_symlen);
|
1998-08-29 21:14:52 +00:00
|
|
|
cp->c_flags &= ~C_SYMLINK;
|
|
|
|
cp->c_symlen = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove it from the table so it can't be found. */
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_unsave(cp);
|
|
|
|
if ((struct coda_mntinfo *)(vp->v_mount->mnt_data) == NULL) {
|
1998-08-29 21:14:52 +00:00
|
|
|
myprintf(("Help! vfsp->vfs_data was NULL, but vnode %p wasn't dying\n", vp));
|
1998-09-11 18:50:17 +00:00
|
|
|
panic("badness in coda_inactive\n");
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (IS_UNMOUNTING(cp)) {
|
|
|
|
#ifdef DEBUG
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_inactive: IS_UNMOUNTING use %d: vp %p, cp %p\n", vp->v_usecount, vp, cp);
|
1998-08-29 21:14:52 +00:00
|
|
|
if (cp->c_ovp != NULL)
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_inactive: cp->ovp != NULL use %d: vp %p, cp %p\n",
|
1998-08-29 21:14:52 +00:00
|
|
|
vp->v_usecount, vp, cp);
|
|
|
|
#endif
|
1998-09-02 19:09:53 +00:00
|
|
|
lockmgr(&cp->c_lock, LK_RELEASE, &vp->v_interlock, p);
|
1998-08-29 21:14:52 +00:00
|
|
|
} else {
|
1998-09-25 17:38:32 +00:00
|
|
|
#ifdef OLD_DIAGNOSTIC
|
1998-08-29 21:14:52 +00:00
|
|
|
if (CTOV(cp)->v_usecount) {
|
1998-09-11 18:50:17 +00:00
|
|
|
panic("coda_inactive: nonzero reference count");
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
if (cp->c_ovp != NULL) {
|
1998-09-11 18:50:17 +00:00
|
|
|
panic("coda_inactive: cp->ovp != NULL");
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
#endif
|
1998-09-02 19:09:53 +00:00
|
|
|
VOP_UNLOCK(vp, 0, p);
|
1998-08-29 21:14:52 +00:00
|
|
|
vgone(vp);
|
|
|
|
}
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_SAT(CODA_INACTIVE_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remote file system operations having to do with directory manipulation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* It appears that in NetBSD, lookup is supposed to return the vnode locked
|
|
|
|
*/
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_lookup(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_lookup_args *ap = v;
|
|
|
|
struct vnode *dvp = ap->a_dvp;
|
|
|
|
struct cnode *dcp = VTOC(dvp);
|
|
|
|
struct vnode **vpp = ap->a_vpp;
|
|
|
|
/*
|
|
|
|
* It looks as though ap->a_cnp->ni_cnd->cn_nameptr holds the rest
|
|
|
|
* of the string to xlate, and that we must try to get at least
|
|
|
|
* ap->a_cnp->ni_cnd->cn_namelen of those characters to macth. I
|
|
|
|
* could be wrong.
|
|
|
|
*/
|
|
|
|
struct componentname *cnp = ap->a_cnp;
|
|
|
|
struct ucred *cred = cnp->cn_cred;
|
|
|
|
struct proc *p = cnp->cn_proc;
|
|
|
|
/* locals */
|
|
|
|
struct cnode *cp;
|
|
|
|
const char *nm = cnp->cn_nameptr;
|
|
|
|
int len = cnp->cn_namelen;
|
|
|
|
ViceFid VFid;
|
|
|
|
int vtype;
|
|
|
|
int error = 0;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_LOOKUP_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_LOOKUP, myprintf(("lookup: %s in %lx.%lx.%lx\n",
|
1998-08-29 21:14:52 +00:00
|
|
|
nm, dcp->c_fid.Volume,
|
|
|
|
dcp->c_fid.Vnode, dcp->c_fid.Unique)););
|
|
|
|
|
|
|
|
/* Check for lookup of control object. */
|
|
|
|
if (IS_CTL_NAME(dvp, nm, len)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
*vpp = coda_ctlvp;
|
1998-08-29 21:14:52 +00:00
|
|
|
vref(*vpp);
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_SAT(CODA_LOOKUP_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
if (len+1 > CODA_MAXNAMLEN) {
|
|
|
|
MARK_INT_FAIL(CODA_LOOKUP_STATS);
|
|
|
|
CODADEBUG(CODA_LOOKUP, myprintf(("name too long: lookup, %lx.%lx.%lx(%s)\n",
|
1998-08-29 21:14:52 +00:00
|
|
|
dcp->c_fid.Volume, dcp->c_fid.Vnode,
|
|
|
|
dcp->c_fid.Unique, nm)););
|
|
|
|
*vpp = (struct vnode *)0;
|
|
|
|
error = EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
/* First try to look the file up in the cfs name cache */
|
|
|
|
/* lock the parent vnode? */
|
1998-09-11 18:50:17 +00:00
|
|
|
cp = coda_nc_lookup(dcp, nm, len, cred);
|
1998-08-29 21:14:52 +00:00
|
|
|
if (cp) {
|
|
|
|
*vpp = CTOV(cp);
|
|
|
|
vref(*vpp);
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_LOOKUP,
|
1998-08-29 21:14:52 +00:00
|
|
|
myprintf(("lookup result %d vpp %p\n",error,*vpp));)
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* The name wasn't cached, so we need to contact Venus */
|
|
|
|
error = venus_lookup(vtomi(dvp), &dcp->c_fid, nm, len, cred, p, &VFid, &vtype);
|
|
|
|
|
|
|
|
if (error) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_LOOKUP_STATS);
|
|
|
|
CODADEBUG(CODA_LOOKUP, myprintf(("lookup error on %lx.%lx.%lx(%s)%d\n",
|
1998-08-29 21:14:52 +00:00
|
|
|
dcp->c_fid.Volume, dcp->c_fid.Vnode, dcp->c_fid.Unique, nm, error));)
|
|
|
|
*vpp = (struct vnode *)0;
|
|
|
|
} else {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_SAT(CODA_LOOKUP_STATS);
|
|
|
|
CODADEBUG(CODA_LOOKUP,
|
1998-08-29 21:14:52 +00:00
|
|
|
myprintf(("lookup: vol %lx vno %lx uni %lx type %o result %d\n",
|
|
|
|
VFid.Volume, VFid.Vnode, VFid.Unique, vtype,
|
|
|
|
error)); )
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
cp = make_coda_node(&VFid, dvp->v_mount, vtype);
|
1998-08-29 21:14:52 +00:00
|
|
|
*vpp = CTOV(cp);
|
|
|
|
|
|
|
|
/* enter the new vnode in the Name Cache only if the top bit isn't set */
|
|
|
|
/* And don't enter a new vnode for an invalid one! */
|
1998-09-11 18:50:17 +00:00
|
|
|
if (!(vtype & CODA_NOCACHE))
|
|
|
|
coda_nc_enter(VTOC(dvp), nm, len, cred, VTOC(*vpp));
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
|
|
|
/*
|
|
|
|
* If we are creating, and this was the last name to be looked up,
|
|
|
|
* and the error was ENOENT, then there really shouldn't be an
|
|
|
|
* error and we can make the leaf NULL and return success. Since
|
|
|
|
* this is supposed to work under Mach as well as NetBSD, we're
|
|
|
|
* leaving this fn wrapped. We also must tell lookup/namei that
|
|
|
|
* we need to save the last component of the name. (Create will
|
|
|
|
* have to free the name buffer later...lucky us...)
|
|
|
|
*/
|
|
|
|
if (((cnp->cn_nameiop == CREATE) || (cnp->cn_nameiop == RENAME))
|
|
|
|
&& (cnp->cn_flags & ISLASTCN)
|
|
|
|
&& (error == ENOENT))
|
|
|
|
{
|
|
|
|
error = EJUSTRETURN;
|
|
|
|
cnp->cn_flags |= SAVENAME;
|
|
|
|
*ap->a_vpp = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we are removing, and we are at the last element, and we
|
|
|
|
* found it, then we need to keep the name around so that the
|
|
|
|
* removal will go ahead as planned. Unfortunately, this will
|
|
|
|
* probably also lock the to-be-removed vnode, which may or may
|
|
|
|
* not be a good idea. I'll have to look at the bits of
|
1998-09-11 18:50:17 +00:00
|
|
|
* coda_remove to make sure. We'll only save the name if we did in
|
|
|
|
* fact find the name, otherwise coda_remove won't have a chance
|
1998-08-29 21:14:52 +00:00
|
|
|
* to free the pathname.
|
|
|
|
*/
|
|
|
|
if ((cnp->cn_nameiop == DELETE)
|
|
|
|
&& (cnp->cn_flags & ISLASTCN)
|
|
|
|
&& !error)
|
|
|
|
{
|
|
|
|
cnp->cn_flags |= SAVENAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the lookup went well, we need to (potentially?) unlock the
|
|
|
|
* parent, and lock the child. We are only responsible for
|
|
|
|
* checking to see if the parent is supposed to be unlocked before
|
|
|
|
* we return. We must always lock the child (provided there is
|
|
|
|
* one, and (the parent isn't locked or it isn't the same as the
|
|
|
|
* parent.) Simple, huh? We can never leave the parent locked unless
|
|
|
|
* we are ISLASTCN
|
|
|
|
*/
|
|
|
|
if (!error || (error == EJUSTRETURN)) {
|
|
|
|
if (!(cnp->cn_flags & LOCKPARENT) || !(cnp->cn_flags & ISLASTCN)) {
|
1998-09-02 19:09:53 +00:00
|
|
|
if ((error = VOP_UNLOCK(dvp, 0, p))) {
|
1998-08-29 21:14:52 +00:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* The parent is unlocked. As long as there is a child,
|
|
|
|
* lock it without bothering to check anything else.
|
|
|
|
*/
|
|
|
|
if (*ap->a_vpp) {
|
1998-09-02 19:09:53 +00:00
|
|
|
if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, p))) {
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_lookup: ");
|
1998-08-29 21:14:52 +00:00
|
|
|
panic("unlocked parent but couldn't lock child");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* The parent is locked, and may be the same as the child */
|
|
|
|
if (*ap->a_vpp && (*ap->a_vpp != dvp)) {
|
|
|
|
/* Different, go ahead and lock it. */
|
1998-09-02 19:09:53 +00:00
|
|
|
if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, p))) {
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_lookup: ");
|
1998-08-29 21:14:52 +00:00
|
|
|
panic("unlocked parent but couldn't lock child");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* If the lookup failed, we need to ensure that the leaf is NULL */
|
|
|
|
/* Don't change any locking? */
|
|
|
|
*ap->a_vpp = NULL;
|
|
|
|
}
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_create(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_create_args *ap = v;
|
|
|
|
struct vnode *dvp = ap->a_dvp;
|
|
|
|
struct cnode *dcp = VTOC(dvp);
|
|
|
|
struct vattr *va = ap->a_vap;
|
|
|
|
int exclusive = 1;
|
|
|
|
int mode = ap->a_vap->va_mode;
|
|
|
|
struct vnode **vpp = ap->a_vpp;
|
|
|
|
struct componentname *cnp = ap->a_cnp;
|
|
|
|
struct ucred *cred = cnp->cn_cred;
|
|
|
|
struct proc *p = cnp->cn_proc;
|
|
|
|
/* locals */
|
|
|
|
int error;
|
|
|
|
struct cnode *cp;
|
|
|
|
const char *nm = cnp->cn_nameptr;
|
|
|
|
int len = cnp->cn_namelen;
|
|
|
|
ViceFid VFid;
|
|
|
|
struct vattr attr;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_CREATE_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* All creates are exclusive XXX */
|
|
|
|
/* I'm assuming the 'mode' argument is the file mode bits XXX */
|
|
|
|
|
|
|
|
/* Check for create of control object. */
|
|
|
|
if (IS_CTL_NAME(dvp, nm, len)) {
|
|
|
|
*vpp = (struct vnode *)0;
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_CREATE_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(EACCES);
|
|
|
|
}
|
|
|
|
|
|
|
|
error = venus_create(vtomi(dvp), &dcp->c_fid, nm, len, exclusive, mode, va, cred, p, &VFid, &attr);
|
|
|
|
|
|
|
|
if (!error) {
|
|
|
|
|
|
|
|
/* If this is an exclusive create, panic if the file already exists. */
|
|
|
|
/* Venus should have detected the file and reported EEXIST. */
|
|
|
|
|
|
|
|
if ((exclusive == 1) &&
|
1998-09-11 18:50:17 +00:00
|
|
|
(coda_find(&VFid) != NULL))
|
1998-08-29 21:14:52 +00:00
|
|
|
panic("cnode existed for newly created file!");
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
cp = make_coda_node(&VFid, dvp->v_mount, attr.va_type);
|
1998-08-29 21:14:52 +00:00
|
|
|
*vpp = CTOV(cp);
|
|
|
|
|
|
|
|
/* Update va to reflect the new attributes. */
|
|
|
|
(*va) = attr;
|
|
|
|
|
|
|
|
/* Update the attribute cache and mark it as valid */
|
1998-09-11 18:50:17 +00:00
|
|
|
if (coda_attr_cache) {
|
1998-08-29 21:14:52 +00:00
|
|
|
VTOC(*vpp)->c_vattr = attr;
|
|
|
|
VTOC(*vpp)->c_flags |= C_VATTR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Invalidate the parent's attr cache, the modification time has changed */
|
|
|
|
VTOC(dvp)->c_flags &= ~C_VATTR;
|
|
|
|
|
|
|
|
/* enter the new vnode in the Name Cache */
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_nc_enter(VTOC(dvp), nm, len, cred, VTOC(*vpp));
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_CREATE,
|
1998-08-29 21:14:52 +00:00
|
|
|
myprintf(("create: (%lx.%lx.%lx), result %d\n",
|
|
|
|
VFid.Volume, VFid.Vnode, VFid.Unique, error)); )
|
|
|
|
} else {
|
|
|
|
*vpp = (struct vnode *)0;
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_CREATE, myprintf(("create error %d\n", error));)
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!error) {
|
|
|
|
if (cnp->cn_flags & LOCKLEAF) {
|
1998-09-02 19:09:53 +00:00
|
|
|
if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, p))) {
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_create: ");
|
1998-08-29 21:14:52 +00:00
|
|
|
panic("unlocked parent but couldn't lock child");
|
|
|
|
}
|
|
|
|
}
|
1998-09-25 17:38:32 +00:00
|
|
|
#ifdef OLD_DIAGNOSTIC
|
1998-08-29 21:14:52 +00:00
|
|
|
else {
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_create: LOCKLEAF not set!\n");
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
1998-09-25 17:38:32 +00:00
|
|
|
#endif
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_remove(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_remove_args *ap = v;
|
|
|
|
struct vnode *dvp = ap->a_dvp;
|
|
|
|
struct cnode *cp = VTOC(dvp);
|
|
|
|
struct componentname *cnp = ap->a_cnp;
|
|
|
|
struct ucred *cred = cnp->cn_cred;
|
|
|
|
struct proc *p = cnp->cn_proc;
|
|
|
|
/* locals */
|
|
|
|
int error;
|
|
|
|
const char *nm = cnp->cn_nameptr;
|
|
|
|
int len = cnp->cn_namelen;
|
|
|
|
struct cnode *tp;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_REMOVE_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_REMOVE, myprintf(("remove: %s in %lx.%lx.%lx\n",
|
1998-08-29 21:14:52 +00:00
|
|
|
nm, cp->c_fid.Volume, cp->c_fid.Vnode,
|
|
|
|
cp->c_fid.Unique)););
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
/* Remove the file's entry from the CODA Name Cache */
|
1998-08-29 21:14:52 +00:00
|
|
|
/* We're being conservative here, it might be that this person
|
|
|
|
* doesn't really have sufficient access to delete the file
|
|
|
|
* but we feel zapping the entry won't really hurt anyone -- dcs
|
|
|
|
*/
|
|
|
|
/* I'm gonna go out on a limb here. If a file and a hardlink to it
|
|
|
|
* exist, and one is removed, the link count on the other will be
|
|
|
|
* off by 1. We could either invalidate the attrs if cached, or
|
|
|
|
* fix them. I'll try to fix them. DCS 11/8/94
|
|
|
|
*/
|
1998-09-11 18:50:17 +00:00
|
|
|
tp = coda_nc_lookup(VTOC(dvp), nm, len, cred);
|
1998-08-29 21:14:52 +00:00
|
|
|
if (tp) {
|
|
|
|
if (VALID_VATTR(tp)) { /* If attrs are cached */
|
|
|
|
if (tp->c_vattr.va_nlink > 1) { /* If it's a hard link */
|
|
|
|
tp->c_vattr.va_nlink--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_nc_zapfile(VTOC(dvp), nm, len);
|
1998-08-29 21:14:52 +00:00
|
|
|
/* No need to flush it if it doesn't exist! */
|
|
|
|
}
|
|
|
|
/* Invalidate the parent's attr cache, the modification time has changed */
|
|
|
|
VTOC(dvp)->c_flags &= ~C_VATTR;
|
|
|
|
|
|
|
|
/* Check for remove of control object. */
|
|
|
|
if (IS_CTL_NAME(dvp, nm, len)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_REMOVE_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(ENOENT);
|
|
|
|
}
|
|
|
|
|
|
|
|
error = venus_remove(vtomi(dvp), &cp->c_fid, nm, len, cred, p);
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_REMOVE, myprintf(("in remove result %d\n",error)); )
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_link(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_link_args *ap = v;
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct cnode *cp = VTOC(vp);
|
|
|
|
struct vnode *tdvp = ap->a_tdvp;
|
|
|
|
struct cnode *tdcp = VTOC(tdvp);
|
|
|
|
struct componentname *cnp = ap->a_cnp;
|
|
|
|
struct ucred *cred = cnp->cn_cred;
|
|
|
|
struct proc *p = cnp->cn_proc;
|
|
|
|
/* locals */
|
|
|
|
int error;
|
|
|
|
const char *nm = cnp->cn_nameptr;
|
|
|
|
int len = cnp->cn_namelen;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_LINK_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
if (codadebug & CODADBGMSK(CODA_LINK)) {
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
myprintf(("nb_link: vp fid: (%lx.%lx.%lx)\n",
|
|
|
|
cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique));
|
|
|
|
myprintf(("nb_link: tdvp fid: (%lx.%lx.%lx)\n",
|
|
|
|
tdcp->c_fid.Volume, tdcp->c_fid.Vnode, tdcp->c_fid.Unique));
|
|
|
|
|
|
|
|
}
|
1998-09-11 18:50:17 +00:00
|
|
|
if (codadebug & CODADBGMSK(CODA_LINK)) {
|
1998-08-29 21:14:52 +00:00
|
|
|
myprintf(("link: vp fid: (%lx.%lx.%lx)\n",
|
|
|
|
cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique));
|
|
|
|
myprintf(("link: tdvp fid: (%lx.%lx.%lx)\n",
|
|
|
|
tdcp->c_fid.Volume, tdcp->c_fid.Vnode, tdcp->c_fid.Unique));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for link to/from control object. */
|
|
|
|
if (IS_CTL_NAME(tdvp, nm, len) || IS_CTL_VP(vp)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_LINK_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(EACCES);
|
|
|
|
}
|
|
|
|
|
|
|
|
error = venus_link(vtomi(vp), &cp->c_fid, &tdcp->c_fid, nm, len, cred, p);
|
|
|
|
|
|
|
|
/* Invalidate the parent's attr cache, the modification time has changed */
|
|
|
|
VTOC(tdvp)->c_flags &= ~C_VATTR;
|
|
|
|
VTOC(vp)->c_flags &= ~C_VATTR;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_LINK, myprintf(("in link result %d\n",error)); )
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_rename(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_rename_args *ap = v;
|
|
|
|
struct vnode *odvp = ap->a_fdvp;
|
|
|
|
struct cnode *odcp = VTOC(odvp);
|
|
|
|
struct componentname *fcnp = ap->a_fcnp;
|
|
|
|
struct vnode *ndvp = ap->a_tdvp;
|
|
|
|
struct cnode *ndcp = VTOC(ndvp);
|
|
|
|
struct componentname *tcnp = ap->a_tcnp;
|
|
|
|
struct ucred *cred = fcnp->cn_cred;
|
|
|
|
struct proc *p = fcnp->cn_proc;
|
|
|
|
/* true args */
|
|
|
|
int error;
|
|
|
|
const char *fnm = fcnp->cn_nameptr;
|
|
|
|
int flen = fcnp->cn_namelen;
|
|
|
|
const char *tnm = tcnp->cn_nameptr;
|
|
|
|
int tlen = tcnp->cn_namelen;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_RENAME_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Hmmm. The vnodes are already looked up. Perhaps they are locked?
|
|
|
|
This could be Bad. XXX */
|
1998-09-25 17:38:32 +00:00
|
|
|
#ifdef OLD_DIAGNOSTIC
|
1998-08-29 21:14:52 +00:00
|
|
|
if ((fcnp->cn_cred != tcnp->cn_cred)
|
|
|
|
|| (fcnp->cn_proc != tcnp->cn_proc))
|
|
|
|
{
|
1998-09-11 18:50:17 +00:00
|
|
|
panic("coda_rename: component names don't agree");
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
1998-09-25 17:38:32 +00:00
|
|
|
#endif
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Check for rename involving control object. */
|
|
|
|
if (IS_CTL_NAME(odvp, fnm, flen) || IS_CTL_NAME(ndvp, tnm, tlen)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_RENAME_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(EACCES);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Problem with moving directories -- need to flush entry for .. */
|
|
|
|
if (odvp != ndvp) {
|
1998-09-11 18:50:17 +00:00
|
|
|
struct cnode *ovcp = coda_nc_lookup(VTOC(odvp), fnm, flen, cred);
|
1998-08-29 21:14:52 +00:00
|
|
|
if (ovcp) {
|
|
|
|
struct vnode *ovp = CTOV(ovcp);
|
|
|
|
if ((ovp) &&
|
|
|
|
(ovp->v_type == VDIR)) /* If it's a directory */
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_nc_zapfile(VTOC(ovp),"..", 2);
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove the entries for both source and target files */
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_nc_zapfile(VTOC(odvp), fnm, flen);
|
|
|
|
coda_nc_zapfile(VTOC(ndvp), tnm, tlen);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Invalidate the parent's attr cache, the modification time has changed */
|
|
|
|
VTOC(odvp)->c_flags &= ~C_VATTR;
|
|
|
|
VTOC(ndvp)->c_flags &= ~C_VATTR;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
if (flen+1 > CODA_MAXNAMLEN) {
|
|
|
|
MARK_INT_FAIL(CODA_RENAME_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
error = EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
if (tlen+1 > CODA_MAXNAMLEN) {
|
|
|
|
MARK_INT_FAIL(CODA_RENAME_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
error = EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = venus_rename(vtomi(odvp), &odcp->c_fid, &ndcp->c_fid, fnm, flen, tnm, tlen, cred, p);
|
|
|
|
|
|
|
|
exit:
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_RENAME, myprintf(("in rename result %d\n",error));)
|
1998-08-29 21:14:52 +00:00
|
|
|
/* XXX - do we need to call cache pureg on the moved vnode? */
|
|
|
|
cache_purge(ap->a_fvp);
|
|
|
|
|
|
|
|
/* It seems to be incumbent on us to drop locks on all four vnodes */
|
|
|
|
/* From-vnodes are not locked, only ref'd. To-vnodes are locked. */
|
|
|
|
|
|
|
|
vrele(ap->a_fvp);
|
|
|
|
vrele(odvp);
|
|
|
|
|
|
|
|
if (ap->a_tvp) {
|
|
|
|
if (ap->a_tvp == ndvp) {
|
|
|
|
vrele(ap->a_tvp);
|
|
|
|
} else {
|
|
|
|
vput(ap->a_tvp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vput(ndvp);
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_mkdir(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_mkdir_args *ap = v;
|
|
|
|
struct vnode *dvp = ap->a_dvp;
|
|
|
|
struct cnode *dcp = VTOC(dvp);
|
|
|
|
struct componentname *cnp = ap->a_cnp;
|
|
|
|
register struct vattr *va = ap->a_vap;
|
|
|
|
struct vnode **vpp = ap->a_vpp;
|
|
|
|
struct ucred *cred = cnp->cn_cred;
|
|
|
|
struct proc *p = cnp->cn_proc;
|
|
|
|
/* locals */
|
|
|
|
int error;
|
|
|
|
const char *nm = cnp->cn_nameptr;
|
|
|
|
int len = cnp->cn_namelen;
|
|
|
|
struct cnode *cp;
|
|
|
|
ViceFid VFid;
|
|
|
|
struct vattr ova;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_MKDIR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Check for mkdir of target object. */
|
|
|
|
if (IS_CTL_NAME(dvp, nm, len)) {
|
|
|
|
*vpp = (struct vnode *)0;
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_MKDIR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(EACCES);
|
|
|
|
}
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
if (len+1 > CODA_MAXNAMLEN) {
|
1998-08-29 21:14:52 +00:00
|
|
|
*vpp = (struct vnode *)0;
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_MKDIR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(EACCES);
|
|
|
|
}
|
|
|
|
|
|
|
|
error = venus_mkdir(vtomi(dvp), &dcp->c_fid, nm, len, va, cred, p, &VFid, &ova);
|
|
|
|
|
|
|
|
if (!error) {
|
1998-09-11 18:50:17 +00:00
|
|
|
if (coda_find(&VFid) != NULL)
|
1998-08-29 21:14:52 +00:00
|
|
|
panic("cnode existed for newly created directory!");
|
|
|
|
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
cp = make_coda_node(&VFid, dvp->v_mount, va->va_type);
|
1998-08-29 21:14:52 +00:00
|
|
|
*vpp = CTOV(cp);
|
|
|
|
|
|
|
|
/* enter the new vnode in the Name Cache */
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_nc_enter(VTOC(dvp), nm, len, cred, VTOC(*vpp));
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* as a side effect, enter "." and ".." for the directory */
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_nc_enter(VTOC(*vpp), ".", 1, cred, VTOC(*vpp));
|
|
|
|
coda_nc_enter(VTOC(*vpp), "..", 2, cred, VTOC(dvp));
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
if (coda_attr_cache) {
|
1998-08-29 21:14:52 +00:00
|
|
|
VTOC(*vpp)->c_vattr = ova; /* update the attr cache */
|
|
|
|
VTOC(*vpp)->c_flags |= C_VATTR; /* Valid attributes in cnode */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Invalidate the parent's attr cache, the modification time has changed */
|
|
|
|
VTOC(dvp)->c_flags &= ~C_VATTR;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG( CODA_MKDIR, myprintf(("mkdir: (%lx.%lx.%lx) result %d\n",
|
1998-08-29 21:14:52 +00:00
|
|
|
VFid.Volume, VFid.Vnode, VFid.Unique, error)); )
|
|
|
|
} else {
|
|
|
|
*vpp = (struct vnode *)0;
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_MKDIR, myprintf(("mkdir error %d\n",error));)
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_rmdir(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_rmdir_args *ap = v;
|
|
|
|
struct vnode *dvp = ap->a_dvp;
|
|
|
|
struct cnode *dcp = VTOC(dvp);
|
|
|
|
struct componentname *cnp = ap->a_cnp;
|
|
|
|
struct ucred *cred = cnp->cn_cred;
|
|
|
|
struct proc *p = cnp->cn_proc;
|
|
|
|
/* true args */
|
|
|
|
int error;
|
|
|
|
const char *nm = cnp->cn_nameptr;
|
|
|
|
int len = cnp->cn_namelen;
|
|
|
|
struct cnode *cp;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_RMDIR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Check for rmdir of control object. */
|
|
|
|
if (IS_CTL_NAME(dvp, nm, len)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_RMDIR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(ENOENT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We're being conservative here, it might be that this person
|
|
|
|
* doesn't really have sufficient access to delete the file
|
|
|
|
* but we feel zapping the entry won't really hurt anyone -- dcs
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* As a side effect of the rmdir, remove any entries for children of
|
|
|
|
* the directory, especially "." and "..".
|
|
|
|
*/
|
1998-09-11 18:50:17 +00:00
|
|
|
cp = coda_nc_lookup(dcp, nm, len, cred);
|
|
|
|
if (cp) coda_nc_zapParentfid(&(cp->c_fid), NOT_DOWNCALL);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
/* Remove the file's entry from the CODA Name Cache */
|
|
|
|
coda_nc_zapfile(dcp, nm, len);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Invalidate the parent's attr cache, the modification time has changed */
|
|
|
|
dcp->c_flags &= ~C_VATTR;
|
|
|
|
|
|
|
|
error = venus_rmdir(vtomi(dvp), &dcp->c_fid, nm, len, cred, p);
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_RMDIR, myprintf(("in rmdir result %d\n", error)); )
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_symlink(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_symlink_args *ap = v;
|
|
|
|
struct vnode *tdvp = ap->a_dvp;
|
|
|
|
struct cnode *tdcp = VTOC(tdvp);
|
|
|
|
struct componentname *cnp = ap->a_cnp;
|
|
|
|
struct vattr *tva = ap->a_vap;
|
|
|
|
char *path = ap->a_target;
|
|
|
|
struct ucred *cred = cnp->cn_cred;
|
|
|
|
struct proc *p = cnp->cn_proc;
|
1999-11-13 20:58:17 +00:00
|
|
|
struct vnode **vpp = ap->a_vpp;
|
1998-08-29 21:14:52 +00:00
|
|
|
/* locals */
|
|
|
|
int error;
|
|
|
|
/*
|
1998-09-11 18:50:17 +00:00
|
|
|
* XXX I'm assuming the following things about coda_symlink's
|
1998-08-29 21:14:52 +00:00
|
|
|
* arguments:
|
|
|
|
* t(foo) is the new name/parent/etc being created.
|
|
|
|
* lname is the contents of the new symlink.
|
|
|
|
*/
|
1998-09-02 19:09:53 +00:00
|
|
|
char *nm = cnp->cn_nameptr;
|
1998-08-29 21:14:52 +00:00
|
|
|
int len = cnp->cn_namelen;
|
|
|
|
int plen = strlen(path);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Here's the strategy for the moment: perform the symlink, then
|
|
|
|
* do a lookup to grab the resulting vnode. I know this requires
|
|
|
|
* two communications with Venus for a new sybolic link, but
|
|
|
|
* that's the way the ball bounces. I don't yet want to change
|
|
|
|
* the way the Mach symlink works. When Mach support is
|
|
|
|
* deprecated, we should change symlink so that the common case
|
|
|
|
* returns the resultant vnode in a vpp argument.
|
|
|
|
*/
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_SYMLINK_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Check for symlink of control object. */
|
|
|
|
if (IS_CTL_NAME(tdvp, nm, len)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_SYMLINK_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(EACCES);
|
|
|
|
}
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
if (plen+1 > CODA_MAXPATHLEN) {
|
|
|
|
MARK_INT_FAIL(CODA_SYMLINK_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
if (len+1 > CODA_MAXNAMLEN) {
|
|
|
|
MARK_INT_FAIL(CODA_SYMLINK_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
error = EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = venus_symlink(vtomi(tdvp), &tdcp->c_fid, path, plen, nm, len, tva, cred, p);
|
|
|
|
|
|
|
|
/* Invalidate the parent's attr cache, the modification time has changed */
|
|
|
|
tdcp->c_flags &= ~C_VATTR;
|
|
|
|
|
1999-11-13 20:58:17 +00:00
|
|
|
if (error == 0)
|
|
|
|
error = VOP_LOOKUP(tdvp, vpp, cnp);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
exit:
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_SYMLINK, myprintf(("in symlink result %d\n",error)); )
|
1998-08-29 21:14:52 +00:00
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read directory entries.
|
|
|
|
*/
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_readdir(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_readdir_args *ap = v;
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct cnode *cp = VTOC(vp);
|
|
|
|
register struct uio *uiop = ap->a_uio;
|
|
|
|
struct ucred *cred = ap->a_cred;
|
|
|
|
int *eofflag = ap->a_eofflag;
|
|
|
|
u_long **cookies = ap->a_cookies;
|
|
|
|
int *ncookies = ap->a_ncookies;
|
|
|
|
struct proc *p = ap->a_uio->uio_procp;
|
|
|
|
/* upcall decl */
|
|
|
|
/* locals */
|
|
|
|
int error = 0;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_READDIR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1999-08-08 13:22:05 +00:00
|
|
|
CODADEBUG(CODA_READDIR, myprintf(("coda_readdir(%p, %d, %lld, %d)\n",
|
|
|
|
(void *)uiop->uio_iov->iov_base,
|
|
|
|
uiop->uio_resid,
|
|
|
|
(long long)uiop->uio_offset,
|
|
|
|
uiop->uio_segflg)); )
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Check for readdir of control object. */
|
|
|
|
if (IS_CTL_VP(vp)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_READDIR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(ENOENT);
|
|
|
|
}
|
|
|
|
|
1998-09-02 19:09:53 +00:00
|
|
|
{
|
1998-08-29 21:14:52 +00:00
|
|
|
/* If directory is not already open do an "internal open" on it. */
|
|
|
|
int opened_internally = 0;
|
|
|
|
if (cp->c_ovp == NULL) {
|
|
|
|
opened_internally = 1;
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_GEN(CODA_OPEN_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
error = VOP_OPEN(vp, FREAD, cred, p);
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_readdir: Internally Opening %p\n", vp);
|
1998-08-29 21:14:52 +00:00
|
|
|
if (error) {
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_readdir: VOP_OPEN on container failed %d\n", error);
|
1998-08-29 21:14:52 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
if (vp->v_type == VREG) {
|
1999-01-05 18:50:03 +00:00
|
|
|
error = vfs_object_create(vp, p, cred);
|
1998-08-29 21:14:52 +00:00
|
|
|
if (error != 0) {
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_readdir: vfs_object_create() returns %d\n", error);
|
1998-08-29 21:14:52 +00:00
|
|
|
vput(vp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (error) return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Have UFS handle the call. */
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_READDIR, myprintf(("indirect readdir: fid = (%lx.%lx.%lx), refcnt = %d\n",cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique, vp->v_usecount)); )
|
1998-08-29 21:14:52 +00:00
|
|
|
error = VOP_READDIR(cp->c_ovp, uiop, cred, eofflag, ncookies,
|
|
|
|
cookies);
|
|
|
|
|
|
|
|
if (error)
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_READDIR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
else
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_SAT(CODA_READDIR_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Do an "internal close" if necessary. */
|
|
|
|
if (opened_internally) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_GEN(CODA_CLOSE_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
(void)VOP_CLOSE(vp, FREAD, cred, p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert from file system blocks to device blocks
|
|
|
|
*/
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_bmap(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* XXX on the global proc */
|
|
|
|
/* true args */
|
|
|
|
struct vop_bmap_args *ap = v;
|
|
|
|
struct vnode *vp __attribute__((unused)) = ap->a_vp; /* file's vnode */
|
|
|
|
daddr_t bn __attribute__((unused)) = ap->a_bn; /* fs block number */
|
|
|
|
struct vnode **vpp = ap->a_vpp; /* RETURN vp of device */
|
|
|
|
daddr_t *bnp __attribute__((unused)) = ap->a_bnp; /* RETURN device block number */
|
|
|
|
struct proc *p __attribute__((unused)) = curproc;
|
|
|
|
/* upcall decl */
|
|
|
|
/* locals */
|
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct cnode *cp;
|
|
|
|
|
|
|
|
cp = VTOC(vp);
|
|
|
|
if (cp->c_ovp) {
|
1998-09-28 20:52:58 +00:00
|
|
|
return EINVAL;
|
1998-08-29 21:14:52 +00:00
|
|
|
ret = VOP_BMAP(cp->c_ovp, bn, vpp, bnp, ap->a_runp, ap->a_runb);
|
1998-09-25 17:38:32 +00:00
|
|
|
#if 0
|
1998-08-29 21:14:52 +00:00
|
|
|
printf("VOP_BMAP(cp->c_ovp %p, bn %p, vpp %p, bnp %p, ap->a_runp %p, ap->a_runb %p) = %d\n",
|
|
|
|
cp->c_ovp, bn, vpp, bnp, ap->a_runp, ap->a_runb, ret);
|
1998-09-25 17:38:32 +00:00
|
|
|
#endif
|
1998-08-29 21:14:52 +00:00
|
|
|
return ret;
|
|
|
|
} else {
|
1998-12-04 18:44:21 +00:00
|
|
|
#if 0
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_bmap: no container\n");
|
1998-12-04 18:44:21 +00:00
|
|
|
#endif
|
1998-08-29 21:14:52 +00:00
|
|
|
return(EOPNOTSUPP);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* I don't think the following two things are used anywhere, so I've
|
|
|
|
* commented them out
|
|
|
|
*
|
|
|
|
* struct buf *async_bufhead;
|
|
|
|
* int async_daemon_count;
|
|
|
|
*/
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_strategy(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_strategy_args *ap = v;
|
|
|
|
register struct buf *bp __attribute__((unused)) = ap->a_bp;
|
|
|
|
struct proc *p __attribute__((unused)) = curproc;
|
|
|
|
/* upcall decl */
|
|
|
|
/* locals */
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_strategy: called ???\n");
|
1998-08-29 21:14:52 +00:00
|
|
|
return(EOPNOTSUPP);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_reclaim(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_reclaim_args *ap = v;
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct cnode *cp = VTOC(vp);
|
|
|
|
/* upcall decl */
|
|
|
|
/* locals */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Forced unmount/flush will let vnodes with non zero use be destroyed!
|
|
|
|
*/
|
|
|
|
ENTRY;
|
|
|
|
|
|
|
|
if (IS_UNMOUNTING(cp)) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (VTOC(vp)->c_ovp) {
|
|
|
|
if (IS_UNMOUNTING(cp))
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_reclaim: c_ovp not void: vp %p, cp %p\n", vp, cp);
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
} else {
|
1998-09-25 17:38:32 +00:00
|
|
|
#ifdef OLD_DIAGNOSTIC
|
1998-08-29 21:14:52 +00:00
|
|
|
if (vp->v_usecount != 0)
|
1998-09-25 17:38:32 +00:00
|
|
|
print("coda_reclaim: pushing active %p\n", vp);
|
1998-08-29 21:14:52 +00:00
|
|
|
if (VTOC(vp)->c_ovp) {
|
1998-09-11 18:50:17 +00:00
|
|
|
panic("coda_reclaim: c_ovp not void");
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
1998-09-25 17:38:32 +00:00
|
|
|
#endif
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
cache_purge(vp);
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_free(VTOC(vp));
|
1998-08-29 21:14:52 +00:00
|
|
|
VTOC(vp) = NULL;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_lock(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_lock_args *ap = v;
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct cnode *cp = VTOC(vp);
|
|
|
|
struct proc *p = ap->a_p;
|
|
|
|
/* upcall decl */
|
|
|
|
/* locals */
|
|
|
|
|
|
|
|
ENTRY;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
if (coda_lockdebug) {
|
1998-08-29 21:14:52 +00:00
|
|
|
myprintf(("Attempting lock on %lx.%lx.%lx\n",
|
|
|
|
cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique));
|
|
|
|
}
|
|
|
|
|
1999-01-20 14:49:12 +00:00
|
|
|
#ifndef DEBUG_LOCKS
|
1998-09-02 19:09:53 +00:00
|
|
|
return (lockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, p));
|
1999-01-20 14:49:12 +00:00
|
|
|
#else
|
|
|
|
return (debuglockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, p,
|
|
|
|
"coda_lock", vp->filename, vp->line));
|
|
|
|
#endif
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_unlock(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_unlock_args *ap = v;
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct cnode *cp = VTOC(vp);
|
|
|
|
struct proc *p = ap->a_p;
|
|
|
|
/* upcall decl */
|
|
|
|
/* locals */
|
|
|
|
|
|
|
|
ENTRY;
|
1998-09-11 18:50:17 +00:00
|
|
|
if (coda_lockdebug) {
|
1998-08-29 21:14:52 +00:00
|
|
|
myprintf(("Attempting unlock on %lx.%lx.%lx\n",
|
|
|
|
cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique));
|
|
|
|
}
|
|
|
|
|
1998-09-02 19:09:53 +00:00
|
|
|
return (lockmgr(&cp->c_lock, ap->a_flags | LK_RELEASE, &vp->v_interlock, p));
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_islocked(v)
|
1998-08-29 21:14:52 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
/* true args */
|
|
|
|
struct vop_islocked_args *ap = v;
|
|
|
|
struct cnode *cp = VTOC(ap->a_vp);
|
|
|
|
ENTRY;
|
|
|
|
|
1999-12-11 16:13:02 +00:00
|
|
|
return (lockstatus(&cp->c_lock, ap->a_p));
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* How one looks up a vnode given a device/inode pair: */
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_grab_vnode(dev_t dev, ino_t ino, struct vnode **vpp)
|
1998-08-29 21:14:52 +00:00
|
|
|
{
|
|
|
|
/* This is like VFS_VGET() or igetinode()! */
|
|
|
|
int error;
|
|
|
|
struct mount *mp;
|
|
|
|
|
|
|
|
if (!(mp = devtomp(dev))) {
|
1999-08-08 13:22:05 +00:00
|
|
|
myprintf(("coda_grab_vnode: devtomp(%#lx) returns NULL\n",
|
|
|
|
(u_long)dev2udev(dev)));
|
1998-08-29 21:14:52 +00:00
|
|
|
return(ENXIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX - ensure that nonzero-return means failure */
|
|
|
|
error = VFS_VGET(mp,ino,vpp);
|
|
|
|
if (error) {
|
1999-08-08 13:22:05 +00:00
|
|
|
myprintf(("coda_grab_vnode: iget/vget(%lx, %lu) returns %p, err %d\n",
|
|
|
|
(u_long)dev2udev(dev), (u_long)ino, (void *)*vpp, error));
|
1998-08-29 21:14:52 +00:00
|
|
|
return(ENOENT);
|
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
print_vattr( attr )
|
|
|
|
struct vattr *attr;
|
|
|
|
{
|
|
|
|
char *typestr;
|
|
|
|
|
|
|
|
switch (attr->va_type) {
|
|
|
|
case VNON:
|
|
|
|
typestr = "VNON";
|
|
|
|
break;
|
|
|
|
case VREG:
|
|
|
|
typestr = "VREG";
|
|
|
|
break;
|
|
|
|
case VDIR:
|
|
|
|
typestr = "VDIR";
|
|
|
|
break;
|
|
|
|
case VBLK:
|
|
|
|
typestr = "VBLK";
|
|
|
|
break;
|
|
|
|
case VCHR:
|
|
|
|
typestr = "VCHR";
|
|
|
|
break;
|
|
|
|
case VLNK:
|
|
|
|
typestr = "VLNK";
|
|
|
|
break;
|
|
|
|
case VSOCK:
|
|
|
|
typestr = "VSCK";
|
|
|
|
break;
|
|
|
|
case VFIFO:
|
|
|
|
typestr = "VFFO";
|
|
|
|
break;
|
|
|
|
case VBAD:
|
|
|
|
typestr = "VBAD";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
typestr = "????";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
myprintf(("attr: type %s mode %d uid %d gid %d fsid %d rdev %d\n",
|
|
|
|
typestr, (int)attr->va_mode, (int)attr->va_uid,
|
|
|
|
(int)attr->va_gid, (int)attr->va_fsid, (int)attr->va_rdev));
|
|
|
|
|
|
|
|
myprintf((" fileid %d nlink %d size %d blocksize %d bytes %d\n",
|
|
|
|
(int)attr->va_fileid, (int)attr->va_nlink,
|
|
|
|
(int)attr->va_size,
|
|
|
|
(int)attr->va_blocksize,(int)attr->va_bytes));
|
|
|
|
myprintf((" gen %ld flags %ld vaflags %d\n",
|
|
|
|
attr->va_gen, attr->va_flags, attr->va_vaflags));
|
|
|
|
myprintf((" atime sec %d nsec %d\n",
|
|
|
|
(int)attr->va_atime.tv_sec, (int)attr->va_atime.tv_nsec));
|
|
|
|
myprintf((" mtime sec %d nsec %d\n",
|
|
|
|
(int)attr->va_mtime.tv_sec, (int)attr->va_mtime.tv_nsec));
|
|
|
|
myprintf((" ctime sec %d nsec %d\n",
|
|
|
|
(int)attr->va_ctime.tv_sec, (int)attr->va_ctime.tv_nsec));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* How to print a ucred */
|
|
|
|
void
|
|
|
|
print_cred(cred)
|
|
|
|
struct ucred *cred;
|
|
|
|
{
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
myprintf(("ref %d\tuid %d\n",cred->cr_ref,cred->cr_uid));
|
|
|
|
|
|
|
|
for (i=0; i < cred->cr_ngroups; i++)
|
|
|
|
myprintf(("\tgroup %d: (%d)\n",i,cred->cr_groups[i]));
|
|
|
|
myprintf(("\n"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return a vnode for the given fid.
|
|
|
|
* If no cnode exists for this fid create one and put it
|
|
|
|
* in a table hashed by fid.Volume and fid.Vnode. If the cnode for
|
|
|
|
* this fid is already in the table return it (ref count is
|
1998-09-11 18:50:17 +00:00
|
|
|
* incremented by coda_find. The cnode will be flushed from the
|
|
|
|
* table when coda_inactive calls coda_unsave.
|
1998-08-29 21:14:52 +00:00
|
|
|
*/
|
|
|
|
struct cnode *
|
1998-09-11 18:50:17 +00:00
|
|
|
make_coda_node(fid, vfsp, type)
|
1998-08-29 21:14:52 +00:00
|
|
|
ViceFid *fid; struct mount *vfsp; short type;
|
|
|
|
{
|
|
|
|
struct cnode *cp;
|
|
|
|
int err;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
if ((cp = coda_find(fid)) == NULL) {
|
1998-08-29 21:14:52 +00:00
|
|
|
struct vnode *vp;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
cp = coda_alloc();
|
1998-08-29 21:14:52 +00:00
|
|
|
lockinit(&cp->c_lock, PINOD, "cnode", 0, 0);
|
|
|
|
cp->c_fid = *fid;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
err = getnewvnode(VT_CODA, vfsp, coda_vnodeop_p, &vp);
|
1998-08-29 21:14:52 +00:00
|
|
|
if (err) {
|
1998-09-11 18:50:17 +00:00
|
|
|
panic("coda: getnewvnode returned error %d\n", err);
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
vp->v_data = cp;
|
|
|
|
vp->v_type = type;
|
|
|
|
cp->c_vnode = vp;
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_save(cp);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
vref(CTOV(cp));
|
|
|
|
}
|
|
|
|
|
|
|
|
return cp;
|
|
|
|
}
|