summaryrefslogtreecommitdiff
path: root/sys/arch/arc
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-05-08 00:14:30 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-05-08 00:14:30 +0000
commitfb1f5450f87a91d0d2079974d96f1a7012e73816 (patch)
treece46ad8340e5976425836da92d9f36333818f517 /sys/arch/arc
parent403c57b5d698f6a7342667143a9b492e61da9ddc (diff)
sync to i386
Diffstat (limited to 'sys/arch/arc')
-rw-r--r--sys/arch/arc/arc/disksubr.c52
1 files changed, 18 insertions, 34 deletions
diff --git a/sys/arch/arc/arc/disksubr.c b/sys/arch/arc/arc/disksubr.c
index 8c12c12f1a2..d63fba7ae2c 100644
--- a/sys/arch/arc/arc/disksubr.c
+++ b/sys/arch/arc/arc/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.13 1997/04/30 08:40:15 provos Exp $ */
+/* $OpenBSD: disksubr.c,v 1.14 1997/05/08 00:14:29 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -70,6 +70,10 @@ dk_establish(dk, dev)
* table needed, attempt to extract it as well. Return buffer
* for use in signalling errors if requested.
*
+ * We would like to check if each MBR has a valid BOOT_MAGIC, but
+ * we cannot because it doesn't always exist. So.. we assume the
+ * MBR is valid.
+ *
* Returns null on success and an error string on failure.
*/
char *
@@ -110,9 +114,7 @@ readdisklabel(dev, strat, lp, osdep)
if (dp) {
daddr_t part_blkno = DOSBBSECTOR;
unsigned long extoff = 0;
- int wander = 1;
- int n = 0;
- int loop = 0;
+ int wander = 1, n = 0, loop = 0;
/*
* Read dos partition table, follow extended partitions.
@@ -120,8 +122,6 @@ readdisklabel(dev, strat, lp, osdep)
*/
while (wander && n < 8 && loop < 8) {
loop++;
-
- /* on finding a extended partition wander further */
wander = 0;
/* read boot record */
@@ -136,19 +136,10 @@ readdisklabel(dev, strat, lp, osdep)
msg = "dos partition I/O error";
goto done;
}
-
- /*
- * We would like to check if each MBR has a valid
- * BOOT_MAGIC, but we cannot because it doesn't
- * always exist. So.. we assume the MBR is valid.
- */
-
bcopy(bp->b_data + DOSPARTOFF, dp, NDOSPART * sizeof(*dp));
- /*
- * Search for our MBR partition
- */
if (ourpart == -1) {
+ /* Search for our MBR partition */
for (dp2=dp, i=0; i < NDOSPART && ourpart == -1;
i++, dp2++)
if (dp2->dp_size &&
@@ -159,15 +150,13 @@ readdisklabel(dev, strat, lp, osdep)
if (dp2->dp_size &&
dp2->dp_typ == DOSPTYP_386BSD)
ourpart = i;
- }
-
- if (ourpart != -1) {
- dp2 = &dp[ourpart];
-
+ if (ourpart == -1)
+ goto donot;
/*
* This is our MBR partition. need sector address
* for SCSI/IDE, cylinder for ESDI/ST506/RLL
*/
+ dp2 = &dp[ourpart];
dospartoff = dp2->dp_start + part_blkno;
cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect);
@@ -183,20 +172,14 @@ readdisklabel(dev, strat, lp, osdep)
lp->d_secpercyl = lp->d_ntracks *
lp->d_nsectors;
}
-
+donot:
/*
* In case the disklabel read below fails, we want to
- * provide a fake label in which m/n/o/p are MBR
- * partitions 0/1/2/3
+ * provide a fake label in i-p.
*/
- for (dp2=dp, i=0; i < NDOSPART && !wander; i++, dp2++) {
+ for (dp2=dp, i=0; i < NDOSPART && n < 8; i++, dp2++) {
struct partition *pp = &lp->d_partitions[8+n];
-/* if (dp2->dp_start + dp2->dp_size >
- lp->d_ncylinders * lp->d_secpercyl)
- continue;
-*/
-
if (dp2->dp_size)
pp->p_size = dp2->dp_size;
if (dp2->dp_start)
@@ -249,7 +232,7 @@ readdisklabel(dev, strat, lp, osdep)
lp->d_sbsize = 64*1024; /* XXX ? */
lp->d_npartitions = MAXPARTITIONS;
}
-
+
/* next, dig out disk label */
bp->b_blkno = dospartoff + LABELSECTOR;
bp->b_cylin = cyl;
@@ -378,8 +361,8 @@ setdisklabel(olp, nlp, openmask, osdep)
npp->p_cpg = opp->p_cpg;
}
}
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
+ nlp->d_checksum = 0;
+ nlp->d_checksum = dkcksum(nlp);
*olp = *nlp;
return (0);
}
@@ -387,6 +370,7 @@ setdisklabel(olp, nlp, openmask, osdep)
/*
* Write disk label back to device after modification.
+ * XXX cannot handle OpenBSD partitions in extended partitions!
*/
int
writedisklabel(dev, strat, lp, osdep)
@@ -441,7 +425,7 @@ writedisklabel(dev, strat, lp, osdep)
cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect);
}
}
-
+
/* next, dig out disk label */
bp->b_blkno = dospartoff + LABELSECTOR;
bp->b_cylin = cyl;