From 665557a4ec2df17cc87be2742ec0484290e93ccd Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Sun, 8 Feb 2009 23:39:30 +0000 Subject: [PATCH] Allow gpe_offset to be set by the scheme. When gpe_offset is zero, or invalid, initialize it to the start of the partition. Adjust the mediasize when the offset lies somewhere inside the partition. --- sys/geom/part/g_part.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c index ac8b3d7b1bf2..9a345bba0fb2 100644 --- a/sys/geom/part/g_part.c +++ b/sys/geom/part/g_part.c @@ -244,7 +244,8 @@ g_part_new_entry(struct g_part_table *table, int index, quad_t start, LIST_INSERT_HEAD(&table->gpt_entry, entry, gpe_entry); else LIST_INSERT_AFTER(last, entry, gpe_entry); - } + } else + entry->gpe_offset = 0; entry->gpe_start = start; entry->gpe_end = end; return (entry); @@ -257,11 +258,14 @@ g_part_new_provider(struct g_geom *gp, struct g_part_table *table, char buf[32]; struct g_consumer *cp; struct g_provider *pp; + off_t offset; cp = LIST_FIRST(&gp->consumer); pp = cp->provider; - entry->gpe_offset = entry->gpe_start * pp->sectorsize; + offset = entry->gpe_start * pp->sectorsize; + if (entry->gpe_offset < offset) + entry->gpe_offset = offset; if (entry->gpe_pp == NULL) { entry->gpe_pp = g_new_providerf(gp, "%s%s", gp->name, @@ -271,6 +275,7 @@ g_part_new_provider(struct g_geom *gp, struct g_part_table *table, entry->gpe_pp->index = entry->gpe_index - 1; /* index is 1-based. */ entry->gpe_pp->mediasize = (entry->gpe_end - entry->gpe_start + 1) * pp->sectorsize; + entry->gpe_pp->mediasize -= entry->gpe_offset - offset; entry->gpe_pp->sectorsize = pp->sectorsize; entry->gpe_pp->flags = pp->flags & G_PF_CANDELETE; if (pp->stripesize > 0) {