Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Feb 2011 13:18:00 +0000 (UTC)
From:      Takahashi Yoshihiro <nyan@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r218558 - head/sys/geom/part
Message-ID:  <201102111318.p1BDI0bN061019@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }



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