diff --git a/sys/i386/isa/wcd.c b/sys/i386/isa/wcd.c index 7f1948a2cebe..d7f6670d316f 100644 --- a/sys/i386/isa/wcd.c +++ b/sys/i386/isa/wcd.c @@ -13,7 +13,7 @@ * all derivative works or modified versions. * * From: Version 1.9, Mon Oct 9 20:27:42 MSK 1995 - * $Id: wcd.c,v 1.53 1998/06/07 17:11:04 dfr Exp $ + * $Id: wcd.c,v 1.54 1998/06/08 08:50:43 bde Exp $ */ #include "wdc.h" @@ -32,32 +32,25 @@ #include #include #include +#include #ifdef DEVFS #include #endif /*DEVFS*/ #include -static d_open_t wcdropen; -static d_open_t wcdbopen; -static d_close_t wcdrclose; -static d_close_t wcdbclose; +static d_open_t wcdopen; +static d_close_t wcdclose; static d_ioctl_t wcdioctl; static d_strategy_t wcdstrategy; #define CDEV_MAJOR 69 #define BDEV_MAJOR 19 -extern struct cdevsw wcd_cdevsw; +static struct cdevsw wcd_cdevsw; static struct bdevsw wcd_bdevsw = - { wcdbopen, wcdbclose, wcdstrategy, wcdioctl, /*19*/ + { wcdopen, wcdclose, wcdstrategy, wcdioctl, /*19*/ nodump, nopsize, 0, "wcd", &wcd_cdevsw, -1 }; -static struct cdevsw wcd_cdevsw = - { wcdropen, wcdrclose, rawread, nowrite, /*69*/ - wcdioctl, nostop, nullreset, nodevtotty,/* atapi */ - seltrue, nommap, wcdstrategy, "wcd", - &wcd_bdevsw, -1 }; - #ifndef ATAPI_STATIC static #endif @@ -83,10 +76,10 @@ struct toc { /* * Volume size info. */ -static struct volinfo { +struct volinfo { u_long volsize; /* Volume size in blocks */ u_long blksize; /* Block size in bytes */ -} info; +}; /* * Current subchannel status. @@ -279,7 +272,6 @@ static int wcd_request_wait (struct wcd *t, u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, u_char a9, char *addr, int count); static void wcd_describe (struct wcd *t); -static int wcd_open(dev_t dev, int rawflag); static int wcd_setchan (struct wcd *t, u_char c0, u_char c1, u_char c2, u_char c3); static int wcd_eject (struct wcd *t, int closeit); @@ -514,7 +506,7 @@ void wcd_describe (struct wcd *t) } static int -wcd_open (dev_t dev, int rawflag) +wcdopen (dev_t dev, int flags, int fmt, struct proc *p) { int lun = dkunit(dev); struct wcd *t; @@ -534,51 +526,37 @@ wcd_open (dev_t dev, int rawflag) 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); t->flags |= F_LOCKED; } - if (rawflag) + if (fmt == S_IFCHR) ++t->refcnt; else t->flags |= F_BOPEN; return (0); } -int wcdbopen (dev_t dev, int flags, int fmt, struct proc *p) -{ - return wcd_open (dev, 0); -} - -int wcdropen (dev_t dev, int flags, int fmt, struct proc *p) -{ - return wcd_open (dev, 1); -} - /* * Close the device. Only called if we are the LAST * occurence of an open device. */ -int wcdbclose (dev_t dev, int flags, int fmt, struct proc *p) +static int +wcdclose (dev_t dev, int flags, int fmt, struct proc *p) { int lun = dkunit(dev); struct wcd *t = wcdtab[lun]; - /* If we were the last open of the entire device, release it. */ - if (! t->refcnt) - wcd_request_wait (t, ATAPI_PREVENT_ALLOW, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - t->flags &= ~(F_BOPEN|F_LOCKED); - return (0); -} - -int wcdrclose (dev_t dev, int flags, int fmt, struct proc *p) -{ - int lun = dkunit(dev); - struct wcd *t = wcdtab[lun]; - - /* If we were the last open of the entire device, release it. */ - if (! (t->flags & F_BOPEN) && t->refcnt == 1) - wcd_request_wait (t, ATAPI_PREVENT_ALLOW, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - t->flags &= ~F_LOCKED; - --t->refcnt; + if (fmt == S_IFBLK) { + /* If we were the last open of the entire device, release it. */ + if (! t->refcnt) + wcd_request_wait (t, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + t->flags &= ~(F_BOPEN|F_LOCKED); + } else { + /* If we were the last open of the entire device, release it. */ + if (! (t->flags & F_BOPEN) && t->refcnt == 1) + wcd_request_wait (t, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + t->flags &= ~F_LOCKED; + --t->refcnt; + } return (0); } @@ -1381,13 +1359,9 @@ static wcd_devsw_installed = 0; static void wcd_drvinit(void *unused) { - dev_t dev; if( ! wcd_devsw_installed ) { - dev = makedev(CDEV_MAJOR, 0); - cdevsw_add(&dev,&wcd_cdevsw, NULL); - dev = makedev(BDEV_MAJOR, 0); - bdevsw_add(&dev,&wcd_bdevsw, NULL); + bdevsw_add_generic(BDEV_MAJOR, CDEV_MAJOR, &wcd_bdevsw); wcd_devsw_installed = 1; } } diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 912c4c539520..a01c47342229 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: kern_conf.c,v 1.23 1997/11/22 08:35:37 bde Exp $ + * $Id: kern_conf.c,v 1.24 1998/06/07 17:11:32 dfr Exp $ */ #include @@ -161,7 +161,7 @@ int TTYPE##_add(dev_t *descrip, \ return 0; \ } \ -ADDENTRY(bdevsw, nblkdev,bdevsw_ALLOCSTART) +static ADDENTRY(bdevsw, nblkdev,bdevsw_ALLOCSTART) ADDENTRY(cdevsw, nchrdev,cdevsw_ALLOCSTART) /* @@ -191,6 +191,11 @@ cdevsw_make(struct bdevsw *from) to->d_name = from->d_name; to->d_bdev = from; to->d_maj = -1; + to->d_bmaj = from->d_maj; + to->d_maxio = from->d_maxio; + to->d_dump = from->d_dump; + to->d_psize = from->d_psize; + to->d_flags = from->d_flags; } void diff --git a/sys/kern/kern_lkm.c b/sys/kern/kern_lkm.c index e384fd97aefb..e27410f1ff41 100644 --- a/sys/kern/kern_lkm.c +++ b/sys/kern/kern_lkm.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: kern_lkm.c,v 1.48 1998/02/12 18:02:07 eivind Exp $ + * $Id: kern_lkm.c,v 1.49 1998/06/07 17:11:34 dfr Exp $ */ #include "opt_devfs.h" @@ -701,18 +701,6 @@ _lkm_dev(lkmtp, cmd) if (lkmexists(lkmtp)) return(EEXIST); switch(args->lkm_devtype) { - case LM_DT_BLOCK: - if ((i = args->lkm_offset) == LKM_ANON) - descrip = (dev_t) -1; - else - descrip = makedev(args->lkm_offset,0); - if ( err = bdevsw_add(&descrip, args->lkm_dev.bdev, - &(args->lkm_olddev.bdev))) { - break; - } - args->lkm_offset = major(descrip) ; - break; - case LM_DT_CHAR: if ((i = args->lkm_offset) == LKM_ANON) descrip = (dev_t) -1; @@ -737,11 +725,6 @@ _lkm_dev(lkmtp, cmd) descrip = makedev(i,0); switch(args->lkm_devtype) { - case LM_DT_BLOCK: - /* replace current slot contents with old contents */ - bdevsw_add(&descrip, args->lkm_olddev.bdev,NULL); - break; - case LM_DT_CHAR: /* replace current slot contents with old contents */ cdevsw_add(&descrip, args->lkm_olddev.cdev,NULL); diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 43096d391ddd..960cd22b75a2 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)conf.h 8.5 (Berkeley) 1/9/95 - * $Id: conf.h,v 1.40 1998/06/07 17:12:57 dfr Exp $ + * $Id: conf.h,v 1.41 1998/06/17 14:58:04 bde Exp $ */ #ifndef _SYS_CONF_H_ @@ -133,6 +133,11 @@ struct cdevsw { char *d_name; /* see above */ struct bdevsw *d_bdev; int d_maj; + d_dump_t *d_dump; + d_psize_t *d_psize; + u_int d_flags; + int d_maxio; + int d_bmaj; }; #ifdef KERNEL @@ -277,7 +282,6 @@ int bdevsw_module_handler __P((module_t mod, modeventtype_t what, void* arg)); #endif /* _SYS_MODULE_H_ */ -int bdevsw_add __P((dev_t *descrip,struct bdevsw *new,struct bdevsw **old)); int cdevsw_add __P((dev_t *descrip,struct cdevsw *new,struct cdevsw **old)); void bdevsw_add_generic __P((int bdev, int cdev, struct bdevsw *bdevsw)); dev_t chrtoblk __P((dev_t dev)); diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h index 43096d391ddd..960cd22b75a2 100644 --- a/sys/sys/linedisc.h +++ b/sys/sys/linedisc.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)conf.h 8.5 (Berkeley) 1/9/95 - * $Id: conf.h,v 1.40 1998/06/07 17:12:57 dfr Exp $ + * $Id: conf.h,v 1.41 1998/06/17 14:58:04 bde Exp $ */ #ifndef _SYS_CONF_H_ @@ -133,6 +133,11 @@ struct cdevsw { char *d_name; /* see above */ struct bdevsw *d_bdev; int d_maj; + d_dump_t *d_dump; + d_psize_t *d_psize; + u_int d_flags; + int d_maxio; + int d_bmaj; }; #ifdef KERNEL @@ -277,7 +282,6 @@ int bdevsw_module_handler __P((module_t mod, modeventtype_t what, void* arg)); #endif /* _SYS_MODULE_H_ */ -int bdevsw_add __P((dev_t *descrip,struct bdevsw *new,struct bdevsw **old)); int cdevsw_add __P((dev_t *descrip,struct cdevsw *new,struct cdevsw **old)); void bdevsw_add_generic __P((int bdev, int cdev, struct bdevsw *bdevsw)); dev_t chrtoblk __P((dev_t dev)); diff --git a/sys/vm/vm_swap.c b/sys/vm/vm_swap.c index 48e6aa6d8b61..71897974ddc8 100644 --- a/sys/vm/vm_swap.c +++ b/sys/vm/vm_swap.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)vm_swap.c 8.5 (Berkeley) 2/17/94 - * $Id: vm_swap.c,v 1.52 1998/02/19 12:15:06 msmith Exp $ + * $Id: vm_swap.c,v 1.53 1998/02/23 08:22:44 dyson Exp $ */ #include "opt_devfs.h" @@ -72,18 +72,12 @@ static void swstrategy __P((struct buf *)); #define CDEV_MAJOR 4 #define BDEV_MAJOR 26 -extern struct cdevsw sw_cdevsw ; +static struct cdevsw sw_cdevsw; static struct bdevsw sw_bdevsw = { noopen, noclose, swstrategy, noioc, /*1*/ nodump, nopsize, 0, "sw", &sw_cdevsw, -1 }; -static struct cdevsw sw_cdevsw = - { nullopen, nullclose, rawread, rawwrite, /*4*/ - noioc, nostop, noreset, nodevtotty,/* swap */ - seltrue, nommap, swstrategy, "sw", - &sw_bdevsw, -1 }; - static dev_t swapdev = makedev(BDEV_MAJOR, 0); /* @@ -312,13 +306,15 @@ static void *drum_devfs_token; static void sw_drvinit(void *unused) { - dev_t dev; if( ! sw_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&sw_cdevsw,NULL); - dev = makedev(BDEV_MAJOR,0); - bdevsw_add(&dev,&sw_bdevsw,NULL); + bdevsw_add_generic(BDEV_MAJOR, CDEV_MAJOR, &sw_bdevsw); + /* + * XXX: This is pretty gross, but it will disappear with + * the blockdevices RSN. + */ + sw_cdevsw.d_open = nullopen; + sw_cdevsw.d_close = nullclose; sw_devsw_installed = 1; #ifdef DEVFS drum_devfs_token = devfs_add_devswf(&sw_cdevsw, 0, DV_CHR,