summaryrefslogtreecommitdiff
path: root/sys/arch/mvme68k
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2007-05-29 05:08:21 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2007-05-29 05:08:21 +0000
commit718c8f1c45893b892977d08b340dcf99697074d3 (patch)
tree208a343033771c2864117f6ba44d29018fef79d8 /sys/arch/mvme68k
parent2adfdb5db46336bf3180da10112743e21c8c8d45 (diff)
Refactor readdisklabel() to ensure there is a single point of return, in
preparation for translating all disk labels visible to the kernel to the soon to arrive V1 format. ok otto@ deraadt@
Diffstat (limited to 'sys/arch/mvme68k')
-rw-r--r--sys/arch/mvme68k/mvme68k/disksubr.c52
1 files changed, 34 insertions, 18 deletions
diff --git a/sys/arch/mvme68k/mvme68k/disksubr.c b/sys/arch/mvme68k/mvme68k/disksubr.c
index 06c2c003e9f..1dd4d51b7b2 100644
--- a/sys/arch/mvme68k/mvme68k/disksubr.c
+++ b/sys/arch/mvme68k/mvme68k/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.37 2006/10/21 16:01:54 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.38 2007/05/29 05:08:20 krw Exp $ */
/*
* Copyright (c) 1998 Steve Murphree, Jr.
* Copyright (c) 1995 Dale Rahn.
@@ -65,7 +65,8 @@ readdisklabel(dev, strat, lp, clp, spoofonly)
struct cpu_disklabel *clp;
int spoofonly;
{
- struct buf *bp;
+ struct buf *bp = NULL;
+ char *msg = NULL;
int error, i;
/* minimal requirements for archetypal disk label */
@@ -73,8 +74,10 @@ readdisklabel(dev, strat, lp, clp, spoofonly)
lp->d_secsize = DEV_BSIZE;
if (lp->d_secperunit == 0)
lp->d_secperunit = 0x1fffffff;
- if (lp->d_secpercyl == 0)
- return ("invalid geometry");
+ if (lp->d_secpercyl == 0) {
+ msg = "invalid geometry";
+ goto done;
+ }
lp->d_npartitions = RAW_PART + 1;
for (i = 0; i < RAW_PART; i++) {
lp->d_partitions[i].p_size = 0;
@@ -86,7 +89,7 @@ readdisklabel(dev, strat, lp, clp, spoofonly)
/* don't read the on-disk label if we are in spoofed-only mode */
if (spoofonly)
- return (NULL);
+ goto done;
/* obtain buffer to probe drive with */
bp = geteblk((int)lp->d_secsize);
@@ -102,28 +105,36 @@ readdisklabel(dev, strat, lp, clp, spoofonly)
error = biowait(bp);
if (error == 0)
bcopy(bp->b_data, clp, sizeof (struct cpu_disklabel));
- bp->b_flags = B_INVAL | B_AGE | B_READ;
- brelse(bp);
- if (error)
- return ("disk label read error");
+ if (error) {
+ msg = "disk label read error";
+ goto done;
+ }
#if defined(CD9660)
- if (iso_disklabelspoof(dev, strat, lp) == 0)
- return (NULL);
+ if (iso_disklabelspoof(dev, strat, lp) == 0) {
+ msg = NULL;
+ goto done;
+ }
#endif
#if defined(UDF)
- if (udf_disklabelspoof(dev, strat, lp) == 0)
- return (NULL);
+ if (udf_disklabelspoof(dev, strat, lp) == 0) {
+ msg = NULL;
+ goto done;
+ }
#endif
- if (clp->magic1 != DISKMAGIC || clp->magic2 != DISKMAGIC)
- return ("no disk label");
+ if (clp->magic1 != DISKMAGIC || clp->magic2 != DISKMAGIC) {
+ msg = "no disk label";
+ goto done;
+ }
cputobsdlabel(lp, clp);
- if (dkcksum(lp) != 0)
- return ("disk label corrupted");
+ if (dkcksum(lp) != 0) {
+ msg = "disk label corrupted";
+ goto done;
+ }
#ifdef DEBUG
if (disksubr_debug > 0) {
@@ -131,7 +142,12 @@ readdisklabel(dev, strat, lp, clp, spoofonly)
printclp(clp, "readdisklabel:cpu label");
}
#endif
- return (NULL);
+done:
+ if (bp) {
+ bp->b_flags = B_INVAL | B_AGE | B_READ;
+ brelse(bp);
+ }
+ return (msg);
}
/*