-/* $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.
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 */
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;
+ }
}
/*
-/* $OpenBSD: fd.c,v 1.29 1996/11/29 22:54:55 niklas Exp $ */
+/* $OpenBSD: fd.c,v 1.30 1996/12/05 13:13:05 deraadt Exp $ */
/* $NetBSD: fd.c,v 1.90 1996/05/12 23:12:03 mycroft Exp $ */
/*-
struct proc *p;
{
struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(dev)];
- struct disklabel buffer;
+ struct disklabel dl, *lp = &dl;
+ struct cpu_disklabel cdl;
+ char *msg;
int error;
switch (cmd) {
return EIO;
return (0);
case DIOCGDINFO:
- bzero(&buffer, sizeof(buffer));
-
- buffer.d_secpercyl = fd->sc_type->seccyl;
- buffer.d_type = DTYPE_FLOPPY;
- buffer.d_secsize = 128 << fd->sc_type->secsize;
-
- if (readdisklabel(dev, fdstrategy, &buffer, NULL) != NULL)
- return EINVAL;
-
- *(struct disklabel *)addr = buffer;
+ bzero(lp, sizeof(*lp));
+ bzero(&cdl, sizeof(struct cpu_disklabel));
+
+ lp->d_secsize = 128 << fd->sc_type->secsize;
+ lp->d_secpercyl = fd->sc_type->seccyl;
+ lp->d_ntracks = fd->sc_type->heads;
+ lp->d_nsectors = fd->sc_type->seccyl;
+ lp->d_ncylinders = fd->sc_type->tracks;
+ lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
+
+ strncpy(lp->d_typename, "floppy disk", 16);
+ lp->d_type = DTYPE_FLOPPY;
+ strncpy(lp->d_packname, "fictitious", 16);
+ lp->d_secperunit = fd->sc_type->size;
+ lp->d_rpm = 300;
+ lp->d_interleave = 1;
+ lp->d_flags = D_REMOVABLE;
+
+ 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_UNUSED;
+ lp->d_npartitions = RAW_PART + 1;
+
+ lp->d_magic = DISKMAGIC;
+ lp->d_magic2 = DISKMAGIC;
+ lp->d_checksum = dkcksum(lp);
+
+ if ((msg = readdisklabel(dev, fdstrategy, lp, &cdl)) != NULL)
+ printf("readdisklabel: %s\n", msg);
+
+ *(struct disklabel *)addr = *lp;
return 0;
case DIOCWLABEL:
if ((flag & FWRITE) == 0)
return EBADF;
- error = setdisklabel(&buffer, (struct disklabel *)addr, 0, NULL);
+ error = setdisklabel(lp, (struct disklabel *)addr, 0, NULL);
if (error)
return error;
- error = writedisklabel(dev, fdstrategy, &buffer, NULL);
+ error = writedisklabel(dev, fdstrategy, lp, NULL);
return error;
case FD_FORM:
-/* $OpenBSD: mcd.c,v 1.17 1996/09/20 06:08:10 deraadt Exp $ */
+/* $OpenBSD: mcd.c,v 1.18 1996/12/05 13:15:28 deraadt Exp $ */
/* $NetBSD: mcd.c,v 1.49 1996/05/12 23:53:11 mycroft Exp $ */
/*
#define MCDPART(dev) DISKPART(dev)
#define MCDUNIT(dev) DISKUNIT(dev)
+#define MAKEMCDDEV(maj, unit, part) MAKEDISKDEV(maj, unit, part)
/* toc */
#define MCD_MAXTOCS 104 /* from the Linux driver */
struct mcd_softc *sc;
{
struct disklabel *lp = sc->sc_dk.dk_label;
+ char *errstring;
bzero(lp, sizeof(struct disklabel));
bzero(sc->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
lp->d_nsectors = 100;
lp->d_ncylinders = (sc->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, "Mitsumi CD-ROM", 16);
- lp->d_type = 0; /* XXX */
+ lp->d_type = DTYPE_SCSI; /* XXX */
strncpy(lp->d_packname, "fictitious", 16);
lp->d_secperunit = sc->disksize;
lp->d_rpm = 300;
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(MAKEMCDDEV(0, sc->sc_dev.dv_unit, RAW_PART),
+ mcdstrategy, lp, sc->sc_dk.dk_cpulabel);
+ if (errstring) {
+ printf("%s: %s\n", sc->sc_dev.dv_xname, errstring);
+ return;
+ }
}
int
-/* $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 $ */
/*
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));
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;
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;
+ }
}
/*