On Sat, Jul 29, 2017 at 02:59:19PM +0200, Mark Kettenis wrote:
> This is apparently very hard. Caught this on arm64 where
> efi_device_path_depth() returned 0, which resulted in always selecting
> the first device. Clearly if the first path component (i = 0) matches
> the desired type, we should return 1, not 0. Here is the amd64
> version of the diff which is easier to test for people.
>
> ok?
God damn, this feels like the tenth time this thing has to be fixed up.
Fix looks good to me, please commit that on arm64 and armv7 as well.
ok patrick@
>
>
> Index: arch/amd64/stand/efiboot/conf.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/amd64/stand/efiboot/conf.c,v
> retrieving revision 1.8
> diff -u -p -r1.8 conf.c
> --- arch/amd64/stand/efiboot/conf.c 1 Jun 2017 11:32:15 -0000 1.8
> +++ arch/amd64/stand/efiboot/conf.c 29 Jul 2017 12:54:10 -0000
> @@ -38,7 +38,7 @@
> #include "efiboot.h"
> #include "efidev.h"
>
> -const char version[] = "3.33";
> +const char version[] = "3.34";
>
> #ifdef EFI_DEBUG
> int debug = 0;
> Index: arch/amd64/stand/efiboot/efiboot.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/amd64/stand/efiboot/efiboot.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 efiboot.c
> --- arch/amd64/stand/efiboot/efiboot.c 1 Jun 2017 11:32:15 -0000
> 1.20
> +++ arch/amd64/stand/efiboot/efiboot.c 29 Jul 2017 12:54:10 -0000
> @@ -222,7 +222,7 @@ efi_device_path_depth(EFI_DEVICE_PATH *d
>
> for (i = 0; !IsDevicePathEnd(dp); dp = NextDevicePathNode(dp), i++) {
> if (DevicePathType(dp) == dptype)
> - return (i);
> + return (i + 1);
> }
>
> return (-1);
>