diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2010-09-22 06:40:26 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2010-09-22 06:40:26 +0000 |
commit | 83018e34c552b5700c5ac28bf696aaa3a17bd340 (patch) | |
tree | ee30239a31556afdfeeb9b96973a4e7477ac1abf | |
parent | e691fb7bf4efc5936e953f3fbb2989323614af79 (diff) |
Add DIOCGPDINFO to drivers that were lacking it. Where there
is no easily available physical information outside of the stored
disklabel just make it a synonym for DIOCGDINFO.
Commit on the theory it is unlikely to harm, and fallout can be
addressed in the mass re-compile that will follow j2k10.
Should allow auto-allocation of disks to work with all devices.
ok deraadt@
-rw-r--r-- | sys/arch/sparc/dev/presto.c | 17 | ||||
-rw-r--r-- | sys/arch/sparc/dev/xd.c | 3 | ||||
-rw-r--r-- | sys/arch/sparc/dev/xy.c | 3 | ||||
-rw-r--r-- | sys/arch/vax/mba/hp.c | 3 | ||||
-rw-r--r-- | sys/arch/vax/mscp/mscp_disk.c | 3 | ||||
-rw-r--r-- | sys/arch/vax/vsa/hdc9224.c | 20 | ||||
-rw-r--r-- | sys/dev/flash.c | 7 |
7 files changed, 40 insertions, 16 deletions
diff --git a/sys/arch/sparc/dev/presto.c b/sys/arch/sparc/dev/presto.c index cfdf91d664c..c9e7e01deb3 100644 --- a/sys/arch/sparc/dev/presto.c +++ b/sys/arch/sparc/dev/presto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: presto.c,v 1.19 2010/09/22 01:18:57 matthew Exp $ */ +/* $OpenBSD: presto.c,v 1.20 2010/09/22 06:40:25 krw Exp $ */ /* * Copyright (c) 2003, Miodrag Vallat. * All rights reserved. @@ -71,7 +71,7 @@ struct presto_softc { void prestostrategy(struct buf *); void presto_attach(struct device *, struct device *, void *); -void presto_getdisklabel(dev_t, struct presto_softc *); +void presto_getdisklabel(dev_t, struct presto_softc *, struct disklabel *, int); int presto_match(struct device *, void *, void *); struct cfattach presto_ca = { @@ -209,7 +209,7 @@ prestoopen(dev_t dev, int flag, int fmt, struct proc *proc) return (ENXIO); /* read the disk label */ - presto_getdisklabel(dev, sc); + presto_getdisklabel(dev, sc, sc->sc_dk.dk_label, 0); /* only allow valid partitions */ part = DISKPART(dev); @@ -324,6 +324,10 @@ prestoioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *proc) sc = (struct presto_softc *)device_lookup(&presto_cd, unit); switch (cmd) { + case DIOCGPDINFO: + presto_getdisklabel(dev, sc, (struct disklabel *)data, 1); + break; + case DIOCGDINFO: bcopy(sc->sc_dk.dk_label, data, sizeof(struct disklabel)); return (0); @@ -351,10 +355,9 @@ prestoioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *proc) * Read the disklabel. If none is present, use a fictitious one instead. */ void -presto_getdisklabel(dev_t dev, struct presto_softc *sc) +presto_getdisklabel(dev_t dev, struct presto_softc *sc, struct disklabel *lp, + int spoofonly); { - struct disklabel *lp = sc->sc_dk.dk_label; - bzero(sc->sc_dk.dk_label, sizeof(struct disklabel)); lp->d_secsize = DEV_BSIZE; @@ -373,5 +376,5 @@ presto_getdisklabel(dev_t dev, struct presto_softc *sc) lp->d_magic2 = DISKMAGIC; lp->d_checksum = dkcksum(lp); - readdisklabel(DISKLABELDEV(dev), prestostrategy, sc->sc_dk.dk_label, 0); + readdisklabel(DISKLABELDEV(dev), prestostrategy, lp, spoofonly); } diff --git a/sys/arch/sparc/dev/xd.c b/sys/arch/sparc/dev/xd.c index befdf6bfb83..c61b96affc5 100644 --- a/sys/arch/sparc/dev/xd.c +++ b/sys/arch/sparc/dev/xd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xd.c,v 1.51 2010/09/22 01:18:57 matthew Exp $ */ +/* $OpenBSD: xd.c,v 1.52 2010/09/22 06:40:25 krw Exp $ */ /* $NetBSD: xd.c,v 1.37 1997/07/29 09:58:16 fair Exp $ */ /* @@ -839,6 +839,7 @@ xdioctl(dev, command, addr, flag, p) return 0; case DIOCGDINFO: /* get disk label */ + case DIOCGPDINFO: /* no separate 'physical' info available. */ bcopy(xd->sc_dk.dk_label, addr, sizeof(struct disklabel)); return 0; diff --git a/sys/arch/sparc/dev/xy.c b/sys/arch/sparc/dev/xy.c index 42b10c2e715..8857c2e4e84 100644 --- a/sys/arch/sparc/dev/xy.c +++ b/sys/arch/sparc/dev/xy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xy.c,v 1.49 2010/09/22 01:18:57 matthew Exp $ */ +/* $OpenBSD: xy.c,v 1.50 2010/09/22 06:40:25 krw Exp $ */ /* $NetBSD: xy.c,v 1.26 1997/07/19 21:43:56 pk Exp $ */ /* @@ -800,6 +800,7 @@ xyioctl(dev, command, addr, flag, p) return 0; case DIOCGDINFO: /* get disk label */ + case DIOCGPDINFO: /* no separate 'physical' info available. */ bcopy(xy->sc_dk.dk_label, addr, sizeof(struct disklabel)); return 0; diff --git a/sys/arch/vax/mba/hp.c b/sys/arch/vax/mba/hp.c index 567a6f8c25a..ab5450e1828 100644 --- a/sys/arch/vax/mba/hp.c +++ b/sys/arch/vax/mba/hp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hp.c,v 1.22 2010/09/22 01:18:57 matthew Exp $ */ +/* $OpenBSD: hp.c,v 1.23 2010/09/22 06:40:25 krw Exp $ */ /* $NetBSD: hp.c,v 1.22 2000/02/12 16:09:33 ragge Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. @@ -329,6 +329,7 @@ hpioctl(dev, cmd, addr, flag, p) switch (cmd) { case DIOCGDINFO: + case DIOCGPDINFO: /* no separate 'physical' info available. */ bcopy(lp, addr, sizeof (struct disklabel)); return 0; diff --git a/sys/arch/vax/mscp/mscp_disk.c b/sys/arch/vax/mscp/mscp_disk.c index 854c673c47a..4686d977567 100644 --- a/sys/arch/vax/mscp/mscp_disk.c +++ b/sys/arch/vax/mscp/mscp_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mscp_disk.c,v 1.31 2010/09/22 01:18:57 matthew Exp $ */ +/* $OpenBSD: mscp_disk.c,v 1.32 2010/09/22 06:40:25 krw Exp $ */ /* $NetBSD: mscp_disk.c,v 1.30 2001/11/13 07:38:28 lukem Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. @@ -378,6 +378,7 @@ raioctl(dev, cmd, data, flag, p) switch (cmd) { case DIOCGDINFO: + case DIOCGPDINFO: /* no separate 'physical' info available. */ bcopy(lp, data, sizeof (struct disklabel)); break; diff --git a/sys/arch/vax/vsa/hdc9224.c b/sys/arch/vax/vsa/hdc9224.c index ba4c509951b..866cadb0c05 100644 --- a/sys/arch/vax/vsa/hdc9224.c +++ b/sys/arch/vax/vsa/hdc9224.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hdc9224.c,v 1.32 2010/09/22 01:18:57 matthew Exp $ */ +/* $OpenBSD: hdc9224.c,v 1.33 2010/09/22 06:40:25 krw Exp $ */ /* $NetBSD: hdc9224.c,v 1.16 2001/07/26 15:05:09 wiz Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. @@ -164,6 +164,7 @@ void hdattach(struct device *, struct device *, void *); void hdcintr(void *); int hdc_command(struct hdcsoftc *, int); void hd_readgeom(struct hdcsoftc *, struct hdsoftc *); +int hdgetdisklabel(dev_t, hdsoftc *, struct disklabel *, int); #ifdef HDDEBUG void hdc_printgeom( struct hdgeom *); #endif @@ -337,6 +338,14 @@ hdmatch(parent, vcf, aux) #define HDMAJOR 19 +int +hdgetdisklabel(dev_t dev, hdsoftc *sc, struct disklabel *lp, int spoofonly) +{ + hdmakelabel(lp, &hd->sc_xbn); + + return readdisklabel(DISKLABEL(dev), hdstrategy, lp, spoofonly); +} + void hdattach(struct device *parent, struct device *self, void *aux) { @@ -360,9 +369,8 @@ hdattach(struct device *parent, struct device *self, void *aux) hd_readgeom(sc, hd); disk_printtype(hd->sc_drive, hd->sc_xbn.media_id); dl = hd->sc_disk.dk_label; - hdmakelabel(dl, &hd->sc_xbn); - error = readdisklabel(MAKEDISKDEV(HDMAJOR, hd->sc_dev.dv_unit, RAW_PART), - hdstrategy, dl, 0); + error = hdgetdisklabel(MAKEDISKDEV(HDMAJOR, hd->sc_dev.dv_unit, RAW_PART), + hd, dl, 0); printf("%s: %luMB, %lu sectors\n", hd->sc_dev.dv_xname, DL_GETDSIZE(dl) / (1048576 / DEV_BSIZE), DL_GETDSIZE(dl)); @@ -700,6 +708,10 @@ hdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) int error = 0; switch (cmd) { + case DIOCGPDINFO: + hdgetdisklabel(dev, hd, (struct disklabel *)addr, 1); + break; + case DIOCGDINFO: bcopy(lp, addr, sizeof (struct disklabel)); break; diff --git a/sys/dev/flash.c b/sys/dev/flash.c index 8f267d5775f..9c18b848321 100644 --- a/sys/dev/flash.c +++ b/sys/dev/flash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flash.c,v 1.18 2010/09/22 01:18:57 matthew Exp $ */ +/* $OpenBSD: flash.c,v 1.19 2010/09/22 06:40:25 krw Exp $ */ /* * Copyright (c) 2005 Uwe Stuehler <uwe@openbsd.org> @@ -850,9 +850,14 @@ flashioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p) } switch (cmd) { + case DIOCGPDINFO: + flashgetdisklabel(dev, sc, (struct disklabel *)data, 1); + break + case DIOCGDINFO: *(struct disklabel *)data = *sc->sc_dk.dk_label; break; + default: error = ENOTTY; break; |