Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/ofppc Fixed writing of MBR disklabel. It was writte...
details: https://anonhg.NetBSD.org/src/rev/e72f57cf581e
branches: trunk
changeset: 773464:e72f57cf581e
user: phx <phx%NetBSD.org@localhost>
date: Thu Feb 02 21:54:34 2012 +0000
description:
Fixed writing of MBR disklabel. It was written by disklabel(8) -r directly
into sector 0, corrupting the MBR. Moved to sector 1.
Removed MBR_LABELSECTOR, which is no longer needed.
diffstat:
sys/arch/ofppc/include/disklabel.h | 8 ++----
sys/arch/ofppc/ofppc/disksubr.c | 45 +++++++++++++++++++++----------------
sys/arch/ofppc/stand/ofwboot/mbr.c | 4 +-
3 files changed, 30 insertions(+), 27 deletions(-)
diffs (150 lines):
diff -r 92db60c6c04d -r e72f57cf581e sys/arch/ofppc/include/disklabel.h
--- a/sys/arch/ofppc/include/disklabel.h Thu Feb 02 20:11:26 2012 +0000
+++ b/sys/arch/ofppc/include/disklabel.h Thu Feb 02 21:54:34 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: disklabel.h,v 1.10 2011/08/30 12:39:57 bouyer Exp $ */
+/* $NetBSD: disklabel.h,v 1.11 2012/02/02 21:54:34 phx Exp $ */
/*-
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -34,10 +34,8 @@
#define _MACHINE_DISKLABEL_H_
#define LABELUSESMBR 0 /* no MBR partitionning */
-#define LABELSECTOR 0 /* sector containing label */
-#define LABELOFFSET 64 /* offset of label in sector */
-#define MBR_LABELSECTOR 1 /* label sector in MBR */
-#define MBR_LABELOFFSET 0 /* label offset in MBR */
+#define LABELSECTOR 1 /* sector containing label */
+#define LABELOFFSET 0 /* offset of label in sector */
#define MAXPARTITIONS 16 /* number of partitions */
#define RAW_PART 2 /* raw partition: xx?c */
diff -r 92db60c6c04d -r e72f57cf581e sys/arch/ofppc/ofppc/disksubr.c
--- a/sys/arch/ofppc/ofppc/disksubr.c Thu Feb 02 20:11:26 2012 +0000
+++ b/sys/arch/ofppc/ofppc/disksubr.c Thu Feb 02 21:54:34 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: disksubr.c,v 1.24 2011/10/08 06:55:19 kiyohara Exp $ */
+/* $NetBSD: disksubr.c,v 1.25 2012/02/02 21:54:34 phx Exp $ */
/*-
* Copyright (c) 2010 Frank Wille.
@@ -63,7 +63,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.24 2011/10/08 06:55:19 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.25 2012/02/02 21:54:34 phx Exp $");
#include "opt_disksubr.h"
@@ -190,8 +190,8 @@
if (2 > maxslot)
maxslot = 2;
/* read in disklabel, blkno + 1 for DOS disklabel offset */
- osdep->cd_labelsector = bsdpartoff + MBR_LABELSECTOR;
- osdep->cd_labeloffset = MBR_LABELOFFSET;
+ osdep->cd_labelsector = bsdpartoff + LABELSECTOR;
+ osdep->cd_labeloffset = LABELOFFSET;
if (read_netbsd_label(dev, strat, lp, osdep))
goto done;
msg = "no NetBSD disk label";
@@ -430,7 +430,9 @@
case ADT_NETBSDROOT:
pp = &lp->d_partitions[0];
if (pp->p_size) {
+#ifdef DIAGNOSTIC
printf("more than one root, ignoring\n");
+#endif
osdep->rdblock = RDBNULL; /* invalidate cpulab */
continue;
}
@@ -438,7 +440,9 @@
case ADT_NETBSDSWAP:
pp = &lp->d_partitions[1];
if (pp->p_size) {
+#ifdef DIAGNOSTIC
printf("more than one swap, ignoring\n");
+#endif
osdep->rdblock = RDBNULL; /* invalidate cpulab */
continue;
}
@@ -730,20 +734,6 @@
if (lp->d_secpercyl == 0) {
return msg = "Zero secpercyl";
}
- bp = geteblk((int)lp->d_secsize);
-
- bp->b_dev = dev;
- bp->b_blkno = 0;
- bp->b_resid = 0;
- bp->b_bcount = lp->d_secsize;
- bp->b_flags |= B_READ;
- bp->b_cylinder = 1 / lp->d_secpercyl;
- (*strat)(bp);
-
- if (biowait(bp)) {
- msg = "I/O error reading block zero";
- goto done;
- }
/* no valid RDB found */
osdep->rdblock = RDBNULL;
@@ -754,6 +744,21 @@
osdep->cd_labelsector = LABELSECTOR;
osdep->cd_labeloffset = LABELOFFSET;
+ bp = geteblk((int)lp->d_secsize);
+
+ bp->b_dev = dev;
+ bp->b_blkno = MBR_BBSECTOR;
+ bp->b_resid = 0;
+ bp->b_bcount = lp->d_secsize;
+ bp->b_flags |= B_READ;
+ bp->b_cylinder = MBR_BBSECTOR / lp->d_secpercyl;
+ (*strat)(bp);
+
+ if (biowait(bp)) {
+ msg = "I/O error reading block zero";
+ goto done;
+ }
+
if (bswap16(*(u_int16_t *)((char *)bp->b_data + MBR_MAGIC_OFFSET))
== MBR_MAGIC) {
/*
@@ -851,7 +856,7 @@
label = *lp;
readdisklabel(dev, strat, &label, osdep);
- /* If RDB was present, we don't support writing them yet. */
+ /* If an RDB was present, we don't support writing it yet. */
if (osdep->rdblock != RDBNULL)
return EINVAL;
@@ -859,7 +864,7 @@
bp = geteblk(lp->d_secsize);
bp->b_dev = dev;
- bp->b_blkno = osdep->cd_start + osdep->cd_labelsector;
+ bp->b_blkno = osdep->cd_labelsector;
bp->b_cylinder = bp->b_blkno / (lp->d_secsize / DEV_BSIZE) /
lp->d_secpercyl;
bp->b_bcount = lp->d_secsize;
diff -r 92db60c6c04d -r e72f57cf581e sys/arch/ofppc/stand/ofwboot/mbr.c
--- a/sys/arch/ofppc/stand/ofwboot/mbr.c Thu Feb 02 20:11:26 2012 +0000
+++ b/sys/arch/ofppc/stand/ofwboot/mbr.c Thu Feb 02 21:54:34 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mbr.c,v 1.3 2011/08/21 13:08:57 phx Exp $ */
+/* $NetBSD: mbr.c,v 1.4 2012/02/02 21:54:34 phx Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -69,7 +69,7 @@
}
#endif
if (poff != 0) {
- if (strategy(devp, F_READ, poff + MBR_LABELSECTOR, DEV_BSIZE,
+ if (strategy(devp, F_READ, poff + LABELSECTOR, DEV_BSIZE,
buf, &read) == 0 && read == DEV_BSIZE)
if (getdisklabel(buf, lp) == NULL)
return 0;
Home |
Main Index |
Thread Index |
Old Index