Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Jul 2011 04:10:33 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r224464 - in stable/8/sys: geom/part sys
Message-ID:  <201107270410.p6R4AXc3040342@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Wed Jul 27 04:10:32 2011
New Revision: 224464
URL: http://svn.freebsd.org/changeset/base/224464

Log:
  MFC r223587:
    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 it 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

Modified:
  stable/8/sys/geom/part/g_part_mbr.c
  stable/8/sys/sys/diskmbr.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/geom/label/   (props changed)

Modified: stable/8/sys/geom/part/g_part_mbr.c
==============================================================================
--- stable/8/sys/geom/part/g_part_mbr.c	Wed Jul 27 01:57:24 2011	(r224463)
+++ stable/8/sys/geom/part/g_part_mbr.c	Wed Jul 27 04:10:32 2011	(r224464)
@@ -234,14 +234,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);
 }
 

Modified: stable/8/sys/sys/diskmbr.h
==============================================================================
--- stable/8/sys/sys/diskmbr.h	Wed Jul 27 01:57:24 2011	(r224463)
+++ stable/8/sys/sys/diskmbr.h	Wed Jul 27 04:10:32 2011	(r224464)
@@ -36,6 +36,7 @@
 #include <sys/ioccom.h>
 
 #define	DOSBBSECTOR	0	/* DOS boot block relative sector number */
+#define	DOSDSNOFF	440	/* WinNT/2K/XP Drive Serial Number offset */
 #define	DOSPARTOFF	446
 #define	DOSPARTSIZE	16
 #define	NDOSPART	4



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107270410.p6R4AXc3040342>