On Mon, Sep 12, 2022 at 12:37:53PM +0000, Klemens Nanni wrote:
> This fixes installboot regress on powerpc64, forgot to send it earlier.
>
> The same diff already landed for macppc; efi already the same fix
> md_init() but without the cleanup that entails for macppc and powerpc64.
>
> From 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?
Same story/diff for octeon.
Index: octeon_installboot.c
===================================================================
RCS file: /cvs/src/usr.sbin/installboot/octeon_installboot.c,v
retrieving revision 1.6
diff -u -p -r1.6 octeon_installboot.c
--- octeon_installboot.c 9 Sep 2022 15:53:16 -0000 1.6
+++ octeon_installboot.c 12 Sep 2022 12:39:57 -0000
@@ -61,6 +61,8 @@ static int findmbrfat(int, struct diskla
void
md_init(void)
{
+ stages = 1;
+ stage1 = "/usr/mdec/boot";
}
void
@@ -164,12 +166,9 @@ write_filesystem(struct disklabel *dl, c
struct msdosfs_args args;
char cmd[60];
char dst[PATH_MAX];
- char *src;
- size_t mntlen, pathlen, srclen;
+ size_t mntlen, pathlen;
int rslt;
- src = NULL;
-
/* Create directory for temporary mount point. */
strlcpy(dst, "/tmp/installboot.XXXXXXXXXX", sizeof(dst));
if (mkdtemp(dst) == NULL)
@@ -231,17 +230,11 @@ write_filesystem(struct disklabel *dl, c
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;
}
@@ -258,8 +251,6 @@ rmdir:
dst[mntlen] = '\0';
if (rmdir(dst) == -1)
err(1, "rmdir('%s') failed", dst);
-
- free(src);
if (rslt == -1)
exit(1);