From owner-svn-src-stable-8@FreeBSD.ORG Thu Jul 28 09:37:03 2011 Return-Path: Delivered-To: svn-src-stable-8@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8835F1065672; Thu, 28 Jul 2011 09:37:03 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 50A288FC1D; Thu, 28 Jul 2011 09:37:01 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id MAA19274; Thu, 28 Jul 2011 12:24:43 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1QmMpe-0000nv-Ut; Thu, 28 Jul 2011 12:24:42 +0300 Message-ID: <4E312AD9.3020703@FreeBSD.org> Date: Thu, 28 Jul 2011 12:24:41 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:5.0) Gecko/20110706 Thunderbird/5.0 MIME-Version: 1.0 To: Jason Hellenthal References: <201107270410.p6R4AXc3040342@svn.freebsd.org> <20110728024007.GB55550@DataIX.net> In-Reply-To: <20110728024007.GB55550@DataIX.net> X-Enigmail-Version: 1.2pre Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "Andrey V. Elsukov" , svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, svn-src-stable-8@FreeBSD.org, svn-src-stable@FreeBSD.org Subject: Re: svn commit: r224464 - in stable/8/sys: geom/part sys X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jul 2011 09:37:03 -0000 on 28/07/2011 05:40 Jason Hellenthal said the following: > > > On Wed, Jul 27, 2011 at 04:10:33AM +0000, Andrey V. Elsukov wrote: >> 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); > > Is it known for an absolute fact that the size being written is always going > to be the size of MBRSIZE ? never less ? wouldnt ">=" greater-than or equal > make sense here ? though I would seriously doubt it needs to return on equal > too as that could be written. > >> >> - 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) > > Shit happens... any case that the product might return less than 0 causing > this to still fall through and process... ? ">" ? Not with unsigned types :-) >> + *(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 >> >> #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 -- Andriy Gapon