Don't look for GPT primary and secondary tables on a disk unless we have
a valid PMBR. Without this fix, if label a disk with a GPT, then relabel it with an MBR the GPT tables are still present. If you then try to create a GPT with 'gpt create', gpt(8) will fail to open the device because the partitions in the stale GPT overlap with the slices in the MBR. MFC after: 1 week
This commit is contained in:
parent
eb5cbaa020
commit
926f079146
@ -585,10 +585,16 @@ gpt_open(const char *dev)
|
||||
|
||||
if (gpt_mbr(fd, 0LL) == -1)
|
||||
goto close;
|
||||
if (gpt_gpt(fd, 1LL) == -1)
|
||||
goto close;
|
||||
if (gpt_gpt(fd, mediasz / secsz - 1LL) == -1)
|
||||
goto close;
|
||||
|
||||
/*
|
||||
* Don't look for a GPT unless we have a valid PMBR.
|
||||
*/
|
||||
if (map_find(MAP_TYPE_PMBR) != NULL) {
|
||||
if (gpt_gpt(fd, 1LL) == -1)
|
||||
goto close;
|
||||
if (gpt_gpt(fd, mediasz / secsz - 1LL) == -1)
|
||||
goto close;
|
||||
}
|
||||
|
||||
return (fd);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user