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-11 18:50:17 +00:00
|
|
|
* @(#) src/sys/cfs/coda_vfsops.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) 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.
|
|
|
|
*/
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
#include <vcoda.h>
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/conf.h>
|
1998-09-02 19:09:53 +00:00
|
|
|
#include <sys/kernel.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/lock.h>
|
1998-08-29 21:14:52 +00:00
|
|
|
#include <sys/malloc.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/mount.h>
|
1998-08-29 21:14:52 +00:00
|
|
|
#include <sys/namei.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/proc.h>
|
2001-04-23 18:51:54 +00:00
|
|
|
#include <sys/socket.h>
|
1999-12-15 23:02:35 +00:00
|
|
|
|
1998-09-13 13:57:59 +00:00
|
|
|
#include <coda/coda.h>
|
|
|
|
#include <coda/cnode.h>
|
|
|
|
#include <coda/coda_vfsops.h>
|
|
|
|
#include <coda/coda_venus.h>
|
|
|
|
#include <coda/coda_subr.h>
|
|
|
|
#include <coda/coda_opstats.h>
|
1998-09-02 19:09:53 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MALLOC_DEFINE(M_CODA, "CODA storage", "Various Coda Structures");
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
int codadebug = 0;
|
|
|
|
int coda_vfsop_print_entry = 0;
|
|
|
|
#define ENTRY if(coda_vfsop_print_entry) myprintf(("Entered %s\n",__FUNCTION__))
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
struct vnode *coda_ctlvp;
|
|
|
|
struct coda_mntinfo coda_mnttbl[NVCODA]; /* indexed by minor device number */
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* structure to keep statistics of internally generated/satisfied calls */
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
struct coda_op_stats coda_vfsopstats[CODA_VFSOPS_SIZE];
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
#define MARK_ENTRY(op) (coda_vfsopstats[op].entries++)
|
|
|
|
#define MARK_INT_SAT(op) (coda_vfsopstats[op].sat_intrn++)
|
|
|
|
#define MARK_INT_FAIL(op) (coda_vfsopstats[op].unsat_intrn++)
|
|
|
|
#define MRAK_INT_GEN(op) (coda_vfsopstats[op].gen_intrn++)
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
extern int coda_nc_initialized; /* Set if cache has been initialized */
|
1998-08-29 21:14:52 +00:00
|
|
|
extern int vc_nb_open __P((dev_t, int, int, struct proc *));
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_vfsopstats_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_VFSOPS_SIZE;i++) {
|
|
|
|
coda_vfsopstats[i].opcode = i;
|
|
|
|
coda_vfsopstats[i].entries = 0;
|
|
|
|
coda_vfsopstats[i].sat_intrn = 0;
|
|
|
|
coda_vfsopstats[i].unsat_intrn = 0;
|
|
|
|
coda_vfsopstats[i].gen_intrn = 0;
|
1998-08-29 21:14:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* cfs mount vfsop
|
|
|
|
* Set up mount info record and attach it to vfs struct.
|
|
|
|
*/
|
|
|
|
/*ARGSUSED*/
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_mount(vfsp, path, data, ndp, p)
|
1998-08-29 21:14:52 +00:00
|
|
|
struct mount *vfsp; /* Allocated and initialized by mount(2) */
|
|
|
|
char *path; /* path covered: ignored by the fs-layer */
|
|
|
|
caddr_t data; /* Need to define a data type for this in netbsd? */
|
|
|
|
struct nameidata *ndp; /* Clobber this to lookup the device name */
|
|
|
|
struct proc *p; /* The ever-famous proc pointer */
|
|
|
|
{
|
|
|
|
struct vnode *dvp;
|
|
|
|
struct cnode *cp;
|
|
|
|
dev_t dev;
|
1998-09-11 18:50:17 +00:00
|
|
|
struct coda_mntinfo *mi;
|
1998-08-29 21:14:52 +00:00
|
|
|
struct vnode *rootvp;
|
|
|
|
ViceFid rootfid;
|
|
|
|
ViceFid ctlfid;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
ENTRY;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_vfsopstats_init();
|
|
|
|
coda_vnodeopstats_init();
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_MOUNT_STATS);
|
|
|
|
if (CODA_MOUNTED(vfsp)) {
|
|
|
|
MARK_INT_FAIL(CODA_MOUNT_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(EBUSY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Validate mount device. Similar to getmdev(). */
|
|
|
|
NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, data, p);
|
|
|
|
error = namei(ndp);
|
|
|
|
dvp = ndp->ni_vp;
|
|
|
|
|
|
|
|
if (error) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_MOUNT_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
if (dvp->v_type != VCHR) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_MOUNT_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
vrele(dvp);
|
1999-12-15 23:02:35 +00:00
|
|
|
NDFREE(ndp, NDF_ONLY_PNBUF);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(ENXIO);
|
|
|
|
}
|
1999-07-20 07:18:17 +00:00
|
|
|
dev = dvp->v_rdev;
|
1998-08-29 21:14:52 +00:00
|
|
|
vrele(dvp);
|
1999-12-15 23:02:35 +00:00
|
|
|
NDFREE(ndp, NDF_ONLY_PNBUF);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* See if the device table matches our expectations.
|
|
|
|
*/
|
1999-05-08 06:40:31 +00:00
|
|
|
if (devsw(dev)->d_open != vc_nb_open)
|
1998-08-29 21:14:52 +00:00
|
|
|
{
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_MOUNT_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(ENXIO);
|
|
|
|
}
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
if (minor(dev) >= NVCODA || minor(dev) < 0) {
|
|
|
|
MARK_INT_FAIL(CODA_MOUNT_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(ENXIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the mount record and link it to the vfs struct
|
|
|
|
*/
|
1998-09-11 18:50:17 +00:00
|
|
|
mi = &coda_mnttbl[minor(dev)];
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
if (!VC_OPEN(&mi->mi_vcomm)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_MOUNT_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(ENODEV);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No initialization (here) of mi_vcomm! */
|
|
|
|
vfsp->mnt_data = (qaddr_t)mi;
|
|
|
|
vfs_getnewfsid (vfsp);
|
|
|
|
|
|
|
|
mi->mi_vfsp = vfsp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make a root vnode to placate the Vnode interface, but don't
|
1998-09-11 18:50:17 +00:00
|
|
|
* actually make the CODA_ROOT call to venus until the first call
|
|
|
|
* to coda_root in case a server is down while venus is starting.
|
1998-08-29 21:14:52 +00:00
|
|
|
*/
|
|
|
|
rootfid.Volume = 0;
|
|
|
|
rootfid.Vnode = 0;
|
|
|
|
rootfid.Unique = 0;
|
1998-09-11 18:50:17 +00:00
|
|
|
cp = make_coda_node(&rootfid, vfsp, VDIR);
|
1998-08-29 21:14:52 +00:00
|
|
|
rootvp = CTOV(cp);
|
|
|
|
rootvp->v_flag |= VROOT;
|
|
|
|
|
|
|
|
ctlfid.Volume = CTL_VOL;
|
|
|
|
ctlfid.Vnode = CTL_VNO;
|
|
|
|
ctlfid.Unique = CTL_UNI;
|
1998-09-11 18:50:17 +00:00
|
|
|
/* cp = make_coda_node(&ctlfid, vfsp, VCHR);
|
1998-08-29 21:14:52 +00:00
|
|
|
The above code seems to cause a loop in the cnode links.
|
|
|
|
I don't totally understand when it happens, it is caught
|
|
|
|
when closing down the system.
|
|
|
|
*/
|
1998-09-11 18:50:17 +00:00
|
|
|
cp = make_coda_node(&ctlfid, 0, VCHR);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_ctlvp = CTOV(cp);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* Add vfs and rootvp to chain of vfs hanging off mntinfo */
|
|
|
|
mi->mi_vfsp = vfsp;
|
|
|
|
mi->mi_rootvp = rootvp;
|
|
|
|
|
|
|
|
/* set filesystem block size */
|
|
|
|
vfsp->mnt_stat.f_bsize = 8192; /* XXX -JJK */
|
1998-09-02 19:09:53 +00:00
|
|
|
|
1998-08-29 21:14:52 +00:00
|
|
|
/* Set f_iosize. XXX -- inamura@isl.ntt.co.jp.
|
|
|
|
For vnode_pager_haspage() references. The value should be obtained
|
|
|
|
from underlying UFS. */
|
|
|
|
/* Checked UFS. iosize is set as 8192 */
|
|
|
|
vfsp->mnt_stat.f_iosize = 8192;
|
|
|
|
|
|
|
|
/* error is currently guaranteed to be zero, but in case some
|
|
|
|
code changes... */
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(1,
|
|
|
|
myprintf(("coda_mount returned %d\n",error)););
|
1998-08-29 21:14:52 +00:00
|
|
|
if (error)
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_MOUNT_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
else
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_SAT(CODA_MOUNT_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_unmount(vfsp, mntflags, p)
|
1998-08-29 21:14:52 +00:00
|
|
|
struct mount *vfsp;
|
|
|
|
int mntflags;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1998-09-11 18:50:17 +00:00
|
|
|
struct coda_mntinfo *mi = vftomi(vfsp);
|
1998-08-29 21:14:52 +00:00
|
|
|
int active, error = 0;
|
|
|
|
|
|
|
|
ENTRY;
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_UMOUNT_STATS);
|
|
|
|
if (!CODA_MOUNTED(vfsp)) {
|
|
|
|
MARK_INT_FAIL(CODA_UMOUNT_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mi->mi_vfsp == vfsp) { /* We found the victim */
|
|
|
|
if (!IS_UNMOUNTING(VTOC(mi->mi_rootvp)))
|
|
|
|
return (EBUSY); /* Venus is still running */
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_unmount: ROOT: vp %p, cp %p\n", mi->mi_rootvp, VTOC(mi->mi_rootvp));
|
1998-08-29 21:14:52 +00:00
|
|
|
#endif
|
|
|
|
vrele(mi->mi_rootvp);
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
active = coda_kill(vfsp, NOT_DOWNCALL);
|
1998-11-16 19:48:26 +00:00
|
|
|
mi->mi_rootvp->v_flag &= ~VROOT;
|
2001-05-16 18:04:37 +00:00
|
|
|
error = vflush(mi->mi_vfsp, 0, FORCECLOSE);
|
1998-09-11 18:50:17 +00:00
|
|
|
printf("coda_unmount: active = %d, vflush active %d\n", active, error);
|
1998-08-29 21:14:52 +00:00
|
|
|
error = 0;
|
|
|
|
/* I'm going to take this out to allow lookups to go through. I'm
|
|
|
|
* not sure it's important anyway. -- DCS 2/2/94
|
|
|
|
*/
|
|
|
|
/* vfsp->VFS_DATA = NULL; */
|
|
|
|
|
|
|
|
/* No more vfsp's to hold onto */
|
|
|
|
mi->mi_vfsp = NULL;
|
|
|
|
mi->mi_rootvp = NULL;
|
|
|
|
|
|
|
|
if (error)
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_UMOUNT_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
else
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_SAT(CODA_UMOUNT_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* find root of cfs
|
|
|
|
*/
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_root(vfsp, vpp)
|
1998-08-29 21:14:52 +00:00
|
|
|
struct mount *vfsp;
|
|
|
|
struct vnode **vpp;
|
|
|
|
{
|
1998-09-11 18:50:17 +00:00
|
|
|
struct coda_mntinfo *mi = vftomi(vfsp);
|
1998-08-29 21:14:52 +00:00
|
|
|
struct vnode **result;
|
|
|
|
int error;
|
|
|
|
struct proc *p = curproc; /* XXX - bnoble */
|
|
|
|
ViceFid VFid;
|
|
|
|
|
|
|
|
ENTRY;
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_ROOT_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
result = NULL;
|
|
|
|
|
|
|
|
if (vfsp == mi->mi_vfsp) {
|
|
|
|
if ((VTOC(mi->mi_rootvp)->c_fid.Volume != 0) ||
|
|
|
|
(VTOC(mi->mi_rootvp)->c_fid.Vnode != 0) ||
|
|
|
|
(VTOC(mi->mi_rootvp)->c_fid.Unique != 0))
|
|
|
|
{ /* Found valid root. */
|
|
|
|
*vpp = mi->mi_rootvp;
|
|
|
|
/* On Mach, this is vref. On NetBSD, VOP_LOCK */
|
1998-09-02 19:09:53 +00:00
|
|
|
#if 1
|
1998-08-29 21:14:52 +00:00
|
|
|
vref(*vpp);
|
1998-09-02 19:09:53 +00:00
|
|
|
vn_lock(*vpp, LK_EXCLUSIVE, p);
|
|
|
|
#else
|
|
|
|
vget(*vpp, LK_EXCLUSIVE, p);
|
|
|
|
#endif
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_SAT(CODA_ROOT_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-27 00:01:31 +00:00
|
|
|
error = venus_root(vftomi(vfsp), p->p_ucred, p, &VFid);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
if (!error) {
|
|
|
|
/*
|
|
|
|
* Save the new rootfid in the cnode, and rehash the cnode into the
|
|
|
|
* cnode hash with the new fid key.
|
|
|
|
*/
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_unsave(VTOC(mi->mi_rootvp));
|
1998-08-29 21:14:52 +00:00
|
|
|
VTOC(mi->mi_rootvp)->c_fid = VFid;
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_save(VTOC(mi->mi_rootvp));
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
*vpp = mi->mi_rootvp;
|
1998-09-02 19:09:53 +00:00
|
|
|
#if 1
|
1998-08-29 21:14:52 +00:00
|
|
|
vref(*vpp);
|
1998-09-02 19:09:53 +00:00
|
|
|
vn_lock(*vpp, LK_EXCLUSIVE, p);
|
|
|
|
#else
|
|
|
|
vget(*vpp, LK_EXCLUSIVE, p);
|
|
|
|
#endif
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_SAT(CODA_ROOT_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
goto exit;
|
1998-11-16 19:48:26 +00:00
|
|
|
} else if (error == ENODEV || error == EINTR) {
|
1998-08-29 21:14:52 +00:00
|
|
|
/* Gross hack here! */
|
|
|
|
/*
|
1998-09-11 18:50:17 +00:00
|
|
|
* If Venus fails to respond to the CODA_ROOT call, coda_call returns
|
1998-08-29 21:14:52 +00:00
|
|
|
* ENODEV. Return the uninitialized root vnode to allow vfs
|
|
|
|
* operations such as unmount to continue. Without this hack,
|
|
|
|
* there is no way to do an unmount if Venus dies before a
|
1998-09-11 18:50:17 +00:00
|
|
|
* successful CODA_ROOT call is done. All vnode operations
|
1998-08-29 21:14:52 +00:00
|
|
|
* will fail.
|
|
|
|
*/
|
|
|
|
*vpp = mi->mi_rootvp;
|
1998-09-02 19:09:53 +00:00
|
|
|
#if 1
|
1998-08-29 21:14:52 +00:00
|
|
|
vref(*vpp);
|
1998-09-02 19:09:53 +00:00
|
|
|
vn_lock(*vpp, LK_EXCLUSIVE, p);
|
|
|
|
#else
|
|
|
|
vget(*vpp, LK_EXCLUSIVE, p);
|
|
|
|
#endif
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_INT_FAIL(CODA_ROOT_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
error = 0;
|
|
|
|
goto exit;
|
|
|
|
} else {
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG( CODA_ROOT, myprintf(("error %d in CODA_ROOT\n", error)); );
|
|
|
|
MARK_INT_FAIL(CODA_ROOT_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
goto exit;
|
|
|
|
}
|
1998-09-02 19:09:53 +00:00
|
|
|
|
1998-08-29 21:14:52 +00:00
|
|
|
exit:
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get file system statistics.
|
|
|
|
*/
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_nb_statfs(vfsp, sbp, p)
|
1998-08-29 21:14:52 +00:00
|
|
|
register struct mount *vfsp;
|
|
|
|
struct statfs *sbp;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
ENTRY;
|
1998-09-11 18:50:17 +00:00
|
|
|
/* MARK_ENTRY(CODA_STATFS_STATS); */
|
|
|
|
if (!CODA_MOUNTED(vfsp)) {
|
|
|
|
/* MARK_INT_FAIL(CODA_STATFS_STATS);*/
|
1998-08-29 21:14:52 +00:00
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
bzero(sbp, sizeof(struct statfs));
|
|
|
|
/* XXX - what to do about f_flags, others? --bnoble */
|
|
|
|
/* Below This is what AFS does
|
|
|
|
#define NB_SFS_SIZ 0x895440
|
|
|
|
*/
|
|
|
|
/* Note: Normal fs's have a bsize of 0x400 == 1024 */
|
1998-09-07 13:17:06 +00:00
|
|
|
sbp->f_type = vfsp->mnt_vfc->vfc_typenum;
|
1998-08-29 21:14:52 +00:00
|
|
|
sbp->f_bsize = 8192; /* XXX */
|
|
|
|
sbp->f_iosize = 8192; /* XXX */
|
|
|
|
#define NB_SFS_SIZ 0x8AB75D
|
|
|
|
sbp->f_blocks = NB_SFS_SIZ;
|
|
|
|
sbp->f_bfree = NB_SFS_SIZ;
|
|
|
|
sbp->f_bavail = NB_SFS_SIZ;
|
|
|
|
sbp->f_files = NB_SFS_SIZ;
|
|
|
|
sbp->f_ffree = NB_SFS_SIZ;
|
|
|
|
bcopy((caddr_t)&(vfsp->mnt_stat.f_fsid), (caddr_t)&(sbp->f_fsid), sizeof (fsid_t));
|
1998-12-04 22:54:57 +00:00
|
|
|
snprintf(sbp->f_mntonname, sizeof(sbp->f_mntonname), "/coda");
|
|
|
|
snprintf(sbp->f_mntfromname, sizeof(sbp->f_mntfromname), "CODA");
|
1998-09-11 18:50:17 +00:00
|
|
|
/* MARK_INT_SAT(CODA_STATFS_STATS); */
|
1998-08-29 21:14:52 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Flush any pending I/O.
|
|
|
|
*/
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_sync(vfsp, waitfor, cred, p)
|
1998-08-29 21:14:52 +00:00
|
|
|
struct mount *vfsp;
|
|
|
|
int waitfor;
|
|
|
|
struct ucred *cred;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
ENTRY;
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_SYNC_STATS);
|
|
|
|
MARK_INT_SAT(CODA_SYNC_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* fhtovp is now what vget used to be in 4.3-derived systems. For
|
|
|
|
* some silly reason, vget is now keyed by a 32 bit ino_t, rather than
|
|
|
|
* a type-specific fid.
|
|
|
|
*/
|
|
|
|
int
|
1998-09-11 18:50:17 +00:00
|
|
|
coda_fhtovp(vfsp, fhp, nam, vpp, exflagsp, creadanonp)
|
1998-08-29 21:14:52 +00:00
|
|
|
register struct mount *vfsp;
|
|
|
|
struct fid *fhp;
|
|
|
|
struct mbuf *nam;
|
|
|
|
struct vnode **vpp;
|
|
|
|
int *exflagsp;
|
|
|
|
struct ucred **creadanonp;
|
|
|
|
{
|
|
|
|
struct cfid *cfid = (struct cfid *)fhp;
|
|
|
|
struct cnode *cp = 0;
|
|
|
|
int error;
|
|
|
|
struct proc *p = curproc; /* XXX -mach */
|
|
|
|
ViceFid VFid;
|
|
|
|
int vtype;
|
|
|
|
|
|
|
|
ENTRY;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MARK_ENTRY(CODA_VGET_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
/* Check for vget of control object. */
|
|
|
|
if (IS_CTL_FID(&cfid->cfid_fid)) {
|
1998-09-11 18:50:17 +00:00
|
|
|
*vpp = coda_ctlvp;
|
|
|
|
vref(coda_ctlvp);
|
|
|
|
MARK_INT_SAT(CODA_VGET_STATS);
|
1998-08-29 21:14:52 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2001-01-27 00:01:31 +00:00
|
|
|
error = venus_fhtovp(vftomi(vfsp), &cfid->cfid_fid, p->p_ucred, p, &VFid, &vtype);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
if (error) {
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_VGET, myprintf(("vget error %d\n",error));)
|
1998-08-29 21:14:52 +00:00
|
|
|
*vpp = (struct vnode *)0;
|
|
|
|
} else {
|
1998-09-11 18:50:17 +00:00
|
|
|
CODADEBUG(CODA_VGET,
|
1998-08-29 21:14:52 +00:00
|
|
|
myprintf(("vget: vol %lx vno %lx uni %lx type %d result %d\n",
|
|
|
|
VFid.Volume, VFid.Vnode, VFid.Unique, vtype, error)); )
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
cp = make_coda_node(&VFid, vfsp, vtype);
|
1998-08-29 21:14:52 +00:00
|
|
|
*vpp = CTOV(cp);
|
|
|
|
}
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* To allow for greater ease of use, some vnodes may be orphaned when
|
|
|
|
* Venus dies. Certain operations should still be allowed to go
|
|
|
|
* through, but without propagating ophan-ness. So this function will
|
|
|
|
* get a new vnode for the file from the current run of Venus. */
|
|
|
|
|
|
|
|
int
|
|
|
|
getNewVnode(vpp)
|
|
|
|
struct vnode **vpp;
|
|
|
|
{
|
|
|
|
struct cfid cfid;
|
1998-09-11 18:50:17 +00:00
|
|
|
struct coda_mntinfo *mi = vftomi((*vpp)->v_mount);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
ENTRY;
|
|
|
|
|
|
|
|
cfid.cfid_len = (short)sizeof(ViceFid);
|
|
|
|
cfid.cfid_fid = VTOC(*vpp)->c_fid; /* Structure assignment. */
|
|
|
|
/* XXX ? */
|
|
|
|
|
|
|
|
/* We're guessing that if set, the 1st element on the list is a
|
|
|
|
* valid vnode to use. If not, return ENODEV as venus is dead.
|
|
|
|
*/
|
|
|
|
if (mi->mi_vfsp == NULL)
|
|
|
|
return ENODEV;
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
return coda_fhtovp(mi->mi_vfsp, (struct fid*)&cfid, NULL, vpp,
|
1998-08-29 21:14:52 +00:00
|
|
|
NULL, NULL);
|
|
|
|
}
|
|
|
|
|
Introduce extended attribute support for FFS, allowing arbitrary
(name, value) pairs to be associated with inodes. This support is
used for ACLs, MAC labels, and Capabilities in the TrustedBSD
security extensions, which are currently under development.
In this implementation, attributes are backed to data vnodes in the
style of the quota support in FFS. Support for FFS extended
attributes may be enabled using the FFS_EXTATTR kernel option
(disabled by default). Userland utilities and man pages will be
committed in the next batch. VFS interfaces and man pages have
been in the repo since 4.0-RELEASE and are unchanged.
o ufs/ufs/extattr.h: UFS-specific extattr defines
o ufs/ufs/ufs_extattr.c: bulk of support routines
o ufs/{ufs,ffs,mfs}/*.[ch]: hooks and extattr.h includes
o contrib/softupdates/ffs_softdep.c: extattr.h includes
o conf/options, conf/files, i386/conf/LINT: added FFS_EXTATTR
o coda/coda_vfsops.c: XXX required extattr.h due to ufsmount.h
(This should not be the case, and will be fixed in a future commit)
Currently attributes are not supported in MFS. This will be fixed.
Reviewed by: adrian, bp, freebsd-fs, other unthanked souls
Obtained from: TrustedBSD Project
2000-04-15 03:34:27 +00:00
|
|
|
#include <ufs/ufs/extattr.h>
|
1998-08-29 21:14:52 +00:00
|
|
|
#include <ufs/ufs/quota.h>
|
|
|
|
#include <ufs/ufs/ufsmount.h>
|
|
|
|
/* get the mount structure corresponding to a given device. Assume
|
|
|
|
* device corresponds to a UFS. Return NULL if no device is found.
|
|
|
|
*/
|
|
|
|
struct mount *devtomp(dev)
|
|
|
|
dev_t dev;
|
|
|
|
{
|
1999-11-20 10:00:46 +00:00
|
|
|
struct mount *mp;
|
|
|
|
|
|
|
|
TAILQ_FOREACH(mp, &mountlist, mnt_list) {
|
1999-05-09 13:11:37 +00:00
|
|
|
if (((VFSTOUFS(mp))->um_dev == dev)) {
|
1998-08-29 21:14:52 +00:00
|
|
|
/* mount corresponds to UFS and the device matches one we want */
|
|
|
|
return(mp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* mount structure wasn't found */
|
|
|
|
return(NULL);
|
|
|
|
}
|
1998-09-25 17:38:32 +00:00
|
|
|
|
|
|
|
struct vfsops coda_vfsops = {
|
|
|
|
coda_mount,
|
1999-09-07 22:42:38 +00:00
|
|
|
vfs_stdstart,
|
1998-09-25 17:38:32 +00:00
|
|
|
coda_unmount,
|
|
|
|
coda_root,
|
1999-09-07 22:42:38 +00:00
|
|
|
vfs_stdquotactl,
|
1998-09-25 17:38:32 +00:00
|
|
|
coda_nb_statfs,
|
|
|
|
coda_sync,
|
1999-09-07 22:42:38 +00:00
|
|
|
vfs_stdvget,
|
|
|
|
vfs_stdfhtovp,
|
1999-09-11 00:46:08 +00:00
|
|
|
vfs_stdcheckexp,
|
1999-09-07 22:42:38 +00:00
|
|
|
vfs_stdvptofh,
|
1999-12-19 06:08:07 +00:00
|
|
|
vfs_stdinit,
|
|
|
|
vfs_stduninit,
|
|
|
|
vfs_stdextattrctl,
|
1998-09-25 17:38:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
VFS_SET(coda_vfsops, coda, VFCF_NETWORK);
|