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/socppc | |
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/socppc')
-rw-r--r-- | sys/arch/socppc/socppc/disksubr.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/sys/arch/socppc/socppc/disksubr.c b/sys/arch/socppc/socppc/disksubr.c index 6ef5b537cd4..8bfa40dbaa4 100644 --- a/sys/arch/socppc/socppc/disksubr.c +++ b/sys/arch/socppc/socppc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.9 2009/06/19 11:47:09 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.10 2009/08/13 15:23:11 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -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,7 +113,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); /* if successful, wander through DPME partition table */ part = (struct part_map_entry *)bp->b_data; @@ -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, @@ -170,10 +168,10 @@ readdpmelabel(struct buf *bp, void (*strat)(struct buf *), } if (hfspartoff == -1) - return ("no OpenBSD partition inside DPME label"); + return (EINVAL); if (spoofonly) - return (NULL); + return (0); /* next, dig out disk label */ bp->b_blkno = hfspartoff + LABELSECTOR; @@ -181,7 +179,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); return checkdisklabel(bp->b_data + LABELOFFSET, lp, hfspartoff, hfspartend); |