From 7528d680d9d77e95509b6cafb0554c9117024149 Mon Sep 17 00:00:00 2001 From: stsp Date: Sun, 25 Oct 2015 21:21:15 +0000 Subject: [PATCH] Fix installboot(8) on i386/amd64 when softraid is on top of GPT. ok krw deraadt --- usr.sbin/installboot/i386_installboot.c | 5 ++--- usr.sbin/installboot/i386_installboot.h | 3 ++- usr.sbin/installboot/i386_softraid.c | 8 +++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/usr.sbin/installboot/i386_installboot.c b/usr.sbin/installboot/i386_installboot.c index 0369cb9515c..be0f42c6fc2 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.14 2015/10/18 17:24:25 rpe Exp $ */ +/* $OpenBSD: i386_installboot.c,v 1.15 2015/10/25 21:21:15 stsp Exp $ */ /* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */ /* @@ -88,7 +88,6 @@ struct sym_data pbr_symbols[] = { static void devread(int, void *, daddr_t, size_t, char *); static u_int findopenbsd(int, struct disklabel *); -static int findgptefisys(int, struct disklabel *); static int getbootparams(char *, int, struct disklabel *); static char *loadproto(char *, long *); @@ -448,7 +447,7 @@ again: return ((u_int)-1); } -static int +int findgptefisys(int devfd, struct disklabel *dl) { struct gpt_partition gp[NGPTPARTITIONS]; diff --git a/usr.sbin/installboot/i386_installboot.h b/usr.sbin/installboot/i386_installboot.h index fcb09f772a3..315e19279af 100644 --- a/usr.sbin/installboot/i386_installboot.h +++ b/usr.sbin/installboot/i386_installboot.h @@ -1,4 +1,4 @@ -/* $OpenBSD: i386_installboot.h,v 1.3 2015/10/07 03:06:46 krw Exp $ */ +/* $OpenBSD: i386_installboot.h,v 1.4 2015/10/25 21:21:15 stsp Exp $ */ /* * Copyright (c) 2011 Joel Sing * Copyright (c) 2010 Otto Moerbeek @@ -55,4 +55,5 @@ int nlist_elf32(const char *, struct nlist *); void pbr_set_symbols(char *, char *, struct sym_data *); void sym_set_value(struct sym_data *, char *, u_int32_t); void write_bootblocks(int, char *, struct disklabel *); +int findgptefisys(int, struct disklabel *); void write_efisystem(struct disklabel *, char); diff --git a/usr.sbin/installboot/i386_softraid.c b/usr.sbin/installboot/i386_softraid.c index 9a943c99aee..ff3d10c41b6 100644 --- a/usr.sbin/installboot/i386_softraid.c +++ b/usr.sbin/installboot/i386_softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i386_softraid.c,v 1.4 2015/10/03 16:56:52 krw Exp $ */ +/* $OpenBSD: i386_softraid.c,v 1.5 2015/10/25 21:21:15 stsp Exp $ */ /* * Copyright (c) 2012 Joel Sing * @@ -87,6 +87,12 @@ sr_install_bootblk(int devfd, int vol, int disk) if (dl.d_type == 0) warnx("disklabel type unknown"); + part = findgptefisys(diskfd, &dl); + if (part != -1) { + write_efisystem(&dl, (char)part); + return; + } + /* Determine poffset and set symbol value. */ pp = &dl.d_partitions[part - 'a']; if (pp->p_offseth != 0) -- 2.20.1