From: deraadt Date: Sat, 4 Jan 1997 08:50:20 +0000 (+0000) Subject: readdisklabel() with correct dev_t X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e107dc91ac83c163a08f75ec186e5e496a2e0ef4;p=openbsd readdisklabel() with correct dev_t --- diff --git a/sys/dev/isa/mcd.c b/sys/dev/isa/mcd.c index 64ec2eee784..3436a03642e 100644 --- a/sys/dev/isa/mcd.c +++ b/sys/dev/isa/mcd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mcd.c,v 1.18 1996/12/05 13:15:28 deraadt Exp $ */ +/* $OpenBSD: mcd.c,v 1.19 1997/01/04 08:50:25 deraadt Exp $ */ /* $NetBSD: mcd.c,v 1.49 1996/05/12 23:53:11 mycroft Exp $ */ /* @@ -92,6 +92,8 @@ #define MCDUNIT(dev) DISKUNIT(dev) #define MAKEMCDDEV(maj, unit, part) MAKEDISKDEV(maj, unit, part) +#define MCDLABELDEV(dev) (MAKEMCDDEV(major(dev), MCDUNIT(dev), RAW_PART)) + /* toc */ #define MCD_MAXTOCS 104 /* from the Linux driver */ @@ -191,7 +193,7 @@ struct cfdriver mcd_cd = { NULL, "mcd", DV_DISK }; -void mcdgetdisklabel __P((struct mcd_softc *)); +void mcdgetdisklabel __P((dev_t, struct mcd_softc *)); int mcd_get_parms __P((struct mcd_softc *)); void mcdstrategy __P((struct buf *)); void mcdstart __P((struct mcd_softc *)); @@ -341,7 +343,7 @@ mcdopen(dev, flag, fmt, p) goto bad2; /* Fabricate a disk label. */ - mcdgetdisklabel(sc); + mcdgetdisklabel(dev, sc); } } @@ -676,7 +678,8 @@ mcdioctl(dev, cmd, addr, flag, p) * whether the scsi cd driver is linked in. */ void -mcdgetdisklabel(sc) +mcdgetdisklabel(dev, sc) + dev_t dev; struct mcd_softc *sc; { struct disklabel *lp = sc->sc_dk.dk_label; @@ -716,8 +719,8 @@ mcdgetdisklabel(sc) /* * Call the generic disklabel extraction routine */ - errstring = readdisklabel(MAKEMCDDEV(0, sc->sc_dev.dv_unit, RAW_PART), - mcdstrategy, lp, sc->sc_dk.dk_cpulabel); + errstring = readdisklabel(MCDLABELDEV(dev), mcdstrategy, lp, + sc->sc_dk.dk_cpulabel); if (errstring) { printf("%s: %s\n", sc->sc_dev.dv_xname, errstring); return; diff --git a/sys/dev/isa/wd.c b/sys/dev/isa/wd.c index 9eabee7e782..3858438158f 100644 --- a/sys/dev/isa/wd.c +++ b/sys/dev/isa/wd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wd.c,v 1.23 1996/11/29 22:55:08 niklas Exp $ */ +/* $OpenBSD: wd.c,v 1.24 1997/01/04 08:50:24 deraadt Exp $ */ /* $NetBSD: wd.c,v 1.150 1996/05/12 23:54:03 mycroft Exp $ */ /* @@ -92,7 +92,7 @@ struct cfdriver wd_cd = { NULL, "wd", DV_DISK }; -void wdgetdisklabel __P((struct wd_softc *)); +void wdgetdisklabel __P((dev_t, struct wd_softc *)); int wd_get_parms __P((struct wd_softc *)); void wdstrategy __P((struct buf *)); @@ -433,7 +433,7 @@ wdopen(dev, flag, fmt, p) } /* Load the partition info if not already loaded. */ - wdgetdisklabel(wd); + wdgetdisklabel(dev, wd); } } @@ -508,7 +508,8 @@ wdclose(dev, flag, fmt, p) * Fabricate a default disk label, and try to read the correct one. */ void -wdgetdisklabel(wd) +wdgetdisklabel(dev, wd) + dev_t dev; struct wd_softc *wd; { struct disklabel *lp = wd->sc_dk.dk_label; @@ -550,8 +551,8 @@ wdgetdisklabel(wd) if (d_link->sc_state > RECAL) d_link->sc_state = RECAL; - errstring = readdisklabel(MAKEWDDEV(0, wd->sc_dev.dv_unit, RAW_PART), - wdstrategy, lp, wd->sc_dk.dk_cpulabel); + errstring = readdisklabel(WDLABELDEV(dev), wdstrategy, lp, + wd->sc_dk.dk_cpulabel); if (errstring) { /* * This probably happened because the drive's default @@ -561,8 +562,8 @@ wdgetdisklabel(wd) */ if (d_link->sc_state > GEOMETRY) d_link->sc_state = GEOMETRY; - errstring = readdisklabel(MAKEWDDEV(0, wd->sc_dev.dv_unit, RAW_PART), - wdstrategy, lp, wd->sc_dk.dk_cpulabel); + errstring = readdisklabel(WDLABELDEV(dev), wdstrategy, lp, + wd->sc_dk.dk_cpulabel); } if (errstring) { printf("%s: %s\n", wd->sc_dev.dv_xname, errstring); diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c index 1a70e51bb0d..1cb5a70d445 100644 --- a/sys/dev/vnd.c +++ b/sys/dev/vnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vnd.c,v 1.7 1996/12/21 05:21:13 deraadt Exp $ */ +/* $OpenBSD: vnd.c,v 1.8 1997/01/04 08:50:22 deraadt Exp $ */ /* $NetBSD: vnd.c,v 1.26 1996/03/30 23:06:11 christos Exp $ */ /* @@ -95,6 +95,9 @@ int vnddebug = 0x00; #define b_cylin b_resid #define vndunit(x) DISKUNIT(x) +#define MAKEVNDDEV(maj, unit, part) MAKEDISKDEV(maj, unit, part) + +#define VNDLABELDEV(dev) (MAKEVNDDEV(major(dev), vndunit(dev), RAW_PART)) struct vndbuf { struct buf vb_buf; @@ -141,7 +144,7 @@ int vndsetcred __P((struct vnd_softc *, struct ucred *)); void vndthrottle __P((struct vnd_softc *, struct vnode *)); void vndiodone __P((struct buf *)); void vndshutdown __P((void)); -void vndgetdisklabel __P((struct vnd_softc *)); +void vndgetdisklabel __P((dev_t, struct vnd_softc *)); static int vndlock __P((struct vnd_softc *)); static void vndunlock __P((struct vnd_softc *)); @@ -189,7 +192,7 @@ vndopen(dev, flags, mode, p) if ((sc->sc_flags & VNF_INITED) && (sc->sc_flags & VNF_HAVELABEL) == 0) { sc->sc_flags |= VNF_HAVELABEL; - vndgetdisklabel(sc); + vndgetdisklabel(dev, sc); } part = DISKPART(dev); @@ -228,7 +231,8 @@ bad: * Load the label information on the named device */ void -vndgetdisklabel(sc) +vndgetdisklabel(dev, sc) + dev_t dev; struct vnd_softc *sc; { struct disklabel *lp = sc->sc_dk.dk_label; @@ -268,8 +272,8 @@ vndgetdisklabel(sc) /* * Call the generic disklabel extraction routine */ - errstring = readdisklabel(MAKEDISKDEV(0, sc->sc_dev.dv_unit, RAW_PART), - vndstrategy, lp, sc->sc_dk.dk_cpulabel); + errstring = readdisklabel(VNDLABELDEV(dev), vndstrategy, lp, + sc->sc_dk.dk_cpulabel); if (errstring) { printf("%s: %s\n", sc->sc_dev.dv_xname, errstring); return; diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c index 02e8273e751..56991a4fac9 100644 --- a/sys/scsi/cd.c +++ b/sys/scsi/cd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd.c,v 1.19 1996/12/24 01:33:33 deraadt Exp $ */ +/* $OpenBSD: cd.c,v 1.20 1997/01/04 08:50:20 deraadt Exp $ */ /* $NetBSD: cd.c,v 1.92 1996/05/05 19:52:50 christos Exp $ */ /* @@ -78,6 +78,8 @@ #define CDPART(z) DISKPART(z) #define MAKECDDEV(maj, unit, part) MAKEDISKDEV(maj, unit, part) +#define CDLABELDEV(dev) (MAKECDDEV(major(dev), CDUNIT(dev), RAW_PART)) + struct cd_softc { struct device sc_dev; struct disk sc_dk; @@ -108,7 +110,7 @@ int cdlock __P((struct cd_softc *)); void cdunlock __P((struct cd_softc *)); void cdstart __P((void *)); void cdminphys __P((struct buf *)); -void cdgetdisklabel __P((struct cd_softc *)); +void cdgetdisklabel __P((dev_t, struct cd_softc *)); int cddone __P((struct scsi_xfer *, int)); u_long cd_size __P((struct cd_softc *, int)); int cd_get_mode __P((struct cd_softc *, struct cd_mode_data *, int)); @@ -340,7 +342,7 @@ cdopen(dev, flag, fmt, p) SC_DEBUG(sc_link, SDEV_DB3, ("Params loaded ")); /* Fabricate a disk label. */ - cdgetdisklabel(cd); + cdgetdisklabel(dev, cd); SC_DEBUG(sc_link, SDEV_DB3, ("Disklabel fabricated ")); } } @@ -1043,7 +1045,8 @@ cdioctl(dev, cmd, addr, flag, p) * data tracks from the TOC and put it in the disklabel */ void -cdgetdisklabel(cd) +cdgetdisklabel(dev, cd) + dev_t dev; struct cd_softc *cd; { struct disklabel *lp = cd->sc_dk.dk_label; @@ -1085,8 +1088,8 @@ cdgetdisklabel(cd) /* * Call the generic disklabel extraction routine */ - errstring = readdisklabel(MAKECDDEV(0, cd->sc_dev.dv_unit, RAW_PART), - cdstrategy, lp, cd->sc_dk.dk_cpulabel); + errstring = readdisklabel(CDLABELDEV(dev), cdstrategy, lp, + cd->sc_dk.dk_cpulabel); if (errstring) { printf("%s: %s\n", cd->sc_dev.dv_xname, errstring); return; diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index 65384ca7a96..8a5331d0921 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.21 1996/12/11 19:08:18 deraadt Exp $ */ +/* $OpenBSD: sd.c,v 1.22 1997/01/04 08:50:21 deraadt Exp $ */ /* $NetBSD: sd.c,v 1.100.4.1 1996/06/04 23:14:08 thorpej Exp $ */ /* @@ -105,7 +105,7 @@ void sdattach __P((struct device *, struct device *, void *)); int sdlock __P((struct sd_softc *)); void sdunlock __P((struct sd_softc *)); void sdminphys __P((struct buf *)); -void sdgetdisklabel __P((struct sd_softc *)); +void sdgetdisklabel __P((dev_t, struct sd_softc *)); void sdstart __P((void *)); int sddone __P((struct scsi_xfer *, int)); int sd_reassign_blocks __P((struct sd_softc *, u_long)); @@ -321,7 +321,7 @@ sdopen(dev, flag, fmt, p) SC_DEBUG(sc_link, SDEV_DB3, ("Params loaded ")); /* Load the partition info if not already loaded. */ - sdgetdisklabel(sd); + sdgetdisklabel(dev, sd); SC_DEBUG(sc_link, SDEV_DB3, ("Disklabel loaded ")); } } @@ -772,7 +772,8 @@ sdioctl(dev, cmd, addr, flag, p) * Load the label information on the named device */ void -sdgetdisklabel(sd) +sdgetdisklabel(dev, sd) + dev_t dev; struct sd_softc *sd; { struct disklabel *lp = sd->sc_dk.dk_label; @@ -812,8 +813,8 @@ sdgetdisklabel(sd) /* * Call the generic disklabel extraction routine */ - errstring = readdisklabel(MAKESDDEV(0, sd->sc_dev.dv_unit, RAW_PART), - sdstrategy, lp, sd->sc_dk.dk_cpulabel); + errstring = readdisklabel(SDLABELDEV(dev), sdstrategy, lp, + sd->sc_dk.dk_cpulabel); if (errstring) { printf("%s: %s\n", sd->sc_dev.dv_xname, errstring); return;