diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2023-10-26 14:08:49 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2023-10-26 14:08:49 +0000 |
commit | 7585f7c7763a24116db91a8ee53840501868ee76 (patch) | |
tree | fd778cd96a0ccb91d2a1135d8288f0593922ea61 | |
parent | 078f6f300e4b96bd08ea1bc819b3a12c334859cb (diff) |
make efi_getdisklabel_cd9660() handle a block size of 512 and simplify
ok yasuoka@
-rw-r--r-- | sys/arch/amd64/stand/efiboot/efidev.c | 21 | ||||
-rw-r--r-- | sys/arch/arm64/stand/efiboot/efidev.c | 21 | ||||
-rw-r--r-- | sys/arch/armv7/stand/efiboot/efidev.c | 21 | ||||
-rw-r--r-- | 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 <yasuoka@yasuoka.net> @@ -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 <yasuoka@yasuoka.net> @@ -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 <yasuoka@yasuoka.net> @@ -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; |