diff options
author | brooks <brooks@FreeBSD.org> | 2004-09-01 01:19:52 +0000 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2004-09-01 01:19:52 +0000 |
commit | eeddbfb0fa1e4bef7bff6ff83926b674f7d9e29c (patch) | |
tree | cc3bec9ba8ac27b526dbb740b61a62d861efbeb0 /sys/coda | |
parent | 77972e1ec2ccf47109756cd13b82696e5a5696b3 (diff) | |
download | FreeBSD-src-eeddbfb0fa1e4bef7bff6ff83926b674f7d9e29c.zip FreeBSD-src-eeddbfb0fa1e4bef7bff6ff83926b674f7d9e29c.tar.gz |
General modernization of coda:
- Ditch NVCODA
- Don't use a static major
- Don't declare functions extern
Reviewed by: peter
Diffstat (limited to 'sys/coda')
-rw-r--r-- | sys/coda/cnode.h | 21 | ||||
-rw-r--r-- | sys/coda/coda_fbsd.c | 81 | ||||
-rw-r--r-- | sys/coda/coda_psdev.c | 35 | ||||
-rw-r--r-- | sys/coda/coda_vfsops.c | 10 |
4 files changed, 54 insertions, 93 deletions
diff --git a/sys/coda/cnode.h b/sys/coda/cnode.h index be7e848..2a9cf0b 100644 --- a/sys/coda/cnode.h +++ b/sys/coda/cnode.h @@ -109,7 +109,7 @@ struct cnode { struct vattr c_vattr; /* attributes */ char *c_symlink; /* pointer to symbolic link */ u_short c_symlen; /* length of symbolic link */ - struct cdev *c_device; /* associated vnode device */ + struct cdev *c_device; /* associated vnode device */ ino_t c_inode; /* associated vnode inode */ struct cnode *c_next; /* links if on NetBSD machine */ }; @@ -153,10 +153,11 @@ struct coda_mntinfo { 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 @@ enum dc_status { }; /* 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 --git a/sys/coda/coda_fbsd.c b/sys/coda/coda_fbsd.c index 8ea9826..1605e7a 100644 --- a/sys/coda/coda_fbsd.c +++ b/sys/coda/coda_fbsd.c @@ -31,8 +31,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "opt_coda.h" - #include <sys/param.h> #include <sys/systm.h> #include <sys/conf.h> @@ -52,20 +50,6 @@ __FBSDID("$FreeBSD$"); #include <coda/coda_vnops.h> #include <coda/coda_psdev.h> -/* - From: "Jordan K. Hubbard" <jkh@time.cdrom.com> - Subject: Re: New 3.0 SNAPshot CDROM about ready for production.. - To: "Robert.V.Baron" <rvb@GLUCK.CODA.CS.CMU.EDU> - 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,21 +60,39 @@ static struct cdevsw codadevsw = { .d_ioctl = vc_nb_ioctl, .d_poll = vc_nb_poll, .d_name = "Coda", - .d_maj = VC_DEV_NO, }; +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: - return (EBUSY); + 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: return (EOPNOTSUPP); } @@ -101,7 +103,7 @@ static moduledata_t codadev_mod = { 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 @@ printf("error = %d\n", error); #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 @@ static void coda_fbsd_clone(arg, name, namelen, dev) struct cdev **dev; { int u; + struct coda_mntinfo *mnt; if (*dev != NULL) return; @@ -192,31 +187,19 @@ static void coda_fbsd_clone(arg, name, namelen, dev) 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;i<NVCODA;i++) - coda_mnttbl[i].dev = NULL; -} - -static void coda_fbsd_drvuninit(unused) - void *unused; -{ - int i; + LIST_FOREACH(mnt, &coda_mnttbl, mi_list) { + if (mnt->dev == dev) + break; + } - EVENTHANDLER_DEREGISTER(dev_clone,clonetag); - for(i=0;i<NVCODA;i++) - if(coda_mnttbl[i].dev) - destroy_dev(coda_mnttbl[i].dev); + return mnt; } - -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); diff --git a/sys/coda/coda_psdev.c b/sys/coda/coda_psdev.c index 35eb725..64db1ee 100644 --- a/sys/coda/coda_psdev.c +++ b/sys/coda/coda_psdev.c @@ -54,8 +54,6 @@ __FBSDID("$FreeBSD$"); extern int coda_nc_initialized; /* Set if cache has been initialized */ -#include "opt_coda.h" - #include <sys/param.h> #include <sys/systm.h> #include <sys/ioccom.h> @@ -122,17 +120,16 @@ vc_nb_open(dev, flag, mode, td) 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 @@ vc_nb_open(dev, flag, mode, td) 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 @@ vc_nb_close (dev, flag, mode, td) 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 @@ vc_nb_read(dev, uiop, flag) 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 @@ vc_nb_write(dev, uiop, flag) 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 @@ vc_nb_poll(dev, events, td) 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 --git a/sys/coda/coda_vfsops.c b/sys/coda/coda_vfsops.c index 04e739c..4096a3f 100644 --- a/sys/coda/coda_vfsops.c +++ b/sys/coda/coda_vfsops.c @@ -43,8 +43,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "opt_coda.h" - #include <sys/param.h> #include <sys/systm.h> #include <sys/conf.h> @@ -69,7 +67,6 @@ int coda_vfsop_print_entry = 0; #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 */ @@ -161,15 +158,10 @@ coda_omount(vfsp, path, data, td) 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); |