Every platform ought to set `stages', `stage1' and optionally `stage2'
in md_init(), otherwise passing explicit files results won't work as
`stages' is zero-initialised and no default path is set:

        # installboot -v sd0 /root/BOOTAA64.EFI
        usage: installboot [-npv] [-r root] disk [stage1]

This is correct synopsis and ought to work, but efi_installboot.c has
an empty md_init().

Set stage bits for EFI platforms (armv7, arm64 and riscv64) to fix this:

        # ./obj/installboot -nv sd0 /root/BOOTAA64.EFI
        Using / as root
        would install bootstrap on /dev/rsd0c
        using first-stage /root/BOOTAA64.EFI
        would copy /root/BOOTAA64.EFI to 
/tmp/installboot.2bGhLGT1eF/efi/boot/bootaa64.efi
        would write /tmp/installboot.2bGhLGT1eF/efi/boot/startup.nsh

/usr/src/distrib/ uses `-r /mnt' without explicit stage files, which is
install media work despite this bug.

These usages keep working with this diff (/mnt is another root install):
        # ./obj/installboot sd4 /usr/mdec/BOOTAA64.EFI
        # ./obj/installboot -r /mnt sd4 /usr/mdec/BOOTAA64.EFI
        # ./obj/installboot -r /mnt sd4

And arm64 miniroot keeps booting and installs/ugprades fine with this.

I've only tested this on arm64 but it should be the same for other EFIs
(armv7 and riscv64);  this just looks like an oversight.

Feedback? OK?


Index: efi_installboot.c
===================================================================
RCS file: /cvs/src/usr.sbin/installboot/efi_installboot.c,v
retrieving revision 1.2
diff -u -p -r1.2 efi_installboot.c
--- efi_installboot.c   3 Feb 2022 10:25:14 -0000       1.2
+++ efi_installboot.c   28 Aug 2022 10:20:52 -0000
@@ -76,6 +76,8 @@ static int    findmbrfat(int, struct diskla
 void
 md_init(void)
 {
+       stages = 1;
+       stage1 = "/usr/mdec/" BOOTEFI_SRC;
 }
 
 void

Reply via email to