From owner-freebsd-geom@FreeBSD.ORG Thu Jun 16 17:03:50 2011 Return-Path: Delivered-To: freebsd-geom@FreeBSD.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id DE4D8106564A for ; Thu, 16 Jun 2011 17:03:50 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from [127.0.0.1] (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id 5802815507F; Thu, 16 Jun 2011 17:03:48 +0000 (UTC) Message-ID: <4DFA376B.1050502@FreeBSD.org> Date: Thu, 16 Jun 2011 21:03:39 +0400 From: "Andrey V. Elsukov" User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.17) Gecko/20110429 Thunderbird/3.1.10 MIME-Version: 1.0 To: Eir Nym References: <201106151620.p5FGK30l019900@freefall.freebsd.org> In-Reply-To: <201106151620.p5FGK30l019900@freefall.freebsd.org> X-Enigmail-Version: 1.1.2 OpenPGP: id=10C8A17A Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig72A5EEC1FEB24F60B83A22C8" Cc: freebsd-geom@FreeBSD.org Subject: Re: kern/157819: [geom] gpart(8): drop serial from MBR X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2011 17:03:51 -0000 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 =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--