From owner-svn-src-head@FreeBSD.ORG Mon Dec 1 00:07:17 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EDABB1065676; Mon, 1 Dec 2008 00:07:17 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DD2688FC12; Mon, 1 Dec 2008 00:07:17 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mB107HBj006219; Mon, 1 Dec 2008 00:07:17 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mB107HW9006215; Mon, 1 Dec 2008 00:07:17 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <200812010007.mB107HW9006215@svn.freebsd.org> From: Marcel Moolenaar Date: Mon, 1 Dec 2008 00:07:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r185497 - head/sys/geom/part X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Dec 2008 00:07:18 -0000 Author: marcel Date: Mon Dec 1 00:07:17 2008 New Revision: 185497 URL: http://svn.freebsd.org/changeset/base/185497 Log: Allow boot code to be smaller than what the scheme expects. This effectively changes the boot code size to be an upper bound and makes the interface more flexible. Modified: head/sys/geom/part/g_part.c head/sys/geom/part/g_part_gpt.c head/sys/geom/part/g_part_mbr.c head/sys/geom/part/g_part_pc98.c Modified: head/sys/geom/part/g_part.c ============================================================================== --- head/sys/geom/part/g_part.c Sun Nov 30 23:46:31 2008 (r185496) +++ head/sys/geom/part/g_part.c Mon Dec 1 00:07:17 2008 (r185497) @@ -535,8 +535,8 @@ g_part_ctl_bootcode(struct gctl_req *req error = ENODEV; goto fail; } - if (gpp->gpp_codesize != sz) { - error = EINVAL; + if (gpp->gpp_codesize > sz) { + error = EFBIG; goto fail; } Modified: head/sys/geom/part/g_part_gpt.c ============================================================================== --- head/sys/geom/part/g_part_gpt.c Sun Nov 30 23:46:31 2008 (r185496) +++ head/sys/geom/part/g_part_gpt.c Mon Dec 1 00:07:17 2008 (r185497) @@ -374,9 +374,14 @@ static int g_part_gpt_bootcode(struct g_part_table *basetable, struct g_part_parms *gpp) { struct g_part_gpt_table *table; + size_t codesz; + codesz = DOSPARTOFF; table = (struct g_part_gpt_table *)basetable; - bcopy(gpp->gpp_codeptr, table->mbr, DOSPARTOFF); + bzero(table->mbr, codesz); + codesz = MIN(codesz, gpp->gpp_codesize); + if (codesz > 0) + bcopy(gpp->gpp_codeptr, table->mbr, codesz); return (0); } Modified: head/sys/geom/part/g_part_mbr.c ============================================================================== --- head/sys/geom/part/g_part_mbr.c Sun Nov 30 23:46:31 2008 (r185496) +++ head/sys/geom/part/g_part_mbr.c Mon Dec 1 00:07:17 2008 (r185497) @@ -213,9 +213,14 @@ 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; + codesz = DOSPARTOFF; table = (struct g_part_mbr_table *)basetable; - bcopy(gpp->gpp_codeptr, table->mbr, DOSPARTOFF); + bzero(table->mbr, codesz); + codesz = MIN(codesz, gpp->gpp_codesize); + if (codesz > 0) + bcopy(gpp->gpp_codeptr, table->mbr, codesz); return (0); } Modified: head/sys/geom/part/g_part_pc98.c ============================================================================== --- head/sys/geom/part/g_part_pc98.c Sun Nov 30 23:46:31 2008 (r185496) +++ head/sys/geom/part/g_part_pc98.c Mon Dec 1 00:07:17 2008 (r185497) @@ -209,9 +209,14 @@ static int g_part_pc98_bootcode(struct g_part_table *basetable, struct g_part_parms *gpp) { struct g_part_pc98_table *table; + size_t codesz; + codesz = DOSMAGICOFFSET; table = (struct g_part_pc98_table *)basetable; - bcopy(gpp->gpp_codeptr, table->boot, DOSMAGICOFFSET); + bzero(table->boot, codesz); + codesz = MIN(codesz, gpp->gpp_codesize); + if (codesz > 0) + bcopy(gpp->gpp_codeptr, table->boot, codesz); return (0); }