From 8c780c8d9a2997c3bb4f2f77173b0af33cefeb75 Mon Sep 17 00:00:00 2001 From: shafeeq Date: Tue, 5 Jun 2001 19:45:16 +0000 Subject: Now works again and as a module and with devfs. Used the bpf & tun drivers as examples as to what is necessary for devfs. --- sys/fs/coda/cnode.h | 1 + sys/fs/coda/coda_fbsd.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++- sys/fs/coda/coda_vnops.c | 29 +++++++++++++++++++-------- 3 files changed, 73 insertions(+), 9 deletions(-) (limited to 'sys/fs') diff --git a/sys/fs/coda/cnode.h b/sys/fs/coda/cnode.h index 75d29ac..c1f8391 100644 --- a/sys/fs/coda/cnode.h +++ b/sys/fs/coda/cnode.h @@ -153,6 +153,7 @@ struct coda_mntinfo { struct vnode *mi_rootvp; struct mount *mi_vfsp; struct vcomm mi_vcomm; + dev_t dev; }; extern struct coda_mntinfo coda_mnttbl[]; /* indexed by minor device number */ diff --git a/sys/fs/coda/coda_fbsd.c b/sys/fs/coda/coda_fbsd.c index 629ead4..438260c 100644 --- a/sys/fs/coda/coda_fbsd.c +++ b/sys/fs/coda/coda_fbsd.c @@ -90,7 +90,6 @@ codadev_modevent(module_t mod, int type, void *data) switch (type) { case MOD_LOAD: - cdevsw_add(&codadevsw); break; case MOD_UNLOAD: break; @@ -173,3 +172,54 @@ printf("error = %d\n", error); } #endif } + + +/* for DEVFS, using bpf & tun drivers as examples*/ +static void coda_fbsd_drvinit __P((void *unused)); +static void coda_fbsd_drvuninit __P((void *unused)); +static void coda_fbsd_clone __P((void *arg, char *name, int namelen, dev_t *dev)); + +static void coda_fbsd_clone(arg, name, namelen, dev) + void *arg; + char *name; + int namelen; + dev_t *dev; +{ + int u; + + if (*dev != NODEV) + return; + if (dev_stdclone(name,NULL,"cfs",&u) != 1) + return; + + *dev = make_dev(&codadevsw,unit2minor(u),UID_ROOT,GID_WHEEL,0600,"cfs%d",u); + coda_mnttbl[unit2minor(u)].dev = *dev; + +} + +static void coda_fbsd_drvinit(unused) + void *unused; +{ + int i; + + EVENTHANDLER_REGISTER(dev_clone,coda_fbsd_clone,0,1000); + cdevsw_add(&codadevsw); + for(i=0;ic_ovp; + struct proc *lp = p; int igot_internally = 0; int opened_internally = 0; int error = 0; + int iscore = 0; MARK_ENTRY(CODA_RDWR_STATS); @@ -432,9 +439,15 @@ coda_rdwr(vp, uiop, rw, ioflag, cred, p) * venus won't have the correct size of the core when * it's completely written. */ - PROC_LOCK(p); - if (cp->c_inode != 0 && !(p && (p->p_acflag & ACORE))) { + if (p) { + PROC_LOCK(p); + iscore = (p->p_acflag & ACORE); PROC_UNLOCK(p); + } + else + lp = curproc; + + if (cp->c_inode != 0 && !iscore) { igot_internally = 1; error = coda_grab_vnode(cp->c_device, cp->c_inode, &cfvp); if (error) { @@ -442,13 +455,12 @@ coda_rdwr(vp, uiop, rw, ioflag, cred, p) return(error); } /* - * We get the vnode back locked in both Mach and + * We get the vnode back locked by curproc in both Mach and * NetBSD. Needs unlocked */ - VOP_UNLOCK(cfvp, 0, p); + VOP_UNLOCK(cfvp, 0, lp); } else { - PROC_UNLOCK(p); opened_internally = 1; MARK_INT_GEN(CODA_OPEN_STATS); error = VOP_OPEN(vp, (rw == UIO_READ ? FREAD : FWRITE), @@ -478,7 +490,6 @@ printf("coda_rdwr: Internally Opening %p\n", vp); cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique, CTOV(cp)->v_usecount)); ) - if (rw == UIO_READ) { error = VOP_READ(cfvp, uiop, ioflag, cred); } else { @@ -510,6 +521,8 @@ printf("coda_rdwr: Internally Opening %p\n", vp); return(error); } + + int coda_ioctl(v) void *v; -- cgit v1.1