Now works again and as a module and with devfs.

Used the bpf & tun drivers as examples as to what is necessary for devfs.
This commit is contained in:
Shafeeq Sinnamohideen 2001-06-05 19:45:16 +00:00
parent 4a70e151df
commit ba8aae1baf
6 changed files with 146 additions and 18 deletions

View File

@ -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 */

View File

@ -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;i<NVCODA;i++)
coda_mnttbl[i].dev = NULL;
}
static void coda_fbsd_drvuninit(unused)
void *unused;
{
int i;
EVENTHANDLER_DEREGISTER(dev_clone,NULL);
for(i=0;i<NVCODA;i++)
if(coda_mnttbl[i].dev)
destroy_dev(coda_mnttbl[i].dev);
cdevsw_remove(&codadevsw);
}
SYSINIT(coda_fbsd_dev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+VC_DEV_NO,coda_fbsd_drvinit,NULL);
SYSUNINIT(coda_fbsd_dev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+VC_DEV_NO,coda_fbsd_drvuninit,NULL);

View File

@ -142,8 +142,8 @@ struct vnodeopv_entry_desc coda_vnodeop_entries[] = {
{ &vop_advlock_desc, coda_vop_nop }, /* advlock */
{ &vop_lease_desc, coda_vop_nop }, /* lease */
{ &vop_poll_desc, (vop_t *) vop_stdpoll },
{ &vop_getpages_desc, coda_fbsd_getpages }, /* pager intf.*/
{ &vop_putpages_desc, vop_stdputpages }, /* pager intf.*/
{ &vop_getpages_desc, (vop_t*)vop_stdgetpages }, /* pager intf.*/
{ &vop_putpages_desc, (vop_t*)vop_stdputpages }, /* pager intf.*/
#if 0
@ -159,6 +159,11 @@ struct vnodeopv_entry_desc coda_vnodeop_entries[] = {
{ &vop_cachedlookup_desc, (vop_t *) ufs_lookup },
{ &vop_whiteout_desc, (vop_t *) ufs_whiteout },
#endif
{ &vop_createvobject_desc, (vop_t *) vop_stdcreatevobject },
{ &vop_destroyvobject_desc, (vop_t *) vop_stddestroyvobject },
{ &vop_getvobject_desc, (vop_t *) vop_stdgetvobject },
{ &vop_getwritemount_desc, (vop_t *) vop_stdgetwritemount },
{ (struct vnodeop_desc*)NULL, (int(*)(void *))NULL }
};
@ -403,9 +408,11 @@ coda_rdwr(vp, uiop, rw, ioflag, cred, p)
/* locals */
struct cnode *cp = VTOC(vp);
struct vnode *cfvp = cp->c_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;

View File

@ -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 */

View File

@ -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;i<NVCODA;i++)
coda_mnttbl[i].dev = NULL;
}
static void coda_fbsd_drvuninit(unused)
void *unused;
{
int i;
EVENTHANDLER_DEREGISTER(dev_clone,NULL);
for(i=0;i<NVCODA;i++)
if(coda_mnttbl[i].dev)
destroy_dev(coda_mnttbl[i].dev);
cdevsw_remove(&codadevsw);
}
SYSINIT(coda_fbsd_dev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+VC_DEV_NO,coda_fbsd_drvinit,NULL);
SYSUNINIT(coda_fbsd_dev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+VC_DEV_NO,coda_fbsd_drvuninit,NULL);

View File

@ -142,8 +142,8 @@ struct vnodeopv_entry_desc coda_vnodeop_entries[] = {
{ &vop_advlock_desc, coda_vop_nop }, /* advlock */
{ &vop_lease_desc, coda_vop_nop }, /* lease */
{ &vop_poll_desc, (vop_t *) vop_stdpoll },
{ &vop_getpages_desc, coda_fbsd_getpages }, /* pager intf.*/
{ &vop_putpages_desc, vop_stdputpages }, /* pager intf.*/
{ &vop_getpages_desc, (vop_t*)vop_stdgetpages }, /* pager intf.*/
{ &vop_putpages_desc, (vop_t*)vop_stdputpages }, /* pager intf.*/
#if 0
@ -159,6 +159,11 @@ struct vnodeopv_entry_desc coda_vnodeop_entries[] = {
{ &vop_cachedlookup_desc, (vop_t *) ufs_lookup },
{ &vop_whiteout_desc, (vop_t *) ufs_whiteout },
#endif
{ &vop_createvobject_desc, (vop_t *) vop_stdcreatevobject },
{ &vop_destroyvobject_desc, (vop_t *) vop_stddestroyvobject },
{ &vop_getvobject_desc, (vop_t *) vop_stdgetvobject },
{ &vop_getwritemount_desc, (vop_t *) vop_stdgetwritemount },
{ (struct vnodeop_desc*)NULL, (int(*)(void *))NULL }
};
@ -403,9 +408,11 @@ coda_rdwr(vp, uiop, rw, ioflag, cred, p)
/* locals */
struct cnode *cp = VTOC(vp);
struct vnode *cfvp = cp->c_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;