summaryrefslogtreecommitdiffstats
path: root/sys/arch
diff options
context:
space:
mode:
authorkn <kn@openbsd.org>2021-03-26 23:29:21 +0000
committerkn <kn@openbsd.org>2021-03-26 23:29:21 +0000
commitfcf3d43cc0b90d9e05a8e1269932955a1857612c (patch)
tree27c49bc8e78501ceb6e103db5a4a6cebee0b70ed /sys/arch
parentFix errno, merge ioctl cases (diff)
downloadwireguard-openbsd-fcf3d43cc0b90d9e05a8e1269932955a1857612c.tar.xz
wireguard-openbsd-fcf3d43cc0b90d9e05a8e1269932955a1857612c.zip
Fix "mach dtb" return code to avoid bogus boot
Bootloader command functions must return zero in case of failure, returning 1 tells the bootloader to boot the currently set kernel iamge. "machine dtb" is is the wrong way around so using it triggers a boot. Fix this and print a brief usage (like other commands such as "hexdump" do) while here. Feedback OK patrick
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/arm64/stand/efiboot/efiboot.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/arch/arm64/stand/efiboot/efiboot.c b/sys/arch/arm64/stand/efiboot/efiboot.c
index 88612206626..d8363a97cca 100644
--- a/sys/arch/arm64/stand/efiboot/efiboot.c
+++ b/sys/arch/arm64/stand/efiboot/efiboot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: efiboot.c,v 1.31 2021/03/09 21:11:24 kettenis Exp $ */
+/* $OpenBSD: efiboot.c,v 1.32 2021/03/26 23:29:21 kn Exp $ */
/*
* Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
@@ -980,24 +980,26 @@ Xdtb_efi(void)
#define O_RDONLY 0
- if (cmd.argc != 2)
- return (1);
+ if (cmd.argc != 2) {
+ printf("dtb file\n");
+ return (0);
+ }
snprintf(path, sizeof(path), "%s:%s", cmd.bootdev, cmd.argv[1]);
fd = open(path, O_RDONLY);
if (fd < 0 || fstat(fd, &sb) == -1) {
printf("cannot open %s\n", path);
- return (1);
+ return (0);
}
if (efi_memprobe_find(EFI_SIZE_TO_PAGES(sb.st_size),
0x1000, &addr) != EFI_SUCCESS) {
printf("cannot allocate memory for %s\n", path);
- return (1);
+ return (0);
}
if (read(fd, (void *)addr, sb.st_size) != sb.st_size) {
printf("cannot read from %s\n", path);
- return (1);
+ return (0);
}
fdt = (void *)addr;