NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-powerpc/39436: mkbootimag tests machine arch instead of machine



>Number:         39436
>Category:       port-powerpc
>Synopsis:       mkbootimag tests machine arch instead of machine
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-powerpc-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Aug 31 00:15:00 +0000 2008
>Originator:     Martin Husemann
>Release:        NetBSD 4.99.72
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD nightprowler.duskware.de 4.99.72 NetBSD 4.99.72 (NIGHTPROWLER) 
#1: Sun Aug 31 00:30:04 CEST 2008 
martin%night-porter.duskware.de@localhost:/usr/src/sys/arch/prep/compile/NIGHTPROWLER
 prep
Architecture: powerpc
Machine: prep
>Description:
The mkbootimage tool tries to figure out which machine it is running on via
sysctl. It useses the hw.machine_arch value, which, obviously, for all supported
machines is "powerpc" instead of the strings they are commpared against.

Using the hw.machine value instead makes it work as expected.

>How-To-Repeat:
Run /usr/mdec/mkbootimage without -m and wonder why it complains that you are
not running it on the target machine.

>Fix:
Index: mkbootimage.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/stand/mkbootimage/mkbootimage.c,v
retrieving revision 1.10
diff -c -u -r1.10 mkbootimage.c
--- mkbootimage.c       24 May 2008 17:34:03 -0000      1.10
+++ mkbootimage.c       30 Aug 2008 23:52:18 -0000
@@ -125,10 +125,10 @@
                fprintf(stderr, "\n\n");
        }
 #ifdef USE_SYSCTL
-       fprintf(stderr, "usage: %s [-lsv] [-m machine_arch] [-b bootfile] "
+       fprintf(stderr, "usage: %s [-lsv] [-m machine] [-b bootfile] "
            "[-k kernel] [-r rawdev] bootimage\n", getprogname());
 #else
-       fprintf(stderr, "usage: %s [-lsv] -m machine_arch [-b bootfile] "
+       fprintf(stderr, "usage: %s [-lsv] -m machine [-b bootfile] "
            "[-k kernel] [-r rawdev] bootimage\n", getprogname());
 #endif
        exit(1);
@@ -830,8 +830,8 @@
        char *kernel = NULL, *boot = NULL, *rawdev = NULL, *outname = NULL;
        char *march = NULL;
 #ifdef USE_SYSCTL
-       char machine_arch[SYS_NMLN];
-       int mib[2] = { CTL_HW, HW_MACHINE_ARCH };
+       char machine[SYS_NMLN];
+       int mib[2] = { CTL_HW, HW_MACHINE };
 #endif
        
        setprogname(argv[0]);
@@ -882,12 +882,12 @@
        if (march == NULL) {
                int i;
 #ifdef USE_SYSCTL
-               size_t len = sizeof(machine_arch);
+               size_t len = sizeof(machine);
 
-               if (sysctl(mib, sizeof (mib) / sizeof (mib[0]), machine_arch,
+               if (sysctl(mib, sizeof (mib) / sizeof (mib[0]), machine,
                        &len, NULL, 0) != -1) {
                        for (i=0; sup_plats[i] != NULL; i++) {
-                               if (strcmp(sup_plats[i], machine_arch) == 0) {
+                               if (strcmp(sup_plats[i], machine) == 0) {
                                        march = strdup(sup_plats[i]);
                                        break;
                                }



Home | Main Index | Thread Index | Old Index