limine-deploy: Auto set an MBR partition as active if none found

This commit is contained in:
mintsuki 2022-04-15 16:40:37 +02:00
parent 98b54eaf25
commit 3baa802ff6

View File

@ -506,6 +506,25 @@ int main(int argc, char *argv[]) {
goto cleanup;
}
bool any_active = false;
uint8_t hint8;
device_read(&hint8, 446, sizeof(uint8_t));
any_active = any_active ? any_active : (hint8 & 0x80) != 0;
device_read(&hint8, 462, sizeof(uint8_t));
any_active = any_active ? any_active : (hint8 & 0x80) != 0;
device_read(&hint8, 478, sizeof(uint8_t));
any_active = any_active ? any_active : (hint8 & 0x80) != 0;
device_read(&hint8, 494, sizeof(uint8_t));
any_active = any_active ? any_active : (hint8 & 0x80) != 0;
if (!any_active) {
fprintf(stderr, "No active MBR partition found, some systems may not boot.\n");
fprintf(stderr, "Setting partition 1 as active to work around the issue...\n");
hint8 = 0x80;
device_write(&hint8, 446, sizeof(uint8_t));
}
size_t stage2_size = bootloader_file_size - 512;
size_t stage2_sects = DIV_ROUNDUP(stage2_size, 512);