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.
This commit is contained in:
parent
08b6360ca3
commit
6647711279
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user