From f4f4f64e3442cb18743dbeb61b98684961475849 Mon Sep 17 00:00:00 2001 From: jsg Date: Thu, 26 Oct 2023 14:08:48 +0000 Subject: [PATCH] make efi_getdisklabel_cd9660() handle a block size of 512 and simplify ok yasuoka@ --- sys/arch/amd64/stand/efiboot/efidev.c | 21 ++++++--------------- sys/arch/arm64/stand/efiboot/efidev.c | 21 ++++++--------------- sys/arch/armv7/stand/efiboot/efidev.c | 21 ++++++--------------- sys/arch/riscv64/stand/efiboot/efidev.c | 21 ++++++--------------- 4 files changed, 24 insertions(+), 60 deletions(-) diff --git a/sys/arch/amd64/stand/efiboot/efidev.c b/sys/arch/amd64/stand/efiboot/efidev.c index 191113670bc..550ad12a0ae 100644 --- a/sys/arch/amd64/stand/efiboot/efidev.c +++ b/sys/arch/amd64/stand/efiboot/efidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efidev.c,v 1.41 2023/04/25 10:11:20 kn Exp $ */ +/* $OpenBSD: efidev.c,v 1.42 2023/10/26 14:08:48 jsg Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -454,23 +454,14 @@ efi_getdisklabel(efi_diskinfo_t ed, struct disklabel *label) static int efi_getdisklabel_cd9660(efi_diskinfo_t ed, struct disklabel *label) { - int off; uint8_t buf[DEV_BSIZE]; EFI_STATUS status; - for (off = 0; off < 100; off++) { - status = efid_io(F_READ, ed, - EFI_BLKSPERSEC(ed) * (16 + off), 1, buf); - if (EFI_ERROR(status)) - return (-1); - if (bcmp(buf + 1, ISO_STANDARD_ID, 5) != 0 || - buf[0] == ISO_VD_END) - return (-1); - if (buf[0] == ISO_VD_PRIMARY) - break; - } - if (off >= 100) - return (-1); + status = efid_io(F_READ, ed, 64, 1, buf); + if (EFI_ERROR(status)) + return -1; + if (buf[0] != ISO_VD_PRIMARY || bcmp(buf + 1, ISO_STANDARD_ID, 5) != 0) + return -1; /* Create an imaginary disk label */ label->d_secsize = 2048; diff --git a/sys/arch/arm64/stand/efiboot/efidev.c b/sys/arch/arm64/stand/efiboot/efidev.c index cb2ada5c907..14b4debdedc 100644 --- a/sys/arch/arm64/stand/efiboot/efidev.c +++ b/sys/arch/arm64/stand/efiboot/efidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efidev.c,v 1.12 2023/04/18 23:11:56 dlg Exp $ */ +/* $OpenBSD: efidev.c,v 1.13 2023/10/26 14:08:48 jsg Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko @@ -444,23 +444,14 @@ efi_getdisklabel(efi_diskinfo_t ed, struct disklabel *label) static int efi_getdisklabel_cd9660(efi_diskinfo_t ed, struct disklabel *label) { - int off; uint8_t buf[DEV_BSIZE]; EFI_STATUS status; - for (off = 0; off < 100; off++) { - status = efid_io(F_READ, ed, - EFI_BLKSPERSEC(ed) * (16 + off), 1, buf); - if (EFI_ERROR(status)) - return (-1); - if (bcmp(buf + 1, ISO_STANDARD_ID, 5) != 0 || - buf[0] == ISO_VD_END) - return (-1); - if (buf[0] == ISO_VD_PRIMARY) - break; - } - if (off >= 100) - return (-1); + status = efid_io(F_READ, ed, 64, 1, buf); + if (EFI_ERROR(status)) + return -1; + if (buf[0] != ISO_VD_PRIMARY || bcmp(buf + 1, ISO_STANDARD_ID, 5) != 0) + return -1; /* Create an imaginary disk label */ label->d_secsize = 2048; diff --git a/sys/arch/armv7/stand/efiboot/efidev.c b/sys/arch/armv7/stand/efiboot/efidev.c index ca1b7090026..137e6592910 100644 --- a/sys/arch/armv7/stand/efiboot/efidev.c +++ b/sys/arch/armv7/stand/efiboot/efidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efidev.c,v 1.10 2022/09/01 13:45:26 krw Exp $ */ +/* $OpenBSD: efidev.c,v 1.11 2023/10/26 14:08:48 jsg Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko @@ -444,23 +444,14 @@ efi_getdisklabel(efi_diskinfo_t ed, struct disklabel *label) static int efi_getdisklabel_cd9660(efi_diskinfo_t ed, struct disklabel *label) { - int off; uint8_t buf[DEV_BSIZE]; EFI_STATUS status; - for (off = 0; off < 100; off++) { - status = efid_io(F_READ, ed, - EFI_BLKSPERSEC(ed) * (16 + off), 1, buf); - if (EFI_ERROR(status)) - return (-1); - if (bcmp(buf + 1, ISO_STANDARD_ID, 5) != 0 || - buf[0] == ISO_VD_END) - return (-1); - if (buf[0] == ISO_VD_PRIMARY) - break; - } - if (off >= 100) - return (-1); + status = efid_io(F_READ, ed, 64, 1, buf); + if (EFI_ERROR(status)) + return -1; + if (buf[0] != ISO_VD_PRIMARY || bcmp(buf + 1, ISO_STANDARD_ID, 5) != 0) + return -1; /* Create an imaginary disk label */ label->d_secsize = 2048; diff --git a/sys/arch/riscv64/stand/efiboot/efidev.c b/sys/arch/riscv64/stand/efiboot/efidev.c index 1dd9eea7da8..db846fe8a48 100644 --- a/sys/arch/riscv64/stand/efiboot/efidev.c +++ b/sys/arch/riscv64/stand/efiboot/efidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efidev.c,v 1.4 2022/09/01 13:45:26 krw Exp $ */ +/* $OpenBSD: efidev.c,v 1.5 2023/10/26 14:08:48 jsg Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko @@ -444,23 +444,14 @@ efi_getdisklabel(efi_diskinfo_t ed, struct disklabel *label) static int efi_getdisklabel_cd9660(efi_diskinfo_t ed, struct disklabel *label) { - int off; uint8_t buf[DEV_BSIZE]; EFI_STATUS status; - for (off = 0; off < 100; off++) { - status = efid_io(F_READ, ed, - EFI_BLKSPERSEC(ed) * (16 + off), 1, buf); - if (EFI_ERROR(status)) - return (-1); - if (bcmp(buf + 1, ISO_STANDARD_ID, 5) != 0 || - buf[0] == ISO_VD_END) - return (-1); - if (buf[0] == ISO_VD_PRIMARY) - break; - } - if (off >= 100) - return (-1); + status = efid_io(F_READ, ed, 64, 1, buf); + if (EFI_ERROR(status)) + return -1; + if (buf[0] != ISO_VD_PRIMARY || bcmp(buf + 1, ISO_STANDARD_ID, 5) != 0) + return -1; /* Create an imaginary disk label */ label->d_secsize = 2048; -- 2.20.1