From 9854b4eeee787d204cee94f285e0ad29ecd88566 Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Fri, 27 May 2011 06:37:42 +0000 Subject: [PATCH] Some partitioning tools may have a different opinion about disk geometry and partitions may start from withing the first track. If we found such partitions, then do not reserve space of the first track, only first sector. --- sys/geom/part/g_part_mbr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/geom/part/g_part_mbr.c b/sys/geom/part/g_part_mbr.c index 0b40366efc1c..825a10959342 100644 --- a/sys/geom/part/g_part_mbr.c +++ b/sys/geom/part/g_part_mbr.c @@ -423,12 +423,13 @@ g_part_mbr_read(struct g_part_table *basetable, struct g_consumer *cp) struct g_part_mbr_table *table; struct g_part_mbr_entry *entry; u_char *buf, *p; - off_t chs, msize; + off_t chs, msize, first; u_int sectors, heads; int error, index; pp = cp->provider; table = (struct g_part_mbr_table *)basetable; + first = basetable->gpt_sectors; msize = MIN(pp->mediasize / pp->sectorsize, UINT32_MAX); buf = g_read_data(cp, 0L, pp->sectorsize, &error); @@ -461,7 +462,8 @@ g_part_mbr_read(struct g_part_table *basetable, struct g_consumer *cp) basetable->gpt_heads = heads; } } - + if (ent.dp_start < first) + first = ent.dp_start; entry = (struct g_part_mbr_entry *)g_part_new_entry(basetable, index + 1, ent.dp_start, ent.dp_start + ent.dp_size - 1); entry->ent = ent; @@ -471,6 +473,9 @@ g_part_mbr_read(struct g_part_table *basetable, struct g_consumer *cp) basetable->gpt_first = basetable->gpt_sectors; basetable->gpt_last = msize - 1; + if (first < basetable->gpt_first) + basetable->gpt_first = 1; + g_free(buf); return (0); }