summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-12-05 13:11:22 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-12-05 13:11:22 +0000
commit6b73ece8f93ac997318ff2539a7d1bec768e9dde (patch)
treeda3d990d8ad57bf8ad32304ef5915464d8de7777
parent9c9c479fccf366b3c4466f873b6bc23412c184c0 (diff)
call readdisklabel() in the same fashion as sd.c does
-rw-r--r--sys/dev/atapi/acd.c26
-rw-r--r--sys/scsi/cd.c25
2 files changed, 35 insertions, 16 deletions
diff --git a/sys/dev/atapi/acd.c b/sys/dev/atapi/acd.c
index a0bd2e94291..618073d64b2 100644
--- a/sys/dev/atapi/acd.c
+++ b/sys/dev/atapi/acd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acd.c,v 1.14 1996/10/05 07:17:00 downsj Exp $ */
+/* $OpenBSD: acd.c,v 1.15 1996/12/05 13:11:21 deraadt Exp $ */
/*
* Copyright (c) 1996 Manuel Bouyer. All rights reserved.
@@ -958,18 +958,20 @@ acdgetdisklabel(acd)
struct acd_softc *acd;
{
struct disklabel *lp = acd->sc_dk.dk_label;
+ char *errstring;
bzero(lp, sizeof(struct disklabel));
bzero(acd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
-#if 0 /* XXX */
lp->d_secsize = acd->params.blksize;
-#endif
- lp->d_secsize = 2048;
lp->d_ntracks = 1;
lp->d_nsectors = 100;
lp->d_ncylinders = (acd->params.disksize / 100) + 1;
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
+ if (lp->d_secpercyl == 0) {
+ lp->d_secpercyl = 100;
+ /* as long as it's not 0 - readdisklabel divides by it (?) */
+ }
strncpy(lp->d_typename, "ATAPI CD-ROM", 16);
lp->d_type = DTYPE_SCSI; /* XXX */
@@ -979,19 +981,25 @@ acdgetdisklabel(acd)
lp->d_interleave = 1;
lp->d_flags = D_REMOVABLE;
- lp->d_partitions[0].p_offset = 0;
- lp->d_partitions[0].p_size =
- lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
- lp->d_partitions[0].p_fstype = FS_ISO9660;
lp->d_partitions[RAW_PART].p_offset = 0;
lp->d_partitions[RAW_PART].p_size =
lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
- lp->d_partitions[RAW_PART].p_fstype = FS_ISO9660;
+ lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
lp->d_npartitions = RAW_PART + 1;
lp->d_magic = DISKMAGIC;
lp->d_magic2 = DISKMAGIC;
lp->d_checksum = dkcksum(lp);
+
+ /*
+ * Call the generic disklabel extraction routine
+ */
+ errstring = readdisklabel(MAKECDDEV(0, acd->sc_dev.dv_unit, RAW_PART),
+ acdstrategy, lp, acd->sc_dk.dk_cpulabel);
+ if (errstring) {
+ printf("%s: %s\n", acd->sc_dev.dv_xname, errstring);
+ return;
+ }
}
/*
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c
index cdd8d861b49..7e84a1eeffc 100644
--- a/sys/scsi/cd.c
+++ b/sys/scsi/cd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd.c,v 1.16 1996/10/31 01:09:20 niklas Exp $ */
+/* $OpenBSD: cd.c,v 1.17 1996/12/05 13:10:24 deraadt Exp $ */
/* $NetBSD: cd.c,v 1.92 1996/05/05 19:52:50 christos Exp $ */
/*
@@ -1046,6 +1046,7 @@ cdgetdisklabel(cd)
struct cd_softc *cd;
{
struct disklabel *lp = cd->sc_dk.dk_label;
+ char *errstring;
bzero(lp, sizeof(struct disklabel));
bzero(cd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
@@ -1055,8 +1056,12 @@ cdgetdisklabel(cd)
lp->d_nsectors = 100;
lp->d_ncylinders = (cd->params.disksize / 100) + 1;
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
+ if (lp->d_secpercyl == 0) {
+ lp->d_secpercyl = 100;
+ /* as long as it's not 0 - readdisklabel divides by it (?) */
+ }
- strncpy(lp->d_typename, "SCSI CD-ROM", 16);
+ strncpy(lp->d_typename, "SCSI disk", 16);
lp->d_type = DTYPE_SCSI;
strncpy(lp->d_packname, "fictitious", 16);
lp->d_secperunit = cd->params.disksize;
@@ -1064,19 +1069,25 @@ cdgetdisklabel(cd)
lp->d_interleave = 1;
lp->d_flags = D_REMOVABLE;
- lp->d_partitions[0].p_offset = 0;
- lp->d_partitions[0].p_size =
- lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
- lp->d_partitions[0].p_fstype = FS_ISO9660;
lp->d_partitions[RAW_PART].p_offset = 0;
lp->d_partitions[RAW_PART].p_size =
lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
- lp->d_partitions[RAW_PART].p_fstype = FS_ISO9660;
+ lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
lp->d_npartitions = RAW_PART + 1;
lp->d_magic = DISKMAGIC;
lp->d_magic2 = DISKMAGIC;
lp->d_checksum = dkcksum(lp);
+
+ /*
+ * Call the generic disklabel extraction routine
+ */
+ errstring = readdisklabel(MAKECDDEV(0, cd->sc_dev.dv_unit, RAW_PART),
+ cdstrategy, lp, cd->sc_dk.dk_cpulabel);
+ if (errstring) {
+ printf("%s: %s\n", cd->sc_dev.dv_xname, errstring);
+ return;
+ }
}
/*