summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2020-08-26 22:27:02 +0000
committerkettenis <kettenis@openbsd.org>2020-08-26 22:27:02 +0000
commitad5cc0520b6241130c5909b1827899a5d2bd802b (patch)
treec2b8ee7b9806e265735004c0c0b156f2e77a0139
parentReset the Rx block ack session counter when an iwm/iwx interface disassociates (diff)
downloadwireguard-openbsd-ad5cc0520b6241130c5909b1827899a5d2bd802b.tar.xz
wireguard-openbsd-ad5cc0520b6241130c5909b1827899a5d2bd802b.zip
Improve detection of the proper boot device by picking the disk that
matches the bootduid of the boot kernel. ok visa@
-rw-r--r--sys/arch/powerpc64/stand/rdboot/disk.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/sys/arch/powerpc64/stand/rdboot/disk.c b/sys/arch/powerpc64/stand/rdboot/disk.c
index 73298dd165f..ad548994bcd 100644
--- a/sys/arch/powerpc64/stand/rdboot/disk.c
+++ b/sys/arch/powerpc64/stand/rdboot/disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disk.c,v 1.1 2020/07/16 19:48:58 kettenis Exp $ */
+/* $OpenBSD: disk.c,v 1.2 2020/08/26 22:27:02 kettenis Exp $ */
/*
* Copyright (c) 2019 Visa Hankala
@@ -45,6 +45,7 @@ void
disk_init(void)
{
char rootdevs[1024];
+ char bootduid[17];
char *devname, *disknames, *ptr;
size_t size;
int mib[2];
@@ -76,6 +77,11 @@ disk_init(void)
return;
}
+ snprintf(bootduid, sizeof(bootduid),
+ "%02x%02x%02x%02x%02x%02x%02x%02x", cmd.bootduid[0],
+ cmd.bootduid[1], cmd.bootduid[2], cmd.bootduid[3], cmd.bootduid[4],
+ cmd.bootduid[5], cmd.bootduid[6], cmd.bootduid[7]);
+
printf("probing disks\n");
rootdevs[0] = '\0';
ptr = disknames;
@@ -91,6 +97,13 @@ disk_init(void)
if (strlen(duid) == 0)
continue;
+ /* If we have a bootduid match, nail it down! */
+ if (strcmp(duid, bootduid) == 0) {
+ snprintf(cmd.bootdev, sizeof(cmd.bootdev),
+ "%sa", devname);
+ }
+
+ /* Otherwise pick the first potential root disk. */
if (disk_proberoot(devname)) {
if (strlen(cmd.bootdev) == 0) {
snprintf(cmd.bootdev, sizeof(cmd.bootdev),