From ed13161d4d7d8aa53077f031032e1b5135150b72 Mon Sep 17 00:00:00 2001 From: kn Date: Tue, 27 Sep 2022 11:31:46 +0000 Subject: [PATCH] fix passing explicit stage files This fixes installboot regress on powerpc64. The exact same diff already landed for macppc; efi also has the same fix for md_init() but without the string handling cleanup that entails. macppc_installboot.c r1.6 "Fix passing explicit stage files": Using `stage1' leads to a bit more cleanup since early MI installboot.c handles `-r', i.e. write_filesystem() no longer has needs to do the fileprefix() dance itself. OK gkoehler --- usr.sbin/installboot/powerpc64_installboot.c | 21 ++++++-------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/usr.sbin/installboot/powerpc64_installboot.c b/usr.sbin/installboot/powerpc64_installboot.c index 602e019cafd..a8d07f0fd40 100644 --- a/usr.sbin/installboot/powerpc64_installboot.c +++ b/usr.sbin/installboot/powerpc64_installboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: powerpc64_installboot.c,v 1.6 2022/09/14 16:43:00 kn Exp $ */ +/* $OpenBSD: powerpc64_installboot.c,v 1.7 2022/09/27 11:31:46 kn Exp $ */ /* * Copyright (c) 2011 Joel Sing @@ -62,6 +62,8 @@ char duid[20]; void md_init(void) { + stages = 1; + stage1 = "/usr/mdec/boot"; } void @@ -169,12 +171,9 @@ write_filesystem(struct disklabel *dl, char part) char cmd[60]; char dir[PATH_MAX]; char dst[PATH_MAX]; - char *src; - size_t mntlen, srclen; + size_t mntlen; int rslt; - src = NULL; - /* Create directory for temporary mount point. */ strlcpy(dir, "/tmp/installboot.XXXXXXXXXX", sizeof(dst)); if (mkdtemp(dir) == NULL) @@ -232,17 +231,11 @@ write_filesystem(struct disklabel *dl, char part) warn("unable to build /boot path"); goto umount; } - src = fileprefix(root, "/usr/mdec/boot"); - if (src == NULL) { - rslt = -1; - goto umount; - } - srclen = strlen(src); if (verbose) fprintf(stderr, "%s %s to %s\n", - (nowrite ? "would copy" : "copying"), src, dst); + (nowrite ? "would copy" : "copying"), stage1, dst); if (!nowrite) { - rslt = filecopy(src, dst); + rslt = filecopy(stage1, dst); if (rslt == -1) goto umount; } @@ -286,8 +279,6 @@ rmdir: if (rmdir(dir) == -1) err(1, "rmdir('%s') failed", dir); - free(src); - if (rslt == -1) exit(1); } -- 2.20.1