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:
ae 2011-05-27 06:37:42 +00:00
parent 0c3a0335f9
commit c7d08bd0ef

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_table *table;
struct g_part_mbr_entry *entry; struct g_part_mbr_entry *entry;
u_char *buf, *p; u_char *buf, *p;
off_t chs, msize; off_t chs, msize, first;
u_int sectors, heads; u_int sectors, heads;
int error, index; int error, index;
pp = cp->provider; pp = cp->provider;
table = (struct g_part_mbr_table *)basetable; table = (struct g_part_mbr_table *)basetable;
first = basetable->gpt_sectors;
msize = MIN(pp->mediasize / pp->sectorsize, UINT32_MAX); msize = MIN(pp->mediasize / pp->sectorsize, UINT32_MAX);
buf = g_read_data(cp, 0L, pp->sectorsize, &error); 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; basetable->gpt_heads = heads;
} }
} }
if (ent.dp_start < first)
first = ent.dp_start;
entry = (struct g_part_mbr_entry *)g_part_new_entry(basetable, entry = (struct g_part_mbr_entry *)g_part_new_entry(basetable,
index + 1, ent.dp_start, ent.dp_start + ent.dp_size - 1); index + 1, ent.dp_start, ent.dp_start + ent.dp_size - 1);
entry->ent = ent; 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_first = basetable->gpt_sectors;
basetable->gpt_last = msize - 1; basetable->gpt_last = msize - 1;
if (first < basetable->gpt_first)
basetable->gpt_first = 1;
g_free(buf); g_free(buf);
return (0); return (0);
} }