Using installboot in dry-run mode aka. -vn (verbose + nowrite) and first
reading "would install" followed by an "installing" made me uneasy.

Luckily, nothing was written in dry-run mode, it's just that the
softraid specific code fails to honour -n/nowrite.

So make sure it does and pull the printf out of `if (!nowrite)' so we
see the "would install" messages in dry-run mode in the first place.

Here are the output diffs from all three supported softraid platforms,
i.e. EFI/arm64, i386/amd64 and sparc64, illustrate the change.

Feedback? OK?

|-# installboot -nv sd1
|+# ./obj/installboot -nv sd1
| would install bootstrap on /dev/rsd1c
| using first-stage /usr/mdec/biosboot, second-stage /usr/mdec/boot
| sd1: softraid volume with 1 disk(s)
|+sd1: would install boot loader on softraid volume
| /usr/mdec/boot is 6 blocks x 16384 bytes
|-sd0a: installing boot blocks on /dev/rsd0c, part offset 144
|+sd0a: would install boot blocks on /dev/rsd0c, part offset 144
| master boot record (MBR) at sector 0
|       partition 3: type 0xA6 offset 64 size 488392001
| /usr/mdec/biosboot will be written at sector 64

|-# installboot -nv sd6
|+# ./obj/installboot -nv sd6
| using first-stage /usr/mdec/bootblk, second-stage /usr/mdec/ofwboot
| boot block is 6888 bytes (14 blocks @ 512 bytes = 7168 bytes)
| sd6: softraid volume with 4 disk(s)
|-sd2a: installing boot blocks on /dev/rsd2c
|+sd6: would install boot loader on softraid volume
|+sd2a: would install boot blocks on /dev/rsd2c
| would write boot block to disk /dev/rsd2c
|-sd3a: installing boot blocks on /dev/rsd3c
|+sd3a: would install boot blocks on /dev/rsd3c
| would write boot block to disk /dev/rsd3c
| softraid chunk 2 not online - skipping...
| softraid chunk 3 not online - skipping...

|-# installboot -nv sd4
|+# ./obj/installboot -nv sd4
| Using / as root
| would install bootstrap on /dev/rsd4c
| sd4: softraid volume with 3 disk(s)
|-sd1a: installing boot blocks on /dev/rsd1c
|-would copy /usr/mdec/BOOTAA64.EFI to 
/tmp/installboot.6CIpogjEIX/efi/boot/bootaa64.efi
|-would write /tmp/installboot.6CIpogjEIX/efi/boot/startup.nsh
|-sd2a: installing boot blocks on /dev/rsd2c
|-would copy /usr/mdec/BOOTAA64.EFI to 
/tmp/installboot.iavORNgJs8/efi/boot/bootaa64.efi
|-would write /tmp/installboot.iavORNgJs8/efi/boot/startup.nsh
|-sd3a: installing boot blocks on /dev/rsd3c
|-would copy /usr/mdec/BOOTAA64.EFI to 
/tmp/installboot.vhlivYeWae/efi/boot/bootaa64.efi
|-would write /tmp/installboot.vhlivYeWae/efi/boot/startup.nsh
|+sd1a: would install boot blocks on /dev/rsd1c
|+would copy /usr/mdec/BOOTAA64.EFI to 
/tmp/installboot.GH19kPb4Lg/efi/boot/bootaa64.efi
|+would write /tmp/installboot.GH19kPb4Lg/efi/boot/startup.nsh
|+sd2a: would install boot blocks on /dev/rsd2c
|+would copy /usr/mdec/BOOTAA64.EFI to 
/tmp/installboot.EzcdxwQjsb/efi/boot/bootaa64.efi
|+would write /tmp/installboot.EzcdxwQjsb/efi/boot/startup.nsh
|+sd3a: would install boot blocks on /dev/rsd3c
|+would copy /usr/mdec/BOOTAA64.EFI to 
/tmp/installboot.sQOCDpqxHn/efi/boot/bootaa64.efi
|+would write /tmp/installboot.sQOCDpqxHn/efi/boot/startup.nsh

Index: efi_softraid.c
===================================================================
RCS file: /cvs/src/usr.sbin/installboot/efi_softraid.c,v
retrieving revision 1.1
diff -u -p -r1.1 efi_softraid.c
--- efi_softraid.c      15 Aug 2022 17:06:43 -0000      1.1
+++ efi_softraid.c      28 Aug 2022 08:39:05 -0000
@@ -67,8 +67,8 @@ sr_install_bootblk(int devfd, int vol, i
                err(1, "open: %s", realdev);
 
        if (verbose)
-               fprintf(stderr, "%s%c: installing boot blocks on %s\n",
-                   bd.bd_vendor, part, realdev);
+               fprintf(stderr, "%s%c: %s boot blocks on %s\n", bd.bd_vendor,
+                   part, (nowrite ? "would install" : "installing"), realdev);
 
        /* Write boot blocks to device. */
        md_installboot(diskfd, realdev);
Index: i386_softraid.c
===================================================================
RCS file: /cvs/src/usr.sbin/installboot/i386_softraid.c,v
retrieving revision 1.18
diff -u -p -r1.18 i386_softraid.c
--- i386_softraid.c     24 Oct 2021 21:24:18 -0000      1.18
+++ i386_softraid.c     28 Aug 2022 08:40:33 -0000
@@ -102,8 +102,9 @@ sr_install_bootblk(int devfd, int vol, i
        sym_set_value(pbr_symbols, "_p_offset", poffset);
 
        if (verbose)
-               fprintf(stderr, "%s%c: installing boot blocks on %s, "
-                   "part offset %u\n", bd.bd_vendor, part, dev, poffset);
+               fprintf(stderr, "%s%c: %s boot blocks on %s, part offset %u\n",
+                   bd.bd_vendor, part,
+                   (nowrite ? "would install" : "installing"), dev, poffset);
 
        /* Write boot blocks to device. */
        write_bootblocks(diskfd, dev, &dl);
@@ -172,10 +173,10 @@ sr_install_bootldr(int devfd, char *dev)
        bb.bb_bootblk = "XXX";
        bb.bb_bootblk_size = sizeof("XXX");
        strncpy(bb.bb_dev, dev, sizeof(bb.bb_dev));
+       if (verbose)
+               fprintf(stderr, "%s: %s boot loader on softraid volume\n", dev,
+                   (nowrite ? "would install" : "installing"));
        if (!nowrite) {
-               if (verbose)
-                       fprintf(stderr, "%s: installing boot loader on "
-                           "softraid volume\n", dev);
                if (ioctl(devfd, BIOCINSTALLBOOT, &bb) == -1)
                        errx(1, "softraid installboot failed");
                sr_status(&bb.bb_bio.bio_status);
Index: sparc64_softraid.c
===================================================================
RCS file: /cvs/src/usr.sbin/installboot/sparc64_softraid.c,v
retrieving revision 1.5
diff -u -p -r1.5 sparc64_softraid.c
--- sparc64_softraid.c  8 Jun 2020 19:17:12 -0000       1.5
+++ sparc64_softraid.c  28 Aug 2022 08:39:23 -0000
@@ -68,8 +68,8 @@ sr_install_bootblk(int devfd, int vol, i
                err(1, "open: %s", realdev);
 
        if (verbose)
-               fprintf(stderr, "%s%c: installing boot blocks on %s\n",
-                   bd.bd_vendor, part, realdev);
+               fprintf(stderr, "%s%c: %s boot blocks on %s\n", bd.bd_vendor,
+                   part, (nowrite ? "would install" : "installing"), realdev);
 
        /* Write boot blocks to device. */
        md_installboot(diskfd, realdev);
@@ -91,10 +91,10 @@ sr_install_bootldr(int devfd, char *dev)
        bb.bb_bootldr = ldrstore;
        bb.bb_bootldr_size = ldrsize;
        strncpy(bb.bb_dev, dev, sizeof(bb.bb_dev));
+       if (verbose)
+               fprintf(stderr, "%s: %s boot loader on softraid volume\n", dev,
+                   (nowrite ? "would install" : "installing"));
        if (!nowrite) {
-               if (verbose)
-                       fprintf(stderr, "%s: installing boot loader on "
-                           "softraid volume\n", dev);
                if (ioctl(devfd, BIOCINSTALLBOOT, &bb) == -1)
                        errx(1, "softraid installboot failed");
                sr_status(&bb.bb_bio.bio_status);

Reply via email to