diff -ru freebsd/sys/coda/cnode.h cleanup/sys/coda/cnode.h --- freebsd/sys/coda/cnode.h Tue Jul 13 14:06:57 2004 +++ cleanup/sys/coda/cnode.h Tue Jul 13 12:26:02 2004 @@ -153,10 +153,11 @@ struct vnode *mi_rootvp; struct mount *mi_vfsp; struct vcomm mi_vcomm; - struct cdev *dev; + struct cdev *dev; int mi_started; + LIST_ENTRY(coda_mntinfo) mi_list; }; -extern struct coda_mntinfo coda_mnttbl[]; /* indexed by minor device number */ +struct coda_mntinfo *dev2coda_mntinfo(struct cdev *dev); /* * vfs pointer to mount info @@ -188,20 +189,20 @@ }; /* cfs_psdev.h */ -extern int coda_call(struct coda_mntinfo *mntinfo, int inSize, int *outSize, caddr_t buffer); +int coda_call(struct coda_mntinfo *mntinfo, int inSize, int *outSize, caddr_t buffer); extern int coda_kernel_version; /* cfs_subr.h */ -extern int handleDownCall(int opcode, union outputArgs *out); -extern void coda_unmounting(struct mount *whoIam); -extern int coda_vmflush(struct cnode *cp); +int handleDownCall(int opcode, union outputArgs *out); +void coda_unmounting(struct mount *whoIam); +int coda_vmflush(struct cnode *cp); /* cfs_vnodeops.h */ -extern struct cnode *make_coda_node(CodaFid *fid, struct mount *vfsp, short type); -extern int coda_vnodeopstats_init(void); +struct cnode *make_coda_node(CodaFid *fid, struct mount *vfsp, short type); +int coda_vnodeopstats_init(void); /* coda_vfsops.h */ -extern struct mount *devtomp(struct cdev *dev); +struct mount *devtomp(struct cdev *dev); /* sigh */ #define CODA_RDWR ((u_long) 31) diff -ru freebsd/sys/coda/coda_fbsd.c cleanup/sys/coda/coda_fbsd.c --- freebsd/sys/coda/coda_fbsd.c Tue Jul 13 14:06:57 2004 +++ cleanup/sys/coda/coda_fbsd.c Tue Jul 13 12:26:02 2004 @@ -31,8 +31,6 @@ #include __FBSDID("$FreeBSD: src/sys/coda/coda_fbsd.c,v 1.35 2004/06/17 17:16:40 phk Exp $"); -#include "vcoda.h" - #include #include #include @@ -52,20 +50,6 @@ #include #include -/* - From: "Jordan K. Hubbard" - Subject: Re: New 3.0 SNAPshot CDROM about ready for production.. - To: "Robert.V.Baron" - Date: Fri, 20 Feb 1998 15:57:01 -0800 - - > Also I need a character device major number. (and might want to reserve - > a block of 10 syscalls.) - - Just one char device number? No block devices? Very well, cdev 93 is yours! -*/ - -#define VC_DEV_NO 93 - static struct cdevsw codadevsw = { .d_version = D_VERSION, .d_flags = D_NEEDGIANT, @@ -76,20 +60,38 @@ .d_ioctl = vc_nb_ioctl, .d_poll = vc_nb_poll, .d_name = "Coda", - .d_maj = VC_DEV_NO, + .d_maj = 93, }; +static eventhandler_tag clonetag; + +static LIST_HEAD(, coda_mntinfo) coda_mnttbl; + int vcdebug = 1; #define VCDEBUG if (vcdebug) printf +/* for DEVFS, using bpf & tun drivers as examples*/ +static void coda_fbsd_clone(void *arg, char *name, int namelen, + struct cdev **dev); + static int codadev_modevent(module_t mod, int type, void *data) { + struct coda_mntinfo *mnt; switch (type) { case MOD_LOAD: + LIST_INIT(&coda_mnttbl); + clonetag = EVENTHANDLER_REGISTER(dev_clone, coda_fbsd_clone, + 0, 1000); break; case MOD_UNLOAD: + EVENTHANDLER_DEREGISTER(dev_clone, clonetag); + while ((mnt = LIST_FIRST(&coda_mnttbl)) != NULL) { + LIST_REMOVE(mnt, mi_list); + destroy_dev(mnt->dev); + free(mnt, M_CODA); + } break; default: break; @@ -101,7 +103,7 @@ codadev_modevent, NULL }; -DECLARE_MODULE(codadev, codadev_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+VC_DEV_NO); +DECLARE_MODULE(codadev, codadev_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE); int coda_fbsd_getpages(v) @@ -170,14 +172,6 @@ #endif } - -/* for DEVFS, using bpf & tun drivers as examples*/ -static void coda_fbsd_drvinit(void *unused); -static void coda_fbsd_drvuninit(void *unused); -static void coda_fbsd_clone(void *arg, char *name, int namelen, struct cdev **dev); - -static eventhandler_tag clonetag; - static void coda_fbsd_clone(arg, name, namelen, dev) void *arg; char *name; @@ -185,6 +179,7 @@ struct cdev **dev; { int u; + struct coda_mntinfo *mnt; if (*dev != NULL) return; @@ -192,31 +187,19 @@ return; *dev = make_dev(&codadevsw,unit2minor(u),UID_ROOT,GID_WHEEL,0600,"cfs%d",u); - coda_mnttbl[unit2minor(u)].dev = *dev; - + mnt = malloc(sizeof(struct coda_mntinfo), M_CODA, M_WAITOK|M_ZERO); + LIST_INSERT_HEAD(&coda_mnttbl, mnt, mi_list); } -static void coda_fbsd_drvinit(unused) - void *unused; +struct coda_mntinfo * +dev2coda_mntinfo(struct cdev *dev) { - int i; + struct coda_mntinfo *mnt; - clonetag = EVENTHANDLER_REGISTER(dev_clone,coda_fbsd_clone,0,1000); - for(i=0;idev == dev) + break; + } - EVENTHANDLER_DEREGISTER(dev_clone,clonetag); - for(i=0;i - #include #include #include @@ -122,17 +120,16 @@ int mode; struct thread *td; /* NetBSD only */ { - register struct vcomm *vcp; + struct vcomm *vcp; + struct coda_mntinfo *mnt; ENTRY; - if (minor(dev) >= NVCODA || minor(dev) < 0) - return(ENXIO); - if (!coda_nc_initialized) coda_nc_init(); - vcp = &coda_mnttbl[minor(dev)].mi_vcomm; + mnt = dev2coda_mntinfo(dev); + vcp = &mnt->mi_vcomm; if (VC_OPEN(vcp)) return(EBUSY); @@ -141,8 +138,8 @@ INIT_QUEUE(vcp->vc_replys); MARK_VC_OPEN(vcp); - coda_mnttbl[minor(dev)].mi_vfsp = NULL; - coda_mnttbl[minor(dev)].mi_rootvp = NULL; + mnt->mi_vfsp = NULL; + mnt->mi_rootvp = NULL; return(0); } @@ -161,10 +158,7 @@ ENTRY; - if (minor(dev) >= NVCODA || minor(dev) < 0) - return(ENXIO); - - mi = &coda_mnttbl[minor(dev)]; + mi = dev2coda_mntinfo(dev); vcp = &(mi->mi_vcomm); if (!VC_OPEN(vcp)) @@ -243,10 +237,7 @@ ENTRY; - if (minor(dev) >= NVCODA || minor(dev) < 0) - return(ENXIO); - - vcp = &coda_mnttbl[minor(dev)].mi_vcomm; + vcp = &dev2coda_mntinfo(dev)->mi_vcomm; /* Get message at head of request queue. */ if (EMPTY(vcp->vc_requests)) return(0); /* Nothing to read */ @@ -301,10 +292,7 @@ ENTRY; - if (minor(dev) >= NVCODA || minor(dev) < 0) - return(ENXIO); - - vcp = &coda_mnttbl[minor(dev)].mi_vcomm; + vcp = &dev2coda_mntinfo(dev)->mi_vcomm; /* Peek at the opcode, unique without transfering the data. */ uiop->uio_rw = UIO_WRITE; @@ -450,10 +438,7 @@ ENTRY; - if (minor(dev) >= NVCODA || minor(dev) < 0) - return(ENXIO); - - vcp = &coda_mnttbl[minor(dev)].mi_vcomm; + vcp = &dev2coda_mntinfo(dev)->mi_vcomm; event_msk = events & (POLLIN|POLLRDNORM); if (!event_msk) diff -ru freebsd/sys/coda/coda_vfsops.c cleanup/sys/coda/coda_vfsops.c --- freebsd/sys/coda/coda_vfsops.c Tue Jul 13 14:06:57 2004 +++ cleanup/sys/coda/coda_vfsops.c Tue Jul 13 12:26:04 2004 @@ -43,8 +43,6 @@ #include __FBSDID("$FreeBSD: src/sys/coda/coda_vfsops.c,v 1.50 2004/07/12 14:11:26 rwatson Exp $"); -#include - #include #include #include @@ -69,7 +67,6 @@ #define ENTRY if(coda_vfsop_print_entry) myprintf(("Entered %s\n",__func__)) struct vnode *coda_ctlvp; -struct coda_mntinfo coda_mnttbl[NVCODA]; /* indexed by minor device number */ /* structure to keep statistics of internally generated/satisfied calls */ @@ -160,15 +157,10 @@ return(ENXIO); } - if (minor(dev) >= NVCODA || minor(dev) < 0) { - MARK_INT_FAIL(CODA_MOUNT_STATS); - return(ENXIO); - } - /* * Initialize the mount record and link it to the vfs struct */ - mi = &coda_mnttbl[minor(dev)]; + mi = dev2coda_mntinfo(dev); if (!VC_OPEN(&mi->mi_vcomm)) { MARK_INT_FAIL(CODA_MOUNT_STATS);