summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2013-12-28 15:05:35 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2013-12-28 15:05:35 +0000
commit4f2ff32d4ae674200b18d68e94cf6e969b22312c (patch)
treef54135d8c913e7fd3d8f0f9ced4007efab777119
parent7cdbadd75e2bd2813ae57b4bb8e96b61d8f9fae8 (diff)
Actually load the second-stage boot loader so that softraid can store it in
the softraid boot area.
-rw-r--r--usr.sbin/installboot/sparc64/sparc64_installboot.c21
-rw-r--r--usr.sbin/installboot/sparc64/sparc64_softraid.c6
2 files changed, 20 insertions, 7 deletions
diff --git a/usr.sbin/installboot/sparc64/sparc64_installboot.c b/usr.sbin/installboot/sparc64/sparc64_installboot.c
index 80549d3d150..69357e255ac 100644
--- a/usr.sbin/installboot/sparc64/sparc64_installboot.c
+++ b/usr.sbin/installboot/sparc64/sparc64_installboot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sparc64_installboot.c,v 1.2 2013/12/28 15:03:47 jsing Exp $ */
+/* $OpenBSD: sparc64_installboot.c,v 1.3 2013/12/28 15:05:34 jsing Exp $ */
/*
* Copyright (c) 2012, 2013 Joel Sing <jsing@openbsd.org>
@@ -31,7 +31,9 @@
#include "installboot.h"
char *blkstore;
+char *ldrstore;
size_t blksize;
+size_t ldrsize;
void
md_init(void)
@@ -48,11 +50,11 @@ md_loadboot(void)
size_t blocks;
int fd;
+ /* Load first-stage boot block. */
if ((fd = open(stage1, O_RDONLY)) < 0)
err(1, "open");
if (fstat(fd, &sb) == -1)
err(1, "fstat");
-
blocks = howmany((size_t)sb.st_size, DEV_BSIZE);
blksize = blocks * DEV_BSIZE;
if (verbose)
@@ -62,15 +64,26 @@ md_loadboot(void)
if (blksize > SBSIZE - DEV_BSIZE)
errx(1, "boot blocks too big (%zu > %d)",
blksize, SBSIZE - DEV_BSIZE);
-
blkstore = malloc(blksize);
if (blkstore == NULL)
err(1, "malloc");
memset(blkstore, 0, blksize);
if (read(fd, blkstore, sb.st_size) != (ssize_t)sb.st_size)
err(1, "read");
-
close(fd);
+
+ /* Load second-stage boot loader. */
+ if ((fd = open(stage2, O_RDONLY)) < 0)
+ err(1, "open");
+ if (fstat(fd, &sb) == -1)
+ err(1, "stat");
+ ldrsize = sb.st_size;
+ ldrstore = malloc(ldrsize);
+ if (ldrstore == NULL)
+ err(1, "malloc");
+ if (read(fd, ldrstore, ldrsize) != (ssize_t)sb.st_size)
+ err(1, "read");
+ close(fd);
}
void
diff --git a/usr.sbin/installboot/sparc64/sparc64_softraid.c b/usr.sbin/installboot/sparc64/sparc64_softraid.c
index 7443abd46e2..1884c4c23b0 100644
--- a/usr.sbin/installboot/sparc64/sparc64_softraid.c
+++ b/usr.sbin/installboot/sparc64/sparc64_softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sparc64_softraid.c,v 1.1 2013/12/28 14:45:57 jsing Exp $ */
+/* $OpenBSD: sparc64_softraid.c,v 1.2 2013/12/28 15:05:34 jsing Exp $ */
/*
* Copyright (c) 2012 Joel Sing <jsing@openbsd.org>
*
@@ -86,10 +86,10 @@ sr_install_bootldr(int devfd, char *dev)
* Install boot loader into softraid boot loader storage area.
*/
memset(&bb, 0, sizeof(bb));
- bb.bb_bootldr = "XXX";
- bb.bb_bootldr_size = sizeof("XXX");
bb.bb_bootblk = blkstore;
bb.bb_bootblk_size = blksize;
+ bb.bb_bootldr = ldrstore;
+ bb.bb_bootldr_size = ldrsize;
strncpy(bb.bb_dev, dev, sizeof(bb.bb_dev));
if (!nowrite) {
if (verbose)