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/macppc | |
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/macppc')
-rw-r--r-- | sys/arch/macppc/macppc/disksubr.c | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/sys/arch/macppc/macppc/disksubr.c b/sys/arch/macppc/macppc/disksubr.c index 7e04b037c19..7988eae966d 100644 --- a/sys/arch/macppc/macppc/disksubr.c +++ b/sys/arch/macppc/macppc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.66 2009/06/19 11:47:09 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.67 2009/08/13 15:23:10 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -37,7 +37,7 @@ #include <sys/disklabel.h> #include <sys/disk.h> -char *readdpmelabel(struct buf *, void (*)(struct buf *), +int readdpmelabel(struct buf *, void (*)(struct buf *), struct disklabel *, int *, int); /* @@ -58,39 +58,37 @@ char *readdpmelabel(struct buf *, void (*)(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 buf *bp = NULL; - char *msg; + int error; - if ((msg = initdisklabel(lp))) + if ((error = initdisklabel(lp))) goto done; /* get a buffer and initialize it */ bp = geteblk((int)lp->d_secsize); bp->b_dev = dev; - msg = readdpmelabel(bp, strat, lp, NULL, spoofonly); - if (msg == NULL) + error = readdpmelabel(bp, strat, lp, NULL, spoofonly); + if (error == 0) goto done; - msg = readdoslabel(bp, strat, lp, NULL, spoofonly); - if (msg == NULL) + error = readdoslabel(bp, strat, lp, NULL, spoofonly); + if (error == 0) goto done; #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: @@ -98,10 +96,10 @@ done: bp->b_flags |= B_INVAL; brelse(bp); } - return (msg); + return (error); } -char * +int readdpmelabel(struct buf *bp, void (*strat)(struct buf *), struct disklabel *lp, int *partoffp, int spoofonly) { @@ -115,13 +113,13 @@ readdpmelabel(struct buf *bp, void (*strat)(struct buf *), bp->b_flags = B_BUSY | B_READ | B_RAW; (*strat)(bp); if (biowait(bp)) - return ("DPME partition I/O error"); + return (bp->b_error); /* if successful, wander through DPME partition table */ part = (struct part_map_entry *)bp->b_data; /* if first partition is not valid, assume not HFS/DPME partitioned */ if (part->pmSig != PART_ENTRY_MAGIC) - return ("not a DPME partition"); + return (EINVAL); /* not a DPME partition */ part_cnt = part->pmMapBlkCnt; n = 8; for (i = 0; i < part_cnt; i++) { @@ -133,7 +131,7 @@ readdpmelabel(struct buf *bp, void (*strat)(struct buf *), bp->b_flags = B_BUSY | B_READ | B_RAW; (*strat)(bp); if (biowait(bp)) - return ("DPME partition I/O error"); + return (bp->b_error); part = (struct part_map_entry *)bp->b_data; /* toupper the string, in case caps are different... */ @@ -146,7 +144,7 @@ readdpmelabel(struct buf *bp, void (*strat)(struct buf *), hfspartend = hfspartoff + part->pmPartBlkCnt; if (partoffp) { *partoffp = hfspartoff; - return (NULL); + return (0); } else { DL_SETBSTART(lp, hfspartoff); DL_SETBEND(lp, @@ -171,10 +169,10 @@ readdpmelabel(struct buf *bp, void (*strat)(struct buf *), } if (hfspartoff == -1) - return ("no OpenBSD partition inside DPME label"); + return (EINVAL); /* no OpenBSD partition inside DPME label */ if (spoofonly) - return (NULL); + return (0); /* next, dig out disk label */ bp->b_blkno = hfspartoff + LABELSECTOR; @@ -182,7 +180,7 @@ readdpmelabel(struct buf *bp, void (*strat)(struct buf *), bp->b_flags = B_BUSY | B_READ | B_RAW; (*strat)(bp); if (biowait(bp)) - return("disk label I/O error"); + return(bp->b_error); if (hfspartoff == -1) hfspartoff = 0; |