for (drive = 0x80; drive < 0x80 + fixed_cnt; drive++) {
if (disk_get_params(drive, &diskinfo))
continue; /* Drive doesn't exist */
- if (!(boot_part = pi_begin(&diskinfo, opt.relax)))
+ if (!(boot_part = pi_begin(&diskinfo, opt.relax | opt.prefmbr)))
continue;
/* Check for a MBR disk */
if (boot_part->type != typedos) {
for (drive = 0x80; drive < 0x80 + fixed_cnt; drive++) {
if (disk_get_params(drive, &diskinfo))
continue; /* Drive doesn't exist */
- if (!(boot_part = pi_begin(&diskinfo, opt.relax)))
+ if (!(boot_part = pi_begin(&diskinfo, opt.relax | opt.prefmbr)))
continue;
/* Check for a GPT disk */
if (boot_part->type != typegpt) {
for (drive = 0x80; drive < 0x80 + fixed_cnt; drive++) {
if (disk_get_params(drive, &diskinfo))
continue; /* Drive doesn't exist */
- if (!(boot_part = pi_begin(&diskinfo, opt.relax)))
+ if (!(boot_part = pi_begin(&diskinfo, opt.relax | opt.prefmbr)))
continue;
/* Check for a GPT disk */
if (!(boot_part->type == typegpt)) {
if (disk_get_params(drive, &diskinfo))
goto bail;
/* this will start iteration over FDD, possibly raw */
- if (!(iter = pi_begin(&diskinfo, opt.relax)))
+ if (!(iter = pi_begin(&diskinfo, opt.relax | opt.prefmbr)))
goto bail;
} else if (!strcmp(opt.drivename, "boot") || !strcmp(opt.drivename, "fs")) {
if (disk_get_params(drive, &diskinfo))
goto bail;
/* this will start iteration over disk emulation, possibly raw */
- if (!(iter = pi_begin(&diskinfo, opt.relax)))
+ if (!(iter = pi_begin(&diskinfo, opt.relax | opt.prefmbr)))
goto bail;
/* 'fs' => we should lookup the syslinux partition number and use it */
if (miter->index > 4 && !(opt.hide & HIDE_EXT))
warn("Specified partition is logical, so it can't be unhidden without 'unhideall'.");
- if (!(iter = pi_begin(&miter->di, PIF_STEPALL | opt.relax)))
+ if (!(iter = pi_begin(&miter->di, PIF_STEPALL | opt.relax | opt.prefmbr)))
return -1;
while (!pi_next(iter) && !werr) {
return -1;
}
- if (!(iter = pi_begin(&miter->di, PIF_STEPALL | opt.relax)))
+ if (!(iter = pi_begin(&miter->di, PIF_STEPALL | opt.relax | opt.prefmbr)))
return -1;
while (!pi_next(iter) && !werr) {
" warn Wait for a keypress to continue chainloading",
" break Don't chainload",
" relax Relax sanity checks",
+" prefmbr On hybrid MBR/GPT disks, prefer legacy layout",
"",
" file=<file> Load and execute <file>",
" seg=<s[:o[:i]]> Load file at <s:o>, jump to <s:i>",
opt.warn = true;
} else if (!strcmp(argv[i], "nowarn")) {
opt.warn = false;
+ } else if (!strcmp(argv[i], "prefmbr")) {
+ opt.prefmbr = PIF_PREFMBR;
+ } else if (!strcmp(argv[i], "noprefmbr")) {
+ opt.prefmbr = 0;
} else if (!strcmp(argv[i], "nobreak")) {
opt.brkchain = false;
} else if (!strcmp(argv[i], "break")) {
enum {HIDE_OFF = 0, HIDE_ON = 1, HIDE_EXT = 2, HIDE_REV = 4};
struct options {
+ const char *drivename;
+ const char *partition;
+ const char *file;
+ const char *grubcfg;
unsigned int fseg;
unsigned int foff;
unsigned int fip;
unsigned int sseg;
unsigned int soff;
unsigned int sip;
- const char *drivename;
- const char *partition;
- const char *file;
- const char *grubcfg;
+ int hide;
+ int relax;
+ int prefmbr;
+ uint16_t keeppxe;
bool isolinux;
bool cmldr;
bool drmk;
bool hand;
bool hptr;
bool swap;
- int hide;
bool sect;
bool save;
bool bss;
bool filebpb;
bool fixchs;
bool warn;
- int relax;
bool brkchain;
- uint16_t keeppxe;
struct syslinux_rm_regs regs;
};
/* pi_begin() - validate and and get proper iterator for a disk described by di */
struct part_iter *pi_begin(const struct disk_info *di, int flags)
{
- int ret = -1;
+ int gptprot, ret = -1;
struct part_iter *iter;
struct disk_dos_mbr *mbr = NULL;
struct disk_gpt_header *gpth = NULL;
}
/* Check for GPT protective MBR */
- if (mbr->table[0].ostype == 0xEE) {
+ gptprot = 0;
+ for (size_t i = 0; i < 4; i++)
+ gptprot |= (mbr->table[i].ostype == 0xEE);
+ if (gptprot && !(flags & PIF_PREFMBR)) {
if (!(gpth = disk_read_sectors(di, 1, 1))) {
error("Couldn't read potential GPT header.");
goto bail;
/* flags */
-#define PIF_STEPALL 0x01
-#define PIF_RELAX 0x02
+#define PIF_STEPALL 0b001
+#define PIF_RELAX 0b010
+#define PIF_PREFMBR 0b100
struct itertype;
struct part_iter;
This option will wait for a keypress right before continuing the chainloading.
Useful to see warnings emited by the chain module.
+ prefmbr
+ *noprefmbr
+
+In the case of presence of non-standard hybrid MBR/GPT layout, this flag makes
+chain module prefer MBR layout over GPT.
+
relax
*norelax