summaryrefslogtreecommitdiff
path: root/sys/arch/mvme68k
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2009-08-13 15:23:14 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2009-08-13 15:23:14 +0000
commitcf6459c8f783ece5445be14e8e2e7201f7cd6632 (patch)
treea5a86e9615b432c0d3ef13f965013ddf06ea6bff /sys/arch/mvme68k
parent46faf138ca97f0462a1c22674098875302fe10d0 (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/mvme68k')
-rw-r--r--sys/arch/mvme68k/mvme68k/disksubr.c46
1 files changed, 19 insertions, 27 deletions
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 <sys/disklabel.h>
#include <sys/disk.h>
-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);
}