summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2011-06-27 10:42:06 +0000
committerae <ae@FreeBSD.org>2011-06-27 10:42:06 +0000
commitc7b111bbcf014d13ab4bcabf0d7e68e5f9a5e5b7 (patch)
treeb49b13b4cca427e8f68ef329fbd7a69156ad7c2f /sys/geom
parentbfdf57abb6fca38cfaa291a8949cf125eb2912f2 (diff)
downloadFreeBSD-src-c7b111bbcf014d13ab4bcabf0d7e68e5f9a5e5b7.zip
FreeBSD-src-c7b111bbcf014d13ab4bcabf0d7e68e5f9a5e5b7.tar.gz
MS Windows NT+ uses 4 bytes at offset 0x1b8 in the MBR to identify
disk drive. The boot0cfg(8) utility preserves these 4 bytes when is writing bootcode to keep a multiboot ability. Change gpart's bootcode method to keep DSN if it is not zero. Also do not allow writing bootcode with size not equal to MBRSIZE. PR: kern/157819 Tested by: Eir Nym MFC after: 1 month
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/part/g_part_mbr.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/geom/part/g_part_mbr.c b/sys/geom/part/g_part_mbr.c
index 825a109..bebdfee 100644
--- a/sys/geom/part/g_part_mbr.c
+++ b/sys/geom/part/g_part_mbr.c
@@ -237,14 +237,16 @@ static int
g_part_mbr_bootcode(struct g_part_table *basetable, struct g_part_parms *gpp)
{
struct g_part_mbr_table *table;
- size_t codesz;
+ uint32_t dsn;
+
+ if (gpp->gpp_codesize != MBRSIZE)
+ return (ENODEV);
- codesz = DOSPARTOFF;
table = (struct g_part_mbr_table *)basetable;
- bzero(table->mbr, codesz);
- codesz = MIN(codesz, gpp->gpp_codesize);
- if (codesz > 0)
- bcopy(gpp->gpp_codeptr, table->mbr, codesz);
+ dsn = *(uint32_t *)(table->mbr + DOSDSNOFF);
+ bcopy(gpp->gpp_codeptr, table->mbr, DOSPARTOFF);
+ if (dsn != 0)
+ *(uint32_t *)(table->mbr + DOSDSNOFF) = dsn;
return (0);
}
OpenPOWER on IntegriCloud