diff options
author | 2015-12-24 18:03:02 +0000 | |
---|---|---|
committer | 2015-12-24 18:03:02 +0000 | |
commit | 12b4e8282ec1d824e20a7e601e5f34b8cbdf239b (patch) | |
tree | ec943435f0c23cf2c695ccdd3137b1946ef69c87 | |
parent | bzero -> memset. No binary change. (diff) | |
download | wireguard-openbsd-12b4e8282ec1d824e20a7e601e5f34b8cbdf239b.tar.xz wireguard-openbsd-12b4e8282ec1d824e20a7e601e5f34b8cbdf239b.zip |
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.
-rw-r--r-- | sys/arch/amd64/stand/efiboot/efidev.c | 11 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/softraid.c | 10 | ||||
-rw-r--r-- | sys/kern/subr_disk.c | 10 | ||||
-rw-r--r-- | usr.sbin/installboot/i386_installboot.c | 10 |
4 files changed, 17 insertions, 24 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) { diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 2702b0ce248..38babce4e30 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.220 2015/09/25 11:56:21 krw Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.221 2015/12/24 18:03:03 krw Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -104,7 +104,7 @@ void disk_attach_callback(void *); int spoofgptlabel(struct buf *, void (*)(struct buf *), struct disklabel *); -int gpt_chk_mbr(struct dos_partition *, struct disklabel *); +int gpt_chk_mbr(struct dos_partition *, u_int64_t); int gpt_chk_hdr(struct gpt_header *, struct disklabel *); int gpt_chk_parts(struct gpt_header *, struct gpt_partition *); int gpt_get_fstype(struct uuid *); @@ -371,7 +371,7 @@ readdoslabel(struct buf *bp, void (*strat)(struct buf *), if (mbrtest != 0x55aa) goto notmbr; - if (gpt_chk_mbr(dp, lp) != 0) + if (gpt_chk_mbr(dp, DL_GETDSIZE(lp)) != 0) goto notgpt; gptlp = malloc(sizeof(struct disklabel), M_DEVBUF, @@ -592,10 +592,9 @@ notfat: * NOTE: MS always uses a size of UINT32_MAX for the EFI partition!** */ int -gpt_chk_mbr(struct dos_partition *dp, struct disklabel *lp) +gpt_chk_mbr(struct dos_partition *dp, u_int64_t dsize) { struct dos_partition *dp2; - u_int64_t dsize; int efi, found, i; u_int32_t psize; @@ -606,7 +605,6 @@ gpt_chk_mbr(struct dos_partition *dp, struct disklabel *lp) found++; if (dp2->dp_typ != DOSPTYP_EFI) continue; - dsize = DL_GETDSIZE(lp); psize = letoh32(dp2->dp_size); if (psize == (dsize - 1) || psize == UINT32_MAX) { diff --git a/usr.sbin/installboot/i386_installboot.c b/usr.sbin/installboot/i386_installboot.c index 933e25a4df7..b789abc911d 100644 --- a/usr.sbin/installboot/i386_installboot.c +++ b/usr.sbin/installboot/i386_installboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i386_installboot.c,v 1.23 2015/12/24 14:12:43 krw Exp $ */ +/* $OpenBSD: i386_installboot.c,v 1.24 2015/12/24 18:03:03 krw Exp $ */ /* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */ /* @@ -90,7 +90,7 @@ static void devread(int, void *, daddr_t, size_t, char *); static u_int findopenbsd(int, struct disklabel *); static int getbootparams(char *, int, struct disklabel *); static char *loadproto(char *, long *); -static int gpt_chk_mbr(struct dos_partition *, struct disklabel *); +static int gpt_chk_mbr(struct dos_partition *, u_int64_t); /* * Read information about /boot's inode and filesystem parameters, then @@ -456,10 +456,9 @@ again: * NOTE: MS always uses a size of UINT32_MAX for the EFI partition!** */ static int -gpt_chk_mbr(struct dos_partition *dp, struct disklabel *lp) +gpt_chk_mbr(struct dos_partition *dp, u_int64_t dsize) { struct dos_partition *dp2; - u_int64_t dsize; int efi, found, i; u_int32_t psize; @@ -470,7 +469,6 @@ gpt_chk_mbr(struct dos_partition *dp, struct disklabel *lp) found++; if (dp2->dp_typ != DOSPTYP_EFI) continue; - dsize = DL_GETDSIZE(lp); psize = letoh32(dp2->dp_size); if (psize == (dsize - 1) || psize == UINT32_MAX) { @@ -511,7 +509,7 @@ findgptefisys(int devfd, struct disklabel *dl) if (len != dl->d_secsize) err(4, "can't read mbr"); memcpy(dp, &secbuf[DOSPARTOFF], sizeof(dp)); - if (gpt_chk_mbr(dp, dl)) { + if (gpt_chk_mbr(dp, DL_GETDSIZE(dl))) { free(secbuf); return (-1); } |