First attempt at creating devfs entries for sliced devices. Doesn't

quite work yet, so the heart of it is disabled.

Added bdev and cdev args to dsopen().

drivers:
Fixed device names, links, minor numbers and modes.

wd.c:
Started actually supporting devfs.

diskslice.h:
Added devfs tokens to structs (currently 576 of them per disk! :-().

subr_diskslice.c:
Create devfs entries in dsopen() and (unsuccessfully) attempt to make
them go away at the right times.  DEVFS is #undefed at the start so
that this shouldn't cause problems.
This commit is contained in:
Bruce Evans 1996-01-27 04:18:15 +00:00
parent dd87702a51
commit c8f2fe8db8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=13647
8 changed files with 119 additions and 59 deletions

View File

@ -43,7 +43,7 @@
* SUCH DAMAGE.
*
* from: @(#)fd.c 7.4 (Berkeley) 5/25/91
* $Id: fd.c,v 1.77 1995/12/10 19:44:45 bde Exp $
* $Id: fd.c,v 1.78 1996/01/27 02:33:35 bde Exp $
*
*/
@ -247,8 +247,8 @@ static struct fd_data {
int options; /* user configurable options, see ioctl_fd.h */
int dkunit; /* disk stats unit number */
#ifdef DEVFS
void *rfd_devfs_token;
void *fd_devfs_token;
void *bdev;
void *cdev;
#endif
} fd_data[NFD];
@ -568,6 +568,7 @@ fdattach(struct isa_device *dev)
struct isa_device *fdup;
int ic_type = 0;
#ifdef DEVFS
int mynor;
char name[64];
#endif /* DEVFS */
@ -765,12 +766,14 @@ fdattach(struct isa_device *dev)
}
kdc_fd[fdu].kdc_state = DC_IDLE;
#ifdef DEVFS
fd->rfd_devfs_token = devfs_add_devsw(
"/",name,&fd_cdevsw, fdu * 8,
DV_CHR,0,0,0644);
fd->fd_devfs_token = devfs_add_devsw(
"/",name+1, &fd_bdevsw, fdu * 8,
DV_BLK,0,0,0644);
mynor = 8 * fdu;
fd->bdev = devfs_add_devsw("/", name + 1, &fd_bdevsw, mynor,
DV_BLK, 0, 0, 0640);
fd->cdev = devfs_add_devsw("/", name, &fd_cdevsw, mynor,
DV_CHR, 0, 0, 0640);
sprintf(name, "rfd%d", fdu);
dev_link("/", name + 1, fd->bdev);
dev_link("/", name, fd->cdev);
#endif /* DEVFS */
if (dk_ndrive < DK_NDRIVE) {
sprintf(dk_names[dk_ndrive], "fd%d", fdu);

View File

@ -133,6 +133,10 @@ int vndebug = 0x00;
struct vn_softc {
int sc_flags; /* flags */
size_t sc_size; /* size of vn */
#if defined(DEVFS) && defined(notyet)
void *sc_bdev; /* devfs token for whole disk */
void *sc_cdev; /* devfs token for raw whole disk */
#endif
struct vnode *sc_vp; /* vnode */
struct ucred *sc_cred; /* credentials */
int sc_maxactive; /* max # of active requests */
@ -206,7 +210,8 @@ vnopen(dev_t dev, int flags, int mode, struct proc *p)
vn->sc_size;
return (dsopen("vn", dev, mode, &vn->sc_slices, &label,
vnstrategy, (ds_setgeom_t *)NULL));
vnstrategy, (ds_setgeom_t *)NULL,
&vn_bdevsw, &vn_cdevsw));
}
if (dkslice(dev) != WHOLE_DISK_SLICE ||
dkpart(dev) != RAW_PART ||
@ -618,6 +623,12 @@ static void
vn_drvinit(void *unused)
{
dev_t dev;
#ifdef DEVFS
int mynor;
char name[32];
int unit;
struct vn_softc *vn;
#endif
if( ! vn_devsw_installed ) {
dev = makedev(CDEV_MAJOR,0);
@ -626,17 +637,21 @@ vn_drvinit(void *unused)
bdevsw_add(&dev,&vn_bdevsw,NULL);
vn_devsw_installed = 1;
#ifdef DEVFS
{
void *x;
/* default for a simple device with no probe routine (usually delete this) */
x=devfs_add_devsw(
/* path name major minor type uid gid perm*/
"/", "rvn", &vn_cdevsw, 0, DV_CHR, 0, 0, 0600);
x=devfs_add_devsw(
"/", "vn", &vn_bdevsw, 0, DV_BLK, 0, 0, 0600);
for (unit = 0; unit < NVN; unit++) {
vn = vn_softc[unit];
mynor = dkmakeminor(unit, WHOLE_DISK_SLICE, RAW_PART);
sprintf(name, "rvn%d", unit);
/*
* XXX not saving tokens yet. The vn devices don't
* exist until after they have been opened :-).
*/
devfs_add_devsw("/", name + 1, &vn_bdevsw, mynor,
DV_BLK, 0, 0, 0640);
devfs_add_devsw("/", name, &vn_cdevsw, mynor,
DV_CHR, 0, 0, 0640);
}
#endif
}
}
}
SYSINIT(vndev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,vn_drvinit,NULL)

View File

@ -43,7 +43,7 @@
* SUCH DAMAGE.
*
* from: @(#)fd.c 7.4 (Berkeley) 5/25/91
* $Id: fd.c,v 1.77 1995/12/10 19:44:45 bde Exp $
* $Id: fd.c,v 1.78 1996/01/27 02:33:35 bde Exp $
*
*/
@ -247,8 +247,8 @@ static struct fd_data {
int options; /* user configurable options, see ioctl_fd.h */
int dkunit; /* disk stats unit number */
#ifdef DEVFS
void *rfd_devfs_token;
void *fd_devfs_token;
void *bdev;
void *cdev;
#endif
} fd_data[NFD];
@ -568,6 +568,7 @@ fdattach(struct isa_device *dev)
struct isa_device *fdup;
int ic_type = 0;
#ifdef DEVFS
int mynor;
char name[64];
#endif /* DEVFS */
@ -765,12 +766,14 @@ fdattach(struct isa_device *dev)
}
kdc_fd[fdu].kdc_state = DC_IDLE;
#ifdef DEVFS
fd->rfd_devfs_token = devfs_add_devsw(
"/",name,&fd_cdevsw, fdu * 8,
DV_CHR,0,0,0644);
fd->fd_devfs_token = devfs_add_devsw(
"/",name+1, &fd_bdevsw, fdu * 8,
DV_BLK,0,0,0644);
mynor = 8 * fdu;
fd->bdev = devfs_add_devsw("/", name + 1, &fd_bdevsw, mynor,
DV_BLK, 0, 0, 0640);
fd->cdev = devfs_add_devsw("/", name, &fd_cdevsw, mynor,
DV_CHR, 0, 0, 0640);
sprintf(name, "rfd%d", fdu);
dev_link("/", name + 1, fd->bdev);
dev_link("/", name, fd->cdev);
#endif /* DEVFS */
if (dk_ndrive < DK_NDRIVE) {
sprintf(dk_names[dk_ndrive], "fd%d", fdu);

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)wd.c 7.2 (Berkeley) 5/9/91
* $Id: wd.c,v 1.101 1995/12/11 05:02:40 dyson Exp $
* $Id: wd.c,v 1.102 1996/01/16 18:13:16 phk Exp $
*/
/* TODO:
@ -231,7 +231,10 @@ struct disk {
u_char dk_error; /* copy of error reg. */
u_char dk_timeout; /* countdown to next timeout */
short dk_port; /* i/o port base */
#ifdef DEVFS
void *dk_bdev; /* devfs token for whole disk */
void *dk_cdev; /* devfs token for raw whole disk */
#endif
u_long cfg_flags; /* configured characteristics */
short dk_flags; /* drive characteristics found */
#define DKFL_SINGLE 0x00004 /* sector at a time mode */
@ -431,6 +434,10 @@ nodevice:
static int
wdattach(struct isa_device *dvp)
{
#ifdef DEVFS
int mynor;
char name[32];
#endif
int unit, lunit;
struct isa_device *wdup;
struct disk *du;
@ -508,6 +515,17 @@ wdattach(struct isa_device *dvp)
wdtimeout(du);
wd_registerdev(dvp->id_unit, lunit);
#ifdef DEVFS
mynor = dkmakeminor(unit, WHOLE_DISK_SLICE, RAW_PART);
sprintf(name, "rwd%d", unit);
du->dk_bdev = devfs_add_devsw("/", name + 1, &wd_bdevsw,
mynor, DV_BLK, 0, 0,
0640);
du->dk_cdev = devfs_add_devsw("/", name, &wd_cdevsw,
mynor, DV_CHR, 0, 0,
0640);
#endif
if (dk_ndrive < DK_NDRIVE) {
sprintf(dk_names[dk_ndrive], "wd%d", lunit);
/*
@ -1168,7 +1186,7 @@ wdopen(dev_t dev, int flags, int fmt, struct proc *p)
label.d_secpercyl = du->dk_dd.d_secpercyl;
label.d_secperunit = du->dk_dd.d_secperunit;
error = dsopen("wd", dev, fmt, &du->dk_slices, &label, wdstrategy1,
(ds_setgeom_t *)NULL);
(ds_setgeom_t *)NULL, &wd_bdevsw, &wd_cdevsw);
}
du->dk_flags &= ~DKFL_LABELLING;
wdsleep(du->dk_ctrlr, "wdopn2");

View File

@ -43,7 +43,7 @@
* SUCH DAMAGE.
*
* from: @(#)fd.c 7.4 (Berkeley) 5/25/91
* $Id: fd.c,v 1.77 1995/12/10 19:44:45 bde Exp $
* $Id: fd.c,v 1.78 1996/01/27 02:33:35 bde Exp $
*
*/
@ -247,8 +247,8 @@ static struct fd_data {
int options; /* user configurable options, see ioctl_fd.h */
int dkunit; /* disk stats unit number */
#ifdef DEVFS
void *rfd_devfs_token;
void *fd_devfs_token;
void *bdev;
void *cdev;
#endif
} fd_data[NFD];
@ -568,6 +568,7 @@ fdattach(struct isa_device *dev)
struct isa_device *fdup;
int ic_type = 0;
#ifdef DEVFS
int mynor;
char name[64];
#endif /* DEVFS */
@ -765,12 +766,14 @@ fdattach(struct isa_device *dev)
}
kdc_fd[fdu].kdc_state = DC_IDLE;
#ifdef DEVFS
fd->rfd_devfs_token = devfs_add_devsw(
"/",name,&fd_cdevsw, fdu * 8,
DV_CHR,0,0,0644);
fd->fd_devfs_token = devfs_add_devsw(
"/",name+1, &fd_bdevsw, fdu * 8,
DV_BLK,0,0,0644);
mynor = 8 * fdu;
fd->bdev = devfs_add_devsw("/", name + 1, &fd_bdevsw, mynor,
DV_BLK, 0, 0, 0640);
fd->cdev = devfs_add_devsw("/", name, &fd_cdevsw, mynor,
DV_CHR, 0, 0, 0640);
sprintf(name, "rfd%d", fdu);
dev_link("/", name + 1, fd->bdev);
dev_link("/", name, fd->cdev);
#endif /* DEVFS */
if (dk_ndrive < DK_NDRIVE) {
sprintf(dk_names[dk_ndrive], "fd%d", fdu);

View File

@ -28,7 +28,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: od.c,v 1.10 1995/12/14 09:54:22 phk Exp $
* $Id: od.c,v 1.11 1996/01/05 20:12:42 wollman Exp $
*/
/*
@ -208,7 +208,10 @@ odattach(struct scsi_link *sc_link)
{
u_int32 unit;
struct disk_parms *dp;
#ifdef DEVFS
char name[32];
int mynor;
#endif
struct scsi_data *od = sc_link->sd;
@ -252,14 +255,14 @@ odattach(struct scsi_link *sc_link)
od->flags |= ODINIT;
od_registerdev(unit);
#ifdef DEVFS
/* FIX PROPERLY WHEN DISKSLICE CODE IS UNDERSTOOD */
mynor = dkmakeminor(unit, WHOLE_DISK_SLICE, RAW_PART);
sprintf(name, "rod%d", unit);
od->c_devfs_token = devfs_add_devsw( "/", name, &od_cdevsw, 0,
DV_CHR, 0, 0, 0600);
sprintf(name, "od%d", unit);
od->b_devfs_token = devfs_add_devsw( "/", name, &od_bdevsw, 0,
DV_BLK, 0, 0, 0600);
od->b_devfs_token = devfs_add_devsw("/", name + 1, &od_bdevsw, mynor,
DV_BLK, 0, 0, 0640);
od->c_devfs_token = devfs_add_devsw("/", name, &od_cdevsw, mynor,
DV_CHR, 0, 0, 0640);
#endif
return 0;
@ -371,7 +374,7 @@ od_open(dev, mode, fmt, p, sc_link)
/* Initialize slice tables. */
errcode = dsopen("od", dev, fmt, &od->dk_slices, &label, odstrategy1,
(ds_setgeom_t *)NULL);
(ds_setgeom_t *)NULL, &od_bdevsw, &od_cdevsw);
if (errcode != 0)
goto bad;
SC_DEBUG(sc_link, SDEV_DB3, ("Slice tables initialized "));

View File

@ -14,7 +14,7 @@
*
* Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992
*
* $Id: sd.c,v 1.82 1995/12/14 19:38:40 bde Exp $
* $Id: sd.c,v 1.83 1996/01/05 20:12:49 wollman Exp $
*/
#include "opt_bounce.h"
@ -193,6 +193,7 @@ sdattach(struct scsi_link *sc_link)
u_int32 unit;
struct disk_parms *dp;
#ifdef DEVFS
int mynor;
char name[32];
#endif
@ -236,14 +237,14 @@ sdattach(struct scsi_link *sc_link)
sd_registerdev(unit);
#ifdef DEVFS
/* Fix minor numbers */
sprintf(name,"rsd%d",unit);
sd->c_devfs_token = devfs_add_devsw( "/", name, &sd_cdevsw, 0,
DV_CHR, 0, 0, 0600);
sprintf(name,"sd%d",unit);
sd->b_devfs_token = devfs_add_devsw( "/", name, &sd_bdevsw, 0,
DV_BLK, 0, 0, 0600);
mynor = dkmakeminor(unit, WHOLE_DISK_SLICE, RAW_PART);
sprintf(name, "rsd%d", unit);
sd->b_devfs_token = devfs_add_devsw("/", name + 1, &sd_bdevsw, mynor,
DV_BLK, 0, 0, 0640);
sd->c_devfs_token = devfs_add_devsw("/", name, &sd_cdevsw, mynor,
DV_CHR, 0, 0, 0640);
#endif
return 0;
}
@ -352,7 +353,7 @@ sd_open(dev, mode, fmt, p, sc_link)
/* Initialize slice tables. */
errcode = dsopen("sd", dev, fmt, &sd->dk_slices, &label, sdstrategy1,
(ds_setgeom_t *)NULL);
(ds_setgeom_t *)NULL, &sd_bdevsw, &sd_cdevsw);
if (errcode != 0)
goto bad;
SC_DEBUG(sc_link, SDEV_DB3, ("Slice tables initialized "));

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: diskslice.h,v 1.9 1995/05/08 16:27:10 bde Exp $
* $Id: diskslice.h,v 1.10 1995/05/30 08:14:19 rgrimes Exp $
*/
#ifndef _SYS_DISKSLICE_H_
@ -46,6 +46,17 @@ struct diskslice {
int ds_type; /* (foreign) slice type */
struct dkbad_intern *ds_bad; /* bad sector table, if any */
struct disklabel *ds_label; /* BSD label, if any */
void *ds_bdev; /* devfs token for whole slice */
void *ds_cdev; /* devfs token for raw whole slice */
#ifdef MAXPARTITIONS /* XXX don't depend on dislabel.h */
#if MAXPARTITIONS != 8 /* but check consistency if possible */
#error "inconsistent MAXPARTITIONS"
#endif
#else
#define MAXPARTITIONS 8
#endif
void *ds_bdevs[MAXPARTITIONS]; /* XXX s.b. in label */
void *ds_cdevs[MAXPARTITIONS]; /* XXX s.b. in label */
u_char ds_bopenmask; /* bdevs open */
u_char ds_copenmask; /* cdevs open */
u_char ds_openmask; /* [bc]devs open */
@ -81,6 +92,8 @@ struct diskslice {
#endif
struct diskslices {
struct bdevsw *dss_bdevsw; /* for containing device */
struct cdevsw *dss_cdevsw; /* for containing device */
int dss_first_bsd_slice; /* COMPATIBILTY_SLICE is mapped here */
u_int dss_nslices; /* actual dimension of dss_slices[] */
struct diskslice
@ -112,7 +125,8 @@ char *dsname __P((char *dname, int unit, int slice, int part,
char *partname));
int dsopen __P((char *dname, dev_t dev, int mode, struct diskslices **sspp,
struct disklabel *lp, d_strategy_t *strat,
ds_setgeom_t *setgeom));
ds_setgeom_t *setgeom, struct bdevsw *bdevsw,
struct cdevsw *cdevsw));
int dssize __P((dev_t dev, struct diskslices **sspp, d_open_t dopen,
d_close_t dclose));