From 16da400c0f2d6c351e14f6854c38f07f60e2b0e9 Mon Sep 17 00:00:00 2001 From: jsing Date: Sat, 28 Dec 2013 15:05:34 +0000 Subject: [PATCH] Actually load the second-stage boot loader so that softraid can store it in the softraid boot area. --- .../installboot/sparc64/sparc64_installboot.c | 21 +++++++++++++++---- .../installboot/sparc64/sparc64_softraid.c | 6 +++--- 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 @@ -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 * @@ -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) -- 2.20.1