From owner-svn-src-all@FreeBSD.ORG Fri Feb 11 13:18:01 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3485E1065672; Fri, 11 Feb 2011 13:18:01 +0000 (UTC) (envelope-from nyan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 098E08FC1E; Fri, 11 Feb 2011 13:18:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p1BDI034061021; Fri, 11 Feb 2011 13:18:00 GMT (envelope-from nyan@svn.freebsd.org) Received: (from nyan@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p1BDI0bN061019; Fri, 11 Feb 2011 13:18:00 GMT (envelope-from nyan@svn.freebsd.org) Message-Id: <201102111318.p1BDI0bN061019@svn.freebsd.org> From: Takahashi Yoshihiro Date: Fri, 11 Feb 2011 13:18:00 +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: r218558 - head/sys/geom/part X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Feb 2011 13:18:01 -0000 Author: nyan Date: Fri Feb 11 13:18:00 2011 New Revision: 218558 URL: http://svn.freebsd.org/changeset/base/218558 Log: Add support to write boot menu. Modified: head/sys/geom/part/g_part_pc98.c Modified: head/sys/geom/part/g_part_pc98.c ============================================================================== --- head/sys/geom/part/g_part_pc98.c Fri Feb 11 13:14:17 2011 (r218557) +++ head/sys/geom/part/g_part_pc98.c Fri Feb 11 13:18:00 2011 (r218558) @@ -46,11 +46,14 @@ __FBSDID("$FreeBSD$"); #include "g_part_if.h" #define SECSIZE 512 +#define MENUSIZE 7168 +#define BOOTSIZE 8192 struct g_part_pc98_table { struct g_part_table base; u_char boot[SECSIZE]; u_char table[SECSIZE]; + u_char menu[MENUSIZE]; }; struct g_part_pc98_entry { @@ -105,7 +108,7 @@ static struct g_part_scheme g_part_pc98_ .gps_entrysz = sizeof(struct g_part_pc98_entry), .gps_minent = NDOSPART, .gps_maxent = NDOSPART, - .gps_bootcodesz = SECSIZE, + .gps_bootcodesz = BOOTSIZE, }; G_PART_SCHEME_DECLARE(g_part_pc98); @@ -204,14 +207,16 @@ 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; + const u_char *codeptr; + + if (gpp->gpp_codesize != BOOTSIZE) + return (EINVAL); - codesz = DOSMAGICOFFSET; table = (struct g_part_pc98_table *)basetable; - bzero(table->boot, codesz); - codesz = MIN(codesz, gpp->gpp_codesize); - if (codesz > 0) - bcopy(gpp->gpp_codeptr, table->boot, codesz); + codeptr = gpp->gpp_codeptr; + bcopy(codeptr, table->boot, SECSIZE); + bcopy(codeptr + SECSIZE*2, table->menu, MENUSIZE); + return (0); } @@ -356,7 +361,7 @@ g_part_pc98_probe(struct g_part_table *t pp = cp->provider; /* Sanity-check the provider. */ - if (pp->sectorsize < SECSIZE || pp->mediasize < 2 * SECSIZE) + if (pp->sectorsize < SECSIZE || pp->mediasize < BOOTSIZE) return (ENOSPC); if (pp->sectorsize > SECSIZE) return (ENXIO); @@ -419,7 +424,7 @@ g_part_pc98_read(struct g_part_table *ba table = (struct g_part_pc98_table *)basetable; msize = pp->mediasize / SECSIZE; - buf = g_read_data(cp, 0L, 2 * SECSIZE, &error); + buf = g_read_data(cp, 0L, BOOTSIZE, &error); if (buf == NULL) return (error); @@ -427,6 +432,7 @@ g_part_pc98_read(struct g_part_table *ba bcopy(buf, table->boot, sizeof(table->boot)); bcopy(buf + SECSIZE, table->table, sizeof(table->table)); + bcopy(buf + SECSIZE*2, table->menu, sizeof(table->menu)); for (index = NDOSPART - 1; index >= 0; index--) { p = buf + SECSIZE + index * DOSPARTSIZE; @@ -567,5 +573,7 @@ g_part_pc98_write(struct g_part_table *b error = g_write_data(cp, 0, table->boot, SECSIZE); if (!error) error = g_write_data(cp, SECSIZE, table->table, SECSIZE); + if (!error) + error = g_write_data(cp, SECSIZE*2, table->menu, MENUSIZE); return (error); }