summaryrefslogtreecommitdiff
path: root/sys/arch/amd64
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2015-12-24 18:03:04 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2015-12-24 18:03:04 +0000
commitb7c254243fdfd92e3402e3fe0568c409bef9b629 (patch)
tree9b9ce25150b9fd86ee19b66b461c9be62b970729 /sys/arch/amd64
parent4786a6bbe424bd70c070ca2f37c67c811ff947c1 (diff)
Make all instances of gpt_chk_mbr() identical (bar static vs
non-static) by passing disk size as 2nd parameter instead of the different structures holding the disk size info. The fifth copy of gpt_chk_mbr() in fdisk is a little specialer. No functional change.
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r--sys/arch/amd64/stand/efiboot/efidev.c11
-rw-r--r--sys/arch/amd64/stand/libsa/softraid.c10
2 files changed, 9 insertions, 12 deletions
diff --git a/sys/arch/amd64/stand/efiboot/efidev.c b/sys/arch/amd64/stand/efiboot/efidev.c
index fe798d9a92c..7f0a2e91c90 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.12 2015/12/24 14:12:43 krw Exp $ */
+/* $OpenBSD: efidev.c,v 1.13 2015/12/24 18:03:02 krw Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
@@ -63,7 +63,7 @@ static EFI_STATUS
static int efid_diskio(int, struct diskinfo *, u_int, int, void *);
static u_int findopenbsd(efi_diskinfo_t, const char **);
static uint64_t findopenbsd_gpt(efi_diskinfo_t, const char **);
-static int gpt_chk_mbr(struct dos_partition *, efi_diskinfo_t);
+static int gpt_chk_mbr(struct dos_partition *, u_int64_t);
void
efid_init(struct diskinfo *dip, void *handle)
@@ -171,10 +171,9 @@ efid_diskio(int rw, struct diskinfo *dip, u_int off, int nsect, void *buf)
* NOTE: MS always uses a size of UINT32_MAX for the EFI partition!**
*/
static int
-gpt_chk_mbr(struct dos_partition *dp, efi_diskinfo_t ed)
+gpt_chk_mbr(struct dos_partition *dp, u_int64_t dsize)
{
struct dos_partition *dp2;
- EFI_LBA dsize;
int efi, found, i;
u_int32_t psize;
@@ -185,7 +184,6 @@ gpt_chk_mbr(struct dos_partition *dp, efi_diskinfo_t ed)
found++;
if (dp2->dp_typ != DOSPTYP_EFI)
continue;
- dsize = ed->blkio->Media->LastBlock + 1;
psize = letoh32(dp2->dp_size);
if (psize == (dsize - 1) ||
psize == UINT32_MAX) {
@@ -234,7 +232,8 @@ again:
}
/* check for GPT protective MBR. */
- if (mbroff == DOSBBSECTOR && gpt_chk_mbr(mbr.dmbr_parts, ed) == 0) {
+ if (mbroff == DOSBBSECTOR && gpt_chk_mbr(mbr.dmbr_parts,
+ ed->blkio->Media->LastBlock + 1) == 0) {
gptoff = findopenbsd_gpt(ed, err);
if (gptoff > UINT_MAX || EFI_SECTOBLK(ed, gptoff) > UINT_MAX) {
*err = "Paritition LBA > 2**32";
diff --git a/sys/arch/amd64/stand/libsa/softraid.c b/sys/arch/amd64/stand/libsa/softraid.c
index 21b7289c3da..3f1d59e93a5 100644
--- a/sys/arch/amd64/stand/libsa/softraid.c
+++ b/sys/arch/amd64/stand/libsa/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.19 2015/12/24 14:12:43 krw Exp $ */
+/* $OpenBSD: softraid.c,v 1.20 2015/12/24 18:03:03 krw Exp $ */
/*
* Copyright (c) 2012 Joel Sing <jsing@openbsd.org>
@@ -46,7 +46,7 @@ struct sr_boot_keydisk {
SLIST_HEAD(sr_boot_keydisk_head, sr_boot_keydisk);
struct sr_boot_keydisk_head sr_keydisks;
-static int gpt_chk_mbr(struct dos_partition *dp, struct sr_boot_volume *bv);
+static int gpt_chk_mbr(struct dos_partition *dp, u_int64_t);
void
srprobe_meta_opt_load(struct sr_metadata *sm, struct sr_meta_opt_head *som)
@@ -408,11 +408,10 @@ sr_strategy(struct sr_boot_volume *bv, int rw, daddr32_t blk, size_t size,
* NOTE: MS always uses a size of UINT32_MAX for the EFI partition!**
*/
static int
-gpt_chk_mbr(struct dos_partition *dp, struct sr_boot_volume *bv)
+gpt_chk_mbr(struct dos_partition *dp, u_int64_t dsize)
{
struct dos_partition *dp2;
int efi, found, i;
- u_int64_t dsize;
u_int32_t psize;
found = efi = 0;
@@ -422,7 +421,6 @@ gpt_chk_mbr(struct dos_partition *dp, struct sr_boot_volume *bv)
found++;
if (dp2->dp_typ != DOSPTYP_EFI)
continue;
- dsize = bv->sbv_size;
psize = letoh32(dp2->dp_size);
if (psize == (dsize - 1) ||
psize == UINT32_MAX) {
@@ -524,7 +522,7 @@ sr_getdisklabel(struct sr_boot_volume *bv, struct disklabel *label)
/* Check for MBR to determine partition offset. */
bzero(&mbr, sizeof(mbr));
sr_strategy(bv, F_READ, DOSBBSECTOR, sizeof(mbr), &mbr, NULL);
- if (gpt_chk_mbr(mbr.dmbr_parts, bv) == 0) {
+ if (gpt_chk_mbr(mbr.dmbr_parts, bv->sbv_size) == 0) {
start = findopenbsd_gpt(bv);
} else if (mbr.dmbr_sign == DOSMBR_SIGNATURE) {