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.
This commit is contained in:
Andrey V. Elsukov 2011-05-27 06:37:42 +00:00
parent df697aa015
commit 9854b4eeee

View File

@ -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);
}