diff options
author | phk <phk@FreeBSD.org> | 2002-09-20 19:36:05 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-09-20 19:36:05 +0000 |
commit | 57a346a21312d7f99ca28aee15ab6091be10cbd7 (patch) | |
tree | 47b5afae3623c1371d19a0478c850d8e6a08d07b /sys/cam | |
parent | 2fb7a39c0fdc17568c3b60cf37e5f3c2d6dff5e4 (diff) | |
download | FreeBSD-src-57a346a21312d7f99ca28aee15ab6091be10cbd7.zip FreeBSD-src-57a346a21312d7f99ca28aee15ab6091be10cbd7.tar.gz |
(This commit touches about 15 disk device drivers in a very consistent
and predictable way, and I apologize if I have gotten it wrong anywhere,
getting prior review on a patch like this is not feasible, considering
the number of people involved and hardware availability etc.)
If struct disklabel is the messenger: kill the messenger.
Inside struct disk we had a struct disklabel which disk drivers used to
communicate certain metrics to the disklayer above (GEOM or the disk
mini-layer). This commit changes this communication to use four
explicit fields instead.
Amongst the benefits is that the fields do not get overwritten by
wrong or bogus on-disk disklabels.
Once that is clear, <sys/disk.h> which is included in the drivers
no longer need to pull <sys/disklabel.h> and <sys/diskslice.h> in,
the few places that needs them, have gotten explicit #includes for
them.
The disklabel inside struct disk is now only for internal use in
the disk mini-layer, so instead of embedding it, we malloc it as
we need it.
This concludes (modulus any mistakes) the series of disklabel related
commits.
I belive it all amounts to a NOP for all the rest of you :-)
Sponsored by: DARPA & NAI Labs.
Diffstat (limited to 'sys/cam')
-rw-r--r-- | sys/cam/scsi/scsi_cd.c | 44 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_da.c | 32 |
2 files changed, 12 insertions, 64 deletions
diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index 88073f6..99ad08f 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -54,6 +54,7 @@ #include <sys/bio.h> #include <sys/conf.h> #include <sys/disk.h> +#include <sys/diskslice.h> #include <sys/malloc.h> #include <sys/cdio.h> #include <sys/dvdio.h> @@ -858,10 +859,8 @@ cdregisterexit: static int cdopen(dev_t dev, int flags, int fmt, struct thread *td) { - struct disklabel *label; struct cam_periph *periph; struct cd_softc *softc; - struct ccb_getdev cgd; u_int32_t size; int error; int s; @@ -912,41 +911,12 @@ cdopen(dev_t dev, int flags, int fmt, struct thread *td) error = 0; } - /* - * Build prototype label for whole disk. - * Should take information about different data tracks from the - * TOC and put it in the partition table. - */ - label = &softc->disk.d_label; - bzero(label, sizeof(*label)); - label->d_type = DTYPE_SCSI; - - /* - * Grab the inquiry data to get the vendor and product names. - * Put them in the typename and packname for the label. - */ - xpt_setup_ccb(&cgd.ccb_h, periph->path, /*priority*/ 1); - cgd.ccb_h.func_code = XPT_GDEV_TYPE; - xpt_action((union ccb *)&cgd); - - strncpy(label->d_typename, cgd.inq_data.vendor, - min(SID_VENDOR_SIZE, sizeof(label->d_typename))); - strncpy(label->d_packname, cgd.inq_data.product, - min(SID_PRODUCT_SIZE, sizeof(label->d_packname))); - - label->d_secsize = softc->params.blksize; - label->d_secperunit = softc->params.disksize; - label->d_flags = D_REMOVABLE; - /* - * Make partition 'a' cover the whole disk. This is a temporary - * compatibility hack. The 'a' partition should not exist, so - * the slice code won't create it. The slice code will make - * partition (RAW_PART + 'a') cover the whole disk and fill in - * some more defaults. - */ - label->d_partitions[0].p_size = label->d_secperunit; - label->d_partitions[0].p_fstype = FS_OTHER; - + softc->disk.d_sectorsize = softc->params.blksize; + softc->disk.d_mediasize = softc->params.blksize * + (off_t)softc->params.disksize; + softc->disk.d_fwsectors = 0; + softc->disk.d_fwheads = 0; + /* * We unconditionally (re)set the blocksize each time the * CD device is opened. This is because the CD can change, diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index bf77e70..c8ea135 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -496,7 +496,6 @@ daopen(dev_t dev, int flags __unused, int fmt __unused, struct thread *td __unus { struct cam_periph *periph; struct da_softc *softc; - struct disklabel *label; struct scsi_read_capacity_data *rcap; union ccb *ccb; int unit; @@ -565,33 +564,12 @@ daopen(dev_t dev, int flags __unused, int fmt __unused, struct thread *td __unus free(rcap, M_TEMP); if (error == 0) { - struct ccb_getdev cgd; - /* Build label for whole disk. */ - label = &softc->disk.d_label; - bzero(label, sizeof(*label)); - label->d_type = DTYPE_SCSI; - - /* - * Grab the inquiry data to get the vendor and product names. - * Put them in the typename and packname for the label. - */ - xpt_setup_ccb(&cgd.ccb_h, periph->path, /*priority*/ 1); - cgd.ccb_h.func_code = XPT_GDEV_TYPE; - xpt_action((union ccb *)&cgd); - - strncpy(label->d_typename, cgd.inq_data.vendor, - min(SID_VENDOR_SIZE, sizeof(label->d_typename))); - strncpy(label->d_packname, cgd.inq_data.product, - min(SID_PRODUCT_SIZE, sizeof(label->d_packname))); - - label->d_secsize = softc->params.secsize; - label->d_nsectors = softc->params.secs_per_track; - label->d_ntracks = softc->params.heads; - label->d_ncylinders = softc->params.cylinders; - label->d_secpercyl = softc->params.heads - * softc->params.secs_per_track; - label->d_secperunit = softc->params.sectors; + softc->disk.d_sectorsize = softc->params.secsize; + softc->disk.d_mediasize = softc->params.secsize * (off_t)softc->params.sectors; + /* XXX: these are not actually "firmware" values, so they may be wrong */ + softc->disk.d_fwsectors = softc->params.secs_per_track; + softc->disk.d_fwheads = softc->params.heads; /* * Check to see whether or not the blocksize is set yet. |