Fri Aug 24 23:19:42 2018 UTC ()
If the boot device could not be determined, use the first one found as
the default. While here, remove unnecessary calls to LibFileSystemInfo().


(jmcneill)
diff -r1.1 -r1.2 src/sys/stand/efiboot/efifile.c

cvs diff -r1.1 -r1.2 src/sys/stand/efiboot/efifile.c (expand / switch to unified diff)

--- src/sys/stand/efiboot/efifile.c 2018/08/24 02:01:06 1.1
+++ src/sys/stand/efiboot/efifile.c 2018/08/24 23:19:42 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: efifile.c,v 1.1 2018/08/24 02:01:06 jmcneill Exp $ */ 1/* $NetBSD: efifile.c,v 1.2 2018/08/24 23:19:42 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2018 Jared McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2018 Jared McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -52,46 +52,43 @@ efi_file_parse(const char *fname, UINTN  @@ -52,46 +52,43 @@ efi_file_parse(const char *fname, UINTN
52 } else if (efi_bootvol != -1) { 52 } else if (efi_bootvol != -1) {
53 *pvol = efi_bootvol; 53 *pvol = efi_bootvol;
54 *pfile = fname; 54 *pfile = fname;
55 } else { 55 } else {
56 return EINVAL; 56 return EINVAL;
57 } 57 }
58 58
59 return 0; 59 return 0;
60} 60}
61 61
62void 62void
63efi_file_system_probe(void) 63efi_file_system_probe(void)
64{ 64{
65 EFI_FILE_SYSTEM_INFO *fsi; 
66 EFI_FILE_HANDLE fh; 65 EFI_FILE_HANDLE fh;
67 EFI_STATUS status; 66 EFI_STATUS status;
68 int n; 67 int n;
69 68
70 status = LibLocateHandle(ByProtocol, &FileSystemProtocol, NULL, &efi_nvol, &efi_vol); 69 status = LibLocateHandle(ByProtocol, &FileSystemProtocol, NULL, &efi_nvol, &efi_vol);
71 if (EFI_ERROR(status)) 70 if (EFI_ERROR(status))
72 return; 71 return;
73 72
74 for (n = 0; n < efi_nvol; n++) { 73 for (n = 0; n < efi_nvol; n++) {
75 fh = LibOpenRoot(efi_vol[n]); 74 fh = LibOpenRoot(efi_vol[n]);
76 if (!fh) 75 if (!fh)
77 continue; 76 continue;
78 77
79 fsi = LibFileSystemInfo(fh); 
80 if (!fsi) 
81 continue; 
82 
83 if (efi_bootdp && LibMatchDevicePaths(DevicePathFromHandle(efi_vol[n]), efi_bootdp) == TRUE) 78 if (efi_bootdp && LibMatchDevicePaths(DevicePathFromHandle(efi_vol[n]), efi_bootdp) == TRUE)
84 efi_bootvol = n; 79 efi_bootvol = n;
 80 else if (efi_bootdp == NULL && efi_bootvol == -1)
 81 efi_bootvol = n;
85 } 82 }
86} 83}
87 84
88int 85int
89efi_file_open(struct open_file *f, ...) 86efi_file_open(struct open_file *f, ...)
90{ 87{
91 EFI_DEVICE_PATH *dp; 88 EFI_DEVICE_PATH *dp;
92 SIMPLE_READ_FILE srf; 89 SIMPLE_READ_FILE srf;
93 EFI_HANDLE device, file; 90 EFI_HANDLE device, file;
94 EFI_STATUS status; 91 EFI_STATUS status;
95 UINTN vol; 92 UINTN vol;
96 const char *fname, *path; 93 const char *fname, *path;
97 CHAR16 *upath; 94 CHAR16 *upath;