1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-04 09:09:56 +00:00

Sharpen the saw:

o  Don't create an APM scheme underneath another scheme when
   the probe doesn't allow it.
o  APM uses 32-bit block numbers. Limit the scheme to 2^32-1
   blocks when the media is larger.
This commit is contained in:
Marcel Moolenaar 2009-03-27 05:35:12 +00:00
parent d24d45d9a9
commit d01a198be7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=190461

View File

@ -216,6 +216,11 @@ g_part_apm_create(struct g_part_table *basetable, struct g_part_parms *gpp)
{
struct g_provider *pp;
struct g_part_apm_table *table;
uint32_t last;
/* We don't nest, which means that our depth should be 0. */
if (basetable->gpt_depth != 0)
return (ENXIO);
table = (struct g_part_apm_table *)basetable;
pp = gpp->gpp_provider;
@ -223,12 +228,15 @@ g_part_apm_create(struct g_part_table *basetable, struct g_part_parms *gpp)
pp->mediasize < (2 + 2 * basetable->gpt_entries) * pp->sectorsize)
return (ENOSPC);
/* APM uses 32-bit LBAs. */
last = MIN(pp->mediasize / pp->sectorsize, 0xffffffff) - 1;
basetable->gpt_first = 2 + basetable->gpt_entries;
basetable->gpt_last = (pp->mediasize / pp->sectorsize) - 1;
basetable->gpt_last = last;
table->ddr.ddr_sig = APM_DDR_SIG;
table->ddr.ddr_blksize = pp->sectorsize;
table->ddr.ddr_blkcount = basetable->gpt_last + 1;
table->ddr.ddr_blkcount = last + 1;
table->self.ent_sig = APM_ENT_SIG;
table->self.ent_pmblkcnt = basetable->gpt_entries + 1;