summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2000-06-15 20:30:53 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2000-06-15 20:30:53 +0000
commit4bd02a5609ea21b6876f95d7f63ae08dd4b85be1 (patch)
treed004d079a69450b92b2c39e2736a3a928c1efa22 /sys
parent0b1574bd338137410761a20a75cf3393e5169f7b (diff)
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/amd64/autoconf.c4
-rw-r--r--sys/dev/ata/ata-disk.c24
-rw-r--r--sys/i386/i386/autoconf.c4
-rw-r--r--sys/kern/subr_disk.c16
-rw-r--r--sys/sys/disk.h4
5 files changed, 21 insertions, 31 deletions
diff --git a/sys/amd64/amd64/autoconf.c b/sys/amd64/amd64/autoconf.c
index 46f35c4a6679..61d0abbcf068 100644
--- a/sys/amd64/amd64/autoconf.c
+++ b/sys/amd64/amd64/autoconf.c
@@ -276,10 +276,8 @@ setroot()
}
majdev = B_TYPE(bootdev);
dev = makebdev(majdev, 0);
- if (devsw(dev) == NULL) {
- printf("no devsw (majdev=%d bootdev=%#lx)\n", majdev, bootdev);
+ if (devsw(dev) == NULL)
return;
- }
unit = B_UNIT(bootdev);
slice = B_SLICE(bootdev);
if (slice == WHOLE_DISK_SLICE)
diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c
index 4b0aaf7e92ce..a11e76635d61 100644
--- a/sys/dev/ata/ata-disk.c
+++ b/sys/dev/ata/ata-disk.c
@@ -72,23 +72,6 @@ static struct cdevsw ad_cdevsw = {
/* bmaj */ 30
};
static struct cdevsw addisk_cdevsw;
-static struct cdevsw fakewd_cdevsw = {
- /* open */ adopen,
- /* close */ nullclose,
- /* read */ physread,
- /* write */ physwrite,
- /* ioctl */ noioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strategy */ adstrategy,
- /* name */ "wd",
- /* maj */ 3,
- /* dump */ addump,
- /* psize */ nopsize,
- /* flags */ D_DISK,
- /* bmaj */ 0
-};
-static struct cdevsw fakewddisk_cdevsw;
/* prototypes */
static void ad_timeout(struct ad_request *);
@@ -196,12 +179,6 @@ ad_attach(struct ata_softc *scp, int32_t device)
dev->si_iosize_max = 256 * DEV_BSIZE;
adp->dev1 = dev;
- dev = disk_create(adp->lun, &adp->disk, 0, &fakewd_cdevsw,
- &fakewddisk_cdevsw);
- dev->si_drv1 = adp;
- dev->si_iosize_max = 256 * DEV_BSIZE;
- adp->dev2 = dev;
-
bioq_init(&adp->queue);
}
@@ -210,7 +187,6 @@ ad_detach(struct ad_softc *adp)
{
disk_invalidate(&adp->disk);
disk_destroy(adp->dev1);
- disk_destroy(adp->dev2);
devstat_remove_entry(&adp->stats);
ata_free_lun(&adp_lun_map, adp->lun);
free(adp, M_AD);
diff --git a/sys/i386/i386/autoconf.c b/sys/i386/i386/autoconf.c
index 46f35c4a6679..61d0abbcf068 100644
--- a/sys/i386/i386/autoconf.c
+++ b/sys/i386/i386/autoconf.c
@@ -276,10 +276,8 @@ setroot()
}
majdev = B_TYPE(bootdev);
dev = makebdev(majdev, 0);
- if (devsw(dev) == NULL) {
- printf("no devsw (majdev=%d bootdev=%#lx)\n", majdev, bootdev);
+ if (devsw(dev) == NULL)
return;
- }
unit = B_UNIT(bootdev);
slice = B_SLICE(bootdev);
if (slice == WHOLE_DISK_SLICE)
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index c600d384e19c..5e18163df5fb 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -27,6 +27,8 @@ static d_open_t diskopen;
static d_close_t diskclose;
static d_ioctl_t diskioctl;
static d_psize_t diskpsize;
+
+static LIST_HEAD(, disk) disklist = LIST_HEAD_INITIALIZER(&disklist);
dev_t
disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw, struct cdevsw *proto)
@@ -49,12 +51,13 @@ disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw, struct
if (bootverbose)
printf("Creating DISK %s%d\n", cdevsw->d_name, unit);
dev = make_dev(proto, dkmakeminor(unit, WHOLE_DISK_SLICE, RAW_PART),
- 0, 0, 0, "r%s%d", cdevsw->d_name, unit);
+ 0, 0, 0, "%s%d", cdevsw->d_name, unit);
dev->si_disk = dp;
dp->d_dev = dev;
dp->d_dsflags = flags;
dp->d_devsw = cdevsw;
+ LIST_INSERT_HEAD(&disklist, dp, d_list);
return (dev);
}
@@ -95,11 +98,22 @@ disk_invalidate (struct disk *disk)
void
disk_destroy(dev_t dev)
{
+ LIST_REMOVE(dev->si_disk, d_list);
+ bzero(dev->si_disk, sizeof(*dev->si_disk));
dev->si_disk = NULL;
destroy_dev(dev);
return;
}
+struct disk *
+disk_enumerate(struct disk *disk)
+{
+ if (!disk)
+ return (LIST_FIRST(&disklist));
+ else
+ return (LIST_NEXT(disk, d_list));
+}
+
/*
* The cdevsw functions
*/
diff --git a/sys/sys/disk.h b/sys/sys/disk.h
index 855670dfa420..958714b199d9 100644
--- a/sys/sys/disk.h
+++ b/sys/sys/disk.h
@@ -21,6 +21,8 @@
#include <sys/disklabel.h>
#endif /* _SYS_DISKLABEL */
+#include <sys/queue.h>
+
struct disk {
u_int d_flags;
u_int d_dsflags;
@@ -28,6 +30,7 @@ struct disk {
dev_t d_dev;
struct diskslices *d_slice;
struct disklabel d_label;
+ LIST_ENTRY(disk) d_list;
};
#define DISKFLAG_LOCK 0x1
@@ -36,6 +39,7 @@ struct disk {
dev_t disk_create __P((int unit, struct disk *disk, int flags, struct cdevsw *cdevsw, struct cdevsw *diskdevsw));
void disk_destroy __P((dev_t dev));
int disk_dumpcheck __P((dev_t dev, u_int *count, u_int *blkno, u_int *secsize));
+struct disk *disk_enumerate __P((struct disk *disk));
void disk_invalidate __P((struct disk *disk));
#endif /* _SYS_DISK_H_ */