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?

loongson needs the same fix.

I can't test this myself but am confident enough that it will fix
        installboot $disk ./boot
on loongson, just like on the other architectures.


Index: loongson_installboot.c
===================================================================
RCS file: /cvs/src/usr.sbin/installboot/loongson_installboot.c,v
retrieving revision 1.6
diff -u -p -r1.6 loongson_installboot.c
--- loongson_installboot.c      11 Sep 2022 07:38:33 -0000      1.6
+++ loongson_installboot.c      13 Sep 2022 20:20:39 -0000
@@ -60,6 +60,8 @@ static int    findmbrfat(int, struct diskla
 void
 md_init(void)
 {
+       stages = 1;
+       stage1 = "/usr/mdec/boot";
 }
 
 void
@@ -104,12 +106,9 @@ write_filesystem(struct disklabel *dl, c
        struct ufs_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)
@@ -195,17 +194,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;
        }
@@ -222,8 +215,6 @@ rmdir:
        dst[mntlen] = '\0';
        if (rmdir(dst) == -1)
                err(1, "rmdir('%s') failed", dst);
-
-       free(src);
 
        if (rslt == -1)
                exit(1);

Reply via email to