diff options
author | imp <imp@FreeBSD.org> | 2016-05-18 05:59:05 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2016-05-18 05:59:05 +0000 |
commit | aec599f958d6743505af55cdd4599840d0391f40 (patch) | |
tree | 44905bdda098b9b6efb4c45f777beb3519597cb6 /sys/boot/efi | |
parent | 2b56fc97b9eabf1a146f1a2bee438f9856ed0b7e (diff) | |
download | FreeBSD-src-aec599f958d6743505af55cdd4599840d0391f40.zip FreeBSD-src-aec599f958d6743505af55cdd4599840d0391f40.tar.gz |
Fix several instances where the boot loader ignored pager_output
return value when it could return 1 (indicating we should stop).
Fix a few instances of pager_open() / pager_close() not being called.
Actually use these routines for the environment variable printing code
I just committed.
Diffstat (limited to 'sys/boot/efi')
-rw-r--r-- | sys/boot/efi/libefi/efinet.c | 5 | ||||
-rw-r--r-- | sys/boot/efi/libefi/efipart.c | 14 | ||||
-rw-r--r-- | sys/boot/efi/loader/Makefile | 4 | ||||
-rw-r--r-- | sys/boot/efi/loader/bootinfo.c | 2 | ||||
-rw-r--r-- | sys/boot/efi/loader/main.c | 40 |
5 files changed, 48 insertions, 17 deletions
diff --git a/sys/boot/efi/libefi/efinet.c b/sys/boot/efi/libefi/efinet.c index b7888aa..4d367b5 100644 --- a/sys/boot/efi/libefi/efinet.c +++ b/sys/boot/efi/libefi/efinet.c @@ -329,9 +329,12 @@ efinet_dev_print(int verbose) EFI_HANDLE h; int unit; + pager_open(); for (unit = 0, h = efi_find_handle(&efinet_dev, 0); h != NULL; h = efi_find_handle(&efinet_dev, ++unit)) { sprintf(line, " %s%d:\n", efinet_dev.dv_name, unit); - pager_output(line); + if (pager_output(line)) + break; } + pager_close(); } diff --git a/sys/boot/efi/libefi/efipart.c b/sys/boot/efi/libefi/efipart.c index 410057c..e8691c5 100644 --- a/sys/boot/efi/libefi/efipart.c +++ b/sys/boot/efi/libefi/efipart.c @@ -180,21 +180,27 @@ efipart_print(int verbose) EFI_STATUS status; u_int unit; + pager_open(); for (unit = 0, h = efi_find_handle(&efipart_dev, 0); h != NULL; h = efi_find_handle(&efipart_dev, ++unit)) { sprintf(line, " %s%d:", efipart_dev.dv_name, unit); - pager_output(line); + if (pager_output(line)) + break; status = BS->HandleProtocol(h, &blkio_guid, (void **)&blkio); if (!EFI_ERROR(status)) { sprintf(line, " %llu blocks", (unsigned long long)(blkio->Media->LastBlock + 1)); - pager_output(line); + if (pager_output(line)) + break; if (blkio->Media->RemovableMedia) - pager_output(" (removable)"); + if (pager_output(" (removable)")) + break; } - pager_output("\n"); + if (pager_output("\n")) + break; } + pager_close(); } static int diff --git a/sys/boot/efi/loader/Makefile b/sys/boot/efi/loader/Makefile index 2d1fffa..50ba9b3 100644 --- a/sys/boot/efi/loader/Makefile +++ b/sys/boot/efi/loader/Makefile @@ -30,6 +30,10 @@ CWARNFLAGS.zfs.c+= -Wno-sign-compare CWARNFLAGS.zfs.c+= -Wno-array-bounds CWARNFLAGS.zfs.c+= -Wno-missing-prototypes .endif +# In the loader, %S is for CHAR16 strings, not wchar_t strings. This +# mismatch causes issues on some archs, so just ignore it for now. +# The printf in libstand implements CHAR16 strings always. +CWARNFLAGS.main.c+= -Wno-format # We implement a slightly non-stadard %S in that it always takes a # CHAR16 that's common in UEFI-land instaed of a wchar_t. This only diff --git a/sys/boot/efi/loader/bootinfo.c b/sys/boot/efi/loader/bootinfo.c index 1f45ea3..34892c6 100644 --- a/sys/boot/efi/loader/bootinfo.c +++ b/sys/boot/efi/loader/bootinfo.c @@ -422,7 +422,7 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp) if (dtb_size) file_addmetadata(kfp, MODINFOMD_DTBP, sizeof dtbp, &dtbp); else - pager_output("WARNING! Trying to fire up the kernel, but no " + printf("WARNING! Trying to fire up the kernel, but no " "device tree blob found!\n"); #endif file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof kernend, &kernend); diff --git a/sys/boot/efi/loader/main.c b/sys/boot/efi/loader/main.c index b3077ec..5efe631 100644 --- a/sys/boot/efi/loader/main.c +++ b/sys/boot/efi/loader/main.c @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/reboot.h> #include <sys/boot.h> +#include <inttypes.h> #include <stand.h> #include <string.h> #include <setjmp.h> @@ -649,6 +650,7 @@ command_nvram(int argc, char *argv[]) /* Initiate the search */ status = RS->GetNextVariableName(&varsz, NULL, NULL); + pager_open(); for (; status != EFI_NOT_FOUND; ) { status = RS->GetNextVariableName(&varsz, var, &varguid); //if (EFI_ERROR(status)) @@ -671,10 +673,11 @@ command_nvram(int argc, char *argv[]) printf("\\x%02x", data[i]); } } - /* XXX */ - pager_output("\n"); free(data); + if (pager_output("\n")) + break; } + pager_close(); return (CMD_OK); } @@ -761,9 +764,11 @@ efi_print_var(CHAR16 *varnamearg, EFI_GUID *matchguid, int lflag) return (CMD_ERROR); } uuid_to_string((uuid_t *)matchguid, &str, &uuid_status); - printf("%s %S=%S\n", str, varnamearg, data); + printf("%s %S=%S", str, varnamearg, data); free(str); free(data); + if (pager_output("\n")) + return (CMD_WARN); return (CMD_OK); } @@ -783,7 +788,7 @@ command_efi_printenv(int argc, char *argv[]) */ /* XXX We assume EFI_GUID is the same as uuid_t */ int aflag = 0, gflag = 0, lflag = 0, vflag = 0; - int ch; + int ch, rv; unsigned i; EFI_STATUS status; EFI_GUID varguid = { 0,0,0,{0,0,0,0,0,0,0,0} }; @@ -842,14 +847,19 @@ command_efi_printenv(int argc, char *argv[]) argc -= optind; argv += optind; - if (vflag && gflag) - return efi_print_var(varnamearg, &matchguid, lflag); + pager_open(); + if (vflag && gflag) { + rv = efi_print_var(varnamearg, &matchguid, lflag); + pager_close(); + return (rv); + } if (argc == 2) { optarg = argv[0]; if (strlen(optarg) >= nitems(varnamearg)) { printf("Variable %s is longer than %zd characters\n", optarg, nitems(varnamearg)); + pager_close(); return (CMD_ERROR); } for (i = 0; i < strlen(optarg); i++) @@ -860,13 +870,17 @@ command_efi_printenv(int argc, char *argv[]) &uuid_status); if (uuid_status != uuid_s_ok) { printf("uid %s could not be parsed\n", optarg); + pager_close(); return (CMD_ERROR); } - return efi_print_var(varnamearg, &matchguid, lflag); + rv = efi_print_var(varnamearg, &matchguid, lflag); + pager_close(); + return (rv); } if (argc != 0) { printf("Too many args\n"); + pager_close(); return (CMD_ERROR); } @@ -882,19 +896,23 @@ command_efi_printenv(int argc, char *argv[]) status = RS->GetNextVariableName(&varsz, varname, &varguid); if (aflag) { - efi_print_var(varname, &varguid, lflag); + if (efi_print_var(varname, &varguid, lflag) != CMD_OK) + break; continue; } if (vflag) { if (wcscmp(varnamearg, varname) == 0) - efi_print_var(varname, &varguid, lflag); + if (efi_print_var(varname, &varguid, lflag) != CMD_OK) + break; } if (gflag) { if (memcmp(&varguid, &matchguid, sizeof(varguid)) == 0) - efi_print_var(varname, &varguid, lflag); + if (efi_print_var(varname, &varguid, lflag) != CMD_OK) + break; } } - + pager_close(); + return (CMD_OK); } |