Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Jun 2011 21:03:39 +0400
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        Eir Nym <eirnym@gmail.com>
Cc:        freebsd-geom@FreeBSD.org
Subject:   Re: kern/157819: [geom] gpart(8): drop serial from MBR
Message-ID:  <4DFA376B.1050502@FreeBSD.org>
In-Reply-To: <201106151620.p5FGK30l019900@freefall.freebsd.org>
References:  <201106151620.p5FGK30l019900@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig72A5EEC1FEB24F60B83A22C8
Content-Type: multipart/mixed; boundary="------------080402030101070309050707"

This is a multi-part message in MIME format.
--------------080402030101070309050707
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable

On 15.06.2011 20:20, Eir Nym wrote:
>  > The fundamental question we need to answer is this:
>  > Is the serial number a well-defined field in the MBR that is
>  > independent and unrelated to the bootcode, or not?
> =20
>  Yes, this field is defined in several documentation sources.
>  It has 6 bytes and used Windows OS as disk identifier in registry to
>  specify mount point.

As i found this field is 4 bytes only. Next 2 bytes are used by our
boot0 boot manager to keep ticks count. Can you test attached patch,
does it fix your problem?

--=20
WBR, Andrey V. Elsukov

--------------080402030101070309050707
Content-Type: text/plain;
 name="mbr_keep_dsn.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
 filename="mbr_keep_dsn.diff"

Index: head/sys/geom/part/g_part_mbr.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- head/sys/geom/part/g_part_mbr.c	(revision 223150)
+++ head/sys/geom/part/g_part_mbr.c	(working copy)
@@ -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;
+	const u_char *codeptr;
=20
-	codesz =3D DOSPARTOFF;
+	if (gpp->gpp_codesize !=3D MBRSIZE)
+		return (ENODEV);
+
 	table =3D (struct g_part_mbr_table *)basetable;
-	bzero(table->mbr, codesz);
-	codesz =3D MIN(codesz,  gpp->gpp_codesize);
-	if (codesz > 0)
-		bcopy(gpp->gpp_codeptr, table->mbr, codesz);
+	codeptr =3D gpp->gpp_codeptr;
+	bcopy(codeptr, table->mbr, DOSDSNOFF);
+	table->mbr[DOSDSNOFF + 4] =3D codeptr[DOSDSNOFF + 4];
+	table->mbr[DOSDSNOFF + 5] =3D codeptr[DOSDSNOFF + 5];
 	return (0);
 }
=20
Index: head/sys/sys/diskmbr.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- head/sys/sys/diskmbr.h	(revision 223150)
+++ head/sys/sys/diskmbr.h	(working copy)
@@ -36,6 +36,7 @@
 #include <sys/ioccom.h>
=20
 #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

--------------080402030101070309050707--

--------------enig72A5EEC1FEB24F60B83A22C8
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (FreeBSD)

iQEcBAEBAgAGBQJN+jdrAAoJEAHF6gQQyKF6AGcIAIyIvSUh3ZrXn6gCTK8+QKzV
aNqe9Zi+Vj5Gcxv7mg+N3qtLWt8wSEwO9D9Ejqsd4aZYpoQtS53zdX/7ZSMbycwv
smMKW4Sgo5lsUc6eWkJXj42ClAELdV5qQ96WaZxakR1nN1e0MNBqXIHtH9i0TRTP
DycKwaFBrvw97bE6OkhyDUj5ZtHrQoMf+3RbFa0a6MitRW1K6yD9rOh6Gd7mFHVu
REBG6xyN4BJzcNcBX4nP+uZv6VLpqahSrTlwYdeZyaa9VEI1S4mrtlcWcjzEAvRg
KvPgpz/N+AKrXSVgkbzAVq4EpUspe0fJB3l/dhiT06aivfi6F/HmRQJlMpb0Wcw=
=K6GL
-----END PGP SIGNATURE-----

--------------enig72A5EEC1FEB24F60B83A22C8--



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