Date: Mon, 1 Dec 2008 00:07:17 +0000 (UTC) From: Marcel Moolenaar <marcel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r185497 - head/sys/geom/part Message-ID: <200812010007.mB107HW9006215@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812010007.mB107HW9006215>