diff options
author | 1996-12-05 13:10:24 +0000 | |
---|---|---|
committer | 1996-12-05 13:10:24 +0000 | |
commit | 3c27f4f2022050f5fee90905c3638e919f85ef2b (patch) | |
tree | baa81fdce3120092d96dc8751c807c9e133a251c /sys/dev/isa | |
parent | call iso_disklabelspoof() as needed... (diff) | |
download | wireguard-openbsd-3c27f4f2022050f5fee90905c3638e919f85ef2b.tar.xz wireguard-openbsd-3c27f4f2022050f5fee90905c3638e919f85ef2b.zip |
call readdisklabel() in the same fashion as sd.c does
Diffstat (limited to 'sys/dev/isa')
-rw-r--r-- | sys/dev/isa/fd.c | 52 | ||||
-rw-r--r-- | sys/dev/isa/mcd.c | 26 |
2 files changed, 57 insertions, 21 deletions
diff --git a/sys/dev/isa/fd.c b/sys/dev/isa/fd.c index 06b6c7256b1..949fa9802d7 100644 --- a/sys/dev/isa/fd.c +++ b/sys/dev/isa/fd.c @@ -1,4 +1,4 @@ -/* $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 $ */ /*- @@ -953,7 +953,9 @@ fdioctl(dev, cmd, addr, flag, p) 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) { @@ -962,16 +964,38 @@ fdioctl(dev, cmd, addr, flag, p) 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: @@ -984,11 +1008,11 @@ fdioctl(dev, cmd, addr, flag, p) 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: diff --git a/sys/dev/isa/mcd.c b/sys/dev/isa/mcd.c index 0c13c11d319..64ec2eee784 100644 --- a/sys/dev/isa/mcd.c +++ b/sys/dev/isa/mcd.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -90,6 +90,7 @@ #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 */ @@ -679,6 +680,7 @@ mcdgetdisklabel(sc) 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)); @@ -688,28 +690,38 @@ mcdgetdisklabel(sc) 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 |