diff options
author | Toomas Soome <tsoome@me.com> | 2019-11-19 09:04:42 +0200 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2019-11-20 08:28:49 +0200 |
commit | 6b02bf31e294d16b68704ede69fdbddaf757fe30 (patch) | |
tree | ec091bb72a586e32aab76aa265a3b58d70a45b71 /usr/src | |
parent | a8661d6d41898fc90e65007115e5c3be62013bbf (diff) | |
download | illumos-joyent-6b02bf31e294d16b68704ede69fdbddaf757fe30.tar.gz |
11999 installboot: multiple stage1 locations are mismanaged
Reviewed by: Jason King <jason.king@joyent.com>
Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk>
Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/boot/installboot/i386/installboot.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/usr/src/cmd/boot/installboot/i386/installboot.c b/usr/src/cmd/boot/installboot/i386/installboot.c index 4175ac4310..50d0085be4 100644 --- a/usr/src/cmd/boot/installboot/i386/installboot.c +++ b/usr/src/cmd/boot/installboot/i386/installboot.c @@ -453,8 +453,8 @@ static bool compare_stage1_cb(struct partlist *plist) { if (write_vbr) { - (void) printf("%s will be written to %s\n", plist->pl_src_name, - plist->pl_devname); + (void) printf("%s is newer than one in %s\n", + plist->pl_src_name, plist->pl_devname); } return (write_vbr); } @@ -1993,7 +1993,29 @@ prepare_bblocks(ib_data_t *data) struct partlist *mbr, *stage1, *stage2; uuid_t uuid; + /* + * Create disk uuid. We only need reasonable amount of uniqueness + * to allow biosdev to identify disk based on mbr differences. + */ + uuid_generate(uuid); + mbr = stage1 = stage2 = NULL; + + /* First find stage 2. */ + STAILQ_FOREACH(pl, data->plist, pl_next) { + if (pl->pl_type == IB_BBLK_STAGE2) { + stage2 = pl; + + /* + * When stage2 needs update, make sure we also + * update stage1. + */ + if (pl->pl_cb.compare != NULL && + pl->pl_cb.compare(pl)) + write_vbr = true; + break; + } + } /* * Walk list and pick up BIOS boot blocks. EFI boot programs * can be set in place. @@ -2005,10 +2027,10 @@ prepare_bblocks(ib_data_t *data) break; case IB_BBLK_STAGE1: stage1 = pl; + if (stage2 != NULL) + prepare_stage1(stage1, stage2, uuid); break; case IB_BBLK_STAGE2: - stage2 = pl; - /* FALLTHROUGH */ case IB_BBLK_EFI: prepare_bootblock(data, pl, update_str); break; @@ -2021,12 +2043,6 @@ prepare_bblocks(ib_data_t *data) if (stage2 == NULL) return; - /* - * Create disk uuid. We only need reasonable amount of uniqueness - * to allow biosdev to identify disk based on mbr differences. - */ - uuid_generate(uuid); - if (mbr != NULL) { prepare_stage1(mbr, stage2, uuid); @@ -2041,10 +2057,6 @@ prepare_bblocks(ib_data_t *data) stage1->pl_device->stage.start; } } - - if (stage1 != NULL) { - prepare_stage1(stage1, stage2, uuid); - } } /* |