diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-08-13 15:23:14 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-08-13 15:23:14 +0000 |
commit | cf6459c8f783ece5445be14e8e2e7201f7cd6632 (patch) | |
tree | a5a86e9615b432c0d3ef13f965013ddf06ea6bff /sys/arch/sparc | |
parent | 46faf138ca97f0462a1c22674098875302fe10d0 (diff) |
Replace the error strings that were being passed around with much simpler
errnos. Note that the error strings are being ignored, since we long ago
decided to not spam the console, and there is no other nice way to use the
errors (without changing the ioctls to pass it back)
The errno is now useful, since we can pass b_error from failing IO up, and
the drive can decide how to use that
ok miod
Diffstat (limited to 'sys/arch/sparc')
-rw-r--r-- | sys/arch/sparc/dev/fd.c | 13 | ||||
-rw-r--r-- | sys/arch/sparc/dev/xd.c | 14 | ||||
-rw-r--r-- | sys/arch/sparc/dev/xy.c | 16 | ||||
-rw-r--r-- | sys/arch/sparc/sparc/disksubr.c | 43 |
4 files changed, 37 insertions, 49 deletions
diff --git a/sys/arch/sparc/dev/fd.c b/sys/arch/sparc/dev/fd.c index 9c99fad9d59..070f4c029e1 100644 --- a/sys/arch/sparc/dev/fd.c +++ b/sys/arch/sparc/dev/fd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fd.c,v 1.65 2009/07/24 08:07:39 blambert Exp $ */ +/* $OpenBSD: fd.c,v 1.66 2009/08/13 15:23:12 deraadt Exp $ */ /* $NetBSD: fd.c,v 1.51 1997/05/24 20:16:19 pk Exp $ */ /*- @@ -237,7 +237,7 @@ struct cfdriver fd_cd = { NULL, "fd", DV_DISK }; -void fdgetdisklabel(dev_t, struct fd_softc *, struct disklabel *, int); +int fdgetdisklabel(dev_t, struct fd_softc *, struct disklabel *, int); int fd_get_parms(struct fd_softc *); void fdstrategy(struct buf *); void fdstart(struct fd_softc *); @@ -1931,12 +1931,10 @@ fdformat(dev, finfo, p) return (rv); } -void +int fdgetdisklabel(dev_t dev, struct fd_softc *fd, struct disklabel *lp, int spoofonly) { - char *errstring; - bzero(lp, sizeof(struct disklabel)); lp->d_type = DTYPE_FLOPPY; @@ -1960,10 +1958,7 @@ fdgetdisklabel(dev_t dev, struct fd_softc *fd, struct disklabel *lp, /* * Call the generic disklabel extraction routine. */ - errstring = readdisklabel(DISKLABELDEV(dev), fdstrategy, lp, spoofonly); - if (errstring) { - /*printf("%s: %s\n", fd->sc_dv.dv_xname, errstring);*/ - } + return readdisklabel(DISKLABELDEV(dev), fdstrategy, lp, spoofonly); } void diff --git a/sys/arch/sparc/dev/xd.c b/sys/arch/sparc/dev/xd.c index 096e3e758d7..dbdb87adbaf 100644 --- a/sys/arch/sparc/dev/xd.c +++ b/sys/arch/sparc/dev/xd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xd.c,v 1.44 2009/01/04 16:51:05 miod Exp $ */ +/* $OpenBSD: xd.c,v 1.45 2009/08/13 15:23:12 deraadt Exp $ */ /* $NetBSD: xd.c,v 1.37 1997/07/29 09:58:16 fair Exp $ */ /* @@ -296,7 +296,7 @@ xdgetdisklabel(xd, b) { struct disklabel *lp = xd->sc_dk.dk_label; struct sun_disklabel *sl = b; - char *err; + int error; bzero(lp, sizeof(struct disklabel)); /* Required parameters for readdisklabel() */ @@ -311,12 +311,10 @@ xdgetdisklabel(xd, b) /* We already have the label data in `b'; setup for dummy strategy */ xd_labeldata = b; - err = readdisklabel(MAKEDISKDEV(0, xd->sc_dev.dv_unit, RAW_PART), + error = readdisklabel(MAKEDISKDEV(0, xd->sc_dev.dv_unit, RAW_PART), xddummystrat, lp, 0); - if (err) { - /*printf("%s: %s\n", xd->sc_dev.dv_xname, err);*/ - return (XD_ERR_FAIL); - } + if (error) + return (error); /* Ok, we have the label; fill in `pcyl' if there's SunOS magic */ sl = b; @@ -336,7 +334,7 @@ xdgetdisklabel(xd, b) xd->nhead = lp->d_ntracks; xd->nsect = lp->d_nsectors; xd->sectpercyl = lp->d_secpercyl; - return (XD_ERR_AOK); + return (0); } /* diff --git a/sys/arch/sparc/dev/xy.c b/sys/arch/sparc/dev/xy.c index 4a10df3ca32..a4684a70c42 100644 --- a/sys/arch/sparc/dev/xy.c +++ b/sys/arch/sparc/dev/xy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xy.c,v 1.41 2009/01/04 16:51:05 miod Exp $ */ +/* $OpenBSD: xy.c,v 1.42 2009/08/13 15:23:12 deraadt Exp $ */ /* $NetBSD: xy.c,v 1.26 1997/07/19 21:43:56 pk Exp $ */ /* @@ -236,7 +236,7 @@ xygetdisklabel(xy, b) { struct disklabel *lp = xy->sc_dk.dk_label; struct sun_disklabel *sl = b; - char *err; + int error; bzero(lp, sizeof(struct disklabel)); /* Required parameters for readdisklabel() */ @@ -251,12 +251,10 @@ xygetdisklabel(xy, b) /* We already have the label data in `b'; setup for dummy strategy */ xy_labeldata = b; - err = readdisklabel(MAKEDISKDEV(0, xy->sc_dev.dv_unit, RAW_PART), + error = readdisklabel(MAKEDISKDEV(0, xy->sc_dev.dv_unit, RAW_PART), xydummystrat, lp, 0); - if (err) { - /*printf("%s: %s\n", xy->sc_dev.dv_xname, err);*/ - return (XY_ERR_FAIL); - } + if (error) + return (error); /* Ok, we have the label; fill in `pcyl' if there's SunOS magic */ sl = b; @@ -276,7 +274,7 @@ xygetdisklabel(xy, b) xy->nhead = lp->d_ntracks; xy->nsect = lp->d_nsectors; xy->sectpercyl = lp->d_secpercyl; - return (XY_ERR_AOK); + return (error); } /* @@ -596,7 +594,7 @@ xyattach(parent, self, aux) /* Attach the disk: must be before getdisklabel to malloc label */ disk_attach(&xy->sc_dk); - if (xygetdisklabel(xy, xa->buf) != XY_ERR_AOK) + if (xygetdisklabel(xy, xa->buf) != 0) goto done; /* inform the user of what is up */ diff --git a/sys/arch/sparc/sparc/disksubr.c b/sys/arch/sparc/sparc/disksubr.c index 2e1ee4a9dd1..94aa419edf0 100644 --- a/sys/arch/sparc/sparc/disksubr.c +++ b/sys/arch/sparc/sparc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.81 2009/06/04 21:13:02 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.82 2009/08/13 15:23:11 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.16 1996/04/28 20:25:59 thorpej Exp $ */ /* @@ -46,7 +46,7 @@ #include "cd.h" -static char *disklabel_sun_to_bsd(struct sun_disklabel *, struct disklabel *); +static int disklabel_sun_to_bsd(struct sun_disklabel *, struct disklabel *); static int disklabel_bsd_to_sun(struct disklabel *, struct sun_disklabel *); static __inline u_int sun_extended_sum(struct sun_disklabel *, void *); @@ -66,15 +66,15 @@ extern void cdstrategy(struct buf *); * * Returns null on success and an error string on failure. */ -char * +int readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, int spoofonly) { struct sun_disklabel *slp; struct buf *bp = NULL; - char *msg; + int error; - if ((msg = initdisklabel(lp))) + if ((error = initdisklabel(lp))) goto done; lp->d_flags |= D_VENDOR; @@ -87,11 +87,11 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), #if NCD > 0 if (strat == cdstrategy) { #if defined(CD9660) - if (iso_disklabelspoof(dev, strat, lp) == 0) + if ((error = iso_disklabelspoof(dev, strat, lp)) == 0) goto done; #endif #if defined(UDF) - if (udf_disklabelspoof(dev, strat, lp) == 0) + if ((error = udf_disklabelspoof(dev, strat, lp)) == 0) goto done; #endif } @@ -109,37 +109,35 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), bp->b_flags = B_BUSY | B_READ | B_RAW; (*strat)(bp); if (biowait(bp)) { - msg = "disk label read error"; + error = bp->b_error; goto done; } slp = (struct sun_disklabel *)bp->b_data; if (slp->sl_magic == SUN_DKMAGIC) { - msg = disklabel_sun_to_bsd(slp, lp); + error = disklabel_sun_to_bsd(slp, lp); goto done; } - msg = checkdisklabel(bp->b_data + LABELOFFSET, lp, 0, DL_GETDSIZE(lp)); - if (msg == NULL) + error = checkdisklabel(bp->b_data + LABELOFFSET, lp, 0, DL_GETDSIZE(lp)); + if (error == 0) goto done; doslabel: - msg = readdoslabel(bp, strat, lp, NULL, spoofonly); - if (msg == NULL) + error = readdoslabel(bp, strat, lp, NULL, spoofonly); + if (error == 0) goto done; /* A CD9660/UDF label may be on a non-CD drive, so recheck */ #if defined(CD9660) - if (iso_disklabelspoof(dev, strat, lp) == 0) { - msg = NULL; + error = iso_disklabelspoof(dev, strat, lp); + if (error == 0) goto done; - } #endif #if defined(UDF) - if (udf_disklabelspoof(dev, strat, lp) == 0) { - msg = NULL; + error = udf_disklabelspoof(dev, strat, lp); + if (error == 0) goto done; - } #endif done: @@ -147,7 +145,7 @@ done: bp->b_flags |= B_INVAL; brelse(bp); } - return (msg); + return (error); } /* @@ -234,7 +232,7 @@ sun_extended_sum(struct sun_disklabel *sl, void *end) * * The BSD label is cleared out before this is called. */ -static char * +static int disklabel_sun_to_bsd(struct sun_disklabel *sl, struct disklabel *lp) { struct sun_preamble *preamble = (struct sun_preamble *)sl; @@ -250,7 +248,7 @@ disklabel_sun_to_bsd(struct sun_disklabel *sl, struct disklabel *lp) while (sp1 < sp2) cksum ^= *sp1++; if (cksum != 0) - return ("SunOS disk label, bad checksum"); + return (EINVAL); /* SunOS disk label, bad checksum */ /* Format conversion. */ lp->d_magic = DISKMAGIC; @@ -461,7 +459,6 @@ disklabel_bsd_to_sun(struct disklabel *lp, struct sun_disklabel *sl) while (sp1 < sp2) cksum ^= *sp1++; sl->sl_cksum = cksum; - return (0); } |