aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Moolenaar <marcel@FreeBSD.org>2008-12-01 00:07:17 +0000
committerMarcel Moolenaar <marcel@FreeBSD.org>2008-12-01 00:07:17 +0000
commit6647711279c8c2412cd3797fa68fbb51cc5ff1c3 (patch)
tree51f00ee526991c6876f648de4469a77f37b7579a
parent08b6360ca3462bcd825290754478c0071fa8d739 (diff)
downloadsrc-6647711279c8c2412cd3797fa68fbb51cc5ff1c3.tar.gz
src-6647711279c8c2412cd3797fa68fbb51cc5ff1c3.zip
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.
Notes
Notes: svn path=/head/; revision=185497
-rw-r--r--sys/geom/part/g_part.c4
-rw-r--r--sys/geom/part/g_part_gpt.c7
-rw-r--r--sys/geom/part/g_part_mbr.c7
-rw-r--r--sys/geom/part/g_part_pc98.c7
4 files changed, 20 insertions, 5 deletions
diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c
index 71c0b05cce07..ad8495694140 100644
--- a/sys/geom/part/g_part.c
+++ b/sys/geom/part/g_part.c
@@ -535,8 +535,8 @@ g_part_ctl_bootcode(struct gctl_req *req, struct g_part_parms *gpp)
error = ENODEV;
goto fail;
}
- if (gpp->gpp_codesize != sz) {
- error = EINVAL;
+ if (gpp->gpp_codesize > sz) {
+ error = EFBIG;
goto fail;
}
diff --git a/sys/geom/part/g_part_gpt.c b/sys/geom/part/g_part_gpt.c
index 7bdfa077fcb2..13a45617434b 100644
--- a/sys/geom/part/g_part_gpt.c
+++ b/sys/geom/part/g_part_gpt.c
@@ -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);
}
diff --git a/sys/geom/part/g_part_mbr.c b/sys/geom/part/g_part_mbr.c
index 9e3e809c7d51..b0ba3231f7fa 100644
--- a/sys/geom/part/g_part_mbr.c
+++ b/sys/geom/part/g_part_mbr.c
@@ -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);
}
diff --git a/sys/geom/part/g_part_pc98.c b/sys/geom/part/g_part_pc98.c
index 2b997bcad5fb..f0f14747eca7 100644
--- a/sys/geom/part/g_part_pc98.c
+++ b/sys/geom/part/g_part_pc98.c
@@ -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);
}