From cf6459c8f783ece5445be14e8e2e7201f7cd6632 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Thu, 13 Aug 2009 15:23:14 +0000 Subject: 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 --- sys/arch/mvme68k/mvme68k/disksubr.c | 46 +++++++++++++++---------------------- 1 file changed, 19 insertions(+), 27 deletions(-) (limited to 'sys/arch/mvme68k') diff --git a/sys/arch/mvme68k/mvme68k/disksubr.c b/sys/arch/mvme68k/mvme68k/disksubr.c index bb66ddd730e..12e444a4059 100644 --- a/sys/arch/mvme68k/mvme68k/disksubr.c +++ b/sys/arch/mvme68k/mvme68k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.64 2009/06/04 21:57:56 miod Exp $ */ +/* $OpenBSD: disksubr.c,v 1.65 2009/08/13 15:23:10 deraadt Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1995 Dale Rahn. @@ -33,8 +33,8 @@ #include #include -void bsdtocpulabel(struct disklabel *, struct mvmedisklabel *); -void cputobsdlabel(struct disklabel *, struct mvmedisklabel *); +void bsdtocpulabel(struct disklabel *, struct mvmedisklabel *); +int cputobsdlabel(struct disklabel *, struct mvmedisklabel *); /* * Attempt to read a disk label from a device @@ -45,16 +45,14 @@ void cputobsdlabel(struct disklabel *, struct mvmedisklabel *); * 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; - struct mvmedisklabel *mlp; int error; - char *msg; - if ((msg = initdisklabel(lp))) + if ((error = initdisklabel(lp))) goto done; /* get a buffer and initialize it */ @@ -69,34 +67,24 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), bp->b_bcount = lp->d_secsize; bp->b_flags = B_BUSY | B_READ | B_RAW; (*strat)(bp); - error = biowait(bp); - if (error) { - msg = "disk label read error"; - goto done; - } - - mlp = (struct mvmedisklabel *)bp->b_data; - if (mlp->magic1 != DISKMAGIC || mlp->magic2 != DISKMAGIC) { - msg = "no disk label"; + if (biowait(bp)) { + error = bp->b_error; goto done; } - cputobsdlabel(lp, mlp); - if (dkcksum(lp) == 0) + error = cputobsdlabel(lp, (struct mvmedisklabel *)bp->b_data); + if (error == 0) goto done; - msg = "disk label corrupted"; #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: @@ -104,7 +92,7 @@ done: bp->b_flags |= B_INVAL; brelse(bp); } - return (msg); + return (error); } /* @@ -194,11 +182,14 @@ bsdtocpulabel(struct disklabel *lp, struct mvmedisklabel *clp) *mot++ = *id++; } -void +int cputobsdlabel(struct disklabel *lp, struct mvmedisklabel *clp) { int i; + if (clp->magic1 != DISKMAGIC || clp->magic2 != DISKMAGIC) + return (EINVAL); /* no disk label */ + lp->d_magic = clp->magic1; lp->d_type = clp->type; lp->d_subtype = clp->subtype; @@ -246,4 +237,5 @@ cputobsdlabel(struct disklabel *lp, struct mvmedisklabel *clp) lp->d_version = 1; lp->d_checksum = 0; lp->d_checksum = dkcksum(lp); + return (0); } -- cgit v1.2.3