Sun Sep 23 17:49:12 2018 UTC ()
Pull up following revision(s) (requested by tsutsui in ticket #1032):

	usr.sbin/sysinst/arch/sgimips/md.c: revision 1.5
	usr.sbin/sysinst/arch/sgimips/md.c: revision 1.6

PR port-sgimips/53583: fetch kernel name always before using it.

Make the struct utsname local to avoid future similar issues.
Make sure to install a bootloader even on upgrade installation.

 -

Fixes another part of port-sgimips/53583.
Should be pulled up (with rev 1.5) to netbsd-7 and netbsd-8.


(martin)
diff -r1.3.8.1 -r1.3.8.2 src/usr.sbin/sysinst/arch/sgimips/md.c

cvs diff -r1.3.8.1 -r1.3.8.2 src/usr.sbin/sysinst/arch/sgimips/md.c (expand / switch to unified diff)

--- src/usr.sbin/sysinst/arch/sgimips/md.c 2018/03/18 11:21:47 1.3.8.1
+++ src/usr.sbin/sysinst/arch/sgimips/md.c 2018/09/23 17:49:12 1.3.8.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: md.c,v 1.3.8.1 2018/03/18 11:21:47 martin Exp $ */ 1/* $NetBSD: md.c,v 1.3.8.2 2018/09/23 17:49:12 martin Exp $ */
2 2
3/* 3/*
4 * Copyright 1997 Piermont Information Systems Inc. 4 * Copyright 1997 Piermont Information Systems Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Based on code written by Philip A. Nelson for Piermont Information 7 * Based on code written by Philip A. Nelson for Piermont Information
8 * Systems Inc. 8 * Systems Inc.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -41,43 +41,44 @@ @@ -41,43 +41,44 @@
41#include <sys/utsname.h> 41#include <sys/utsname.h>
42#include <stdio.h> 42#include <stdio.h>
43#include <curses.h> 43#include <curses.h>
44#include <unistd.h> 44#include <unistd.h>
45#include <fcntl.h> 45#include <fcntl.h>
46#include <util.h> 46#include <util.h>
47#include <errno.h> 47#include <errno.h>
48 48
49#include "defs.h" 49#include "defs.h"
50#include "md.h" 50#include "md.h"
51#include "msg_defs.h" 51#include "msg_defs.h"
52#include "menu_defs.h" 52#include "menu_defs.h"
53 53
54struct utsname instsys; 
55 54
56void 55void
57md_init(void) 56md_init(void)
58{ 57{
59} 58}
60 59
61void 60void
62md_init_set_status(int flags) 61md_init_set_status(int flags)
63{ 62{
 63 struct utsname instsys;
 64
64 (void)flags; 65 (void)flags;
65 66
66 /* 67 /*
67 * Get the name of the Install Kernel we are running under and 68 * Get the name of the Install Kernel we are running under and
68 * enable the installation of the corresponding GENERIC kernel. 69 * enable the installation of the corresponding GENERIC kernel.
69 */ 70 */
70 uname(&instsys); 71 uname(&instsys);
71 if (strstr(instsys.version, "(INSTALL32_IP3x")) 72 if (strstr(instsys.version, "(INSTALL32_IP3x"))
72 set_kernel_set(SET_KERNEL_2); 73 set_kernel_set(SET_KERNEL_2);
73 else if (strstr(instsys.version, "(INSTALL32_IP2x")) 74 else if (strstr(instsys.version, "(INSTALL32_IP2x"))
74 set_kernel_set(SET_KERNEL_1); 75 set_kernel_set(SET_KERNEL_1);
75 else if (strstr(instsys.version, "(GENERIC32_IP12")) 76 else if (strstr(instsys.version, "(GENERIC32_IP12"))
76 set_kernel_set(SET_KERNEL_3); 77 set_kernel_set(SET_KERNEL_3);
77} 78}
78 79
79int 80int
80md_get_info(void) 81md_get_info(void)
81{ 82{
82 struct disklabel disklabel; 83 struct disklabel disklabel;
83 int fd; 84 int fd;
@@ -146,27 +147,30 @@ md_check_partitions(void) @@ -146,27 +147,30 @@ md_check_partitions(void)
146 */ 147 */
147int 148int
148md_pre_disklabel(void) 149md_pre_disklabel(void)
149{ 150{
150 return 0; 151 return 0;
151} 152}
152 153
153/* 154/*
154 * hook called after writing disklabel to new target disk. 155 * hook called after writing disklabel to new target disk.
155 */ 156 */
156int 157int
157md_post_disklabel(void) 158md_post_disklabel(void)
158{ 159{
159 if (strstr(instsys.version, "(INSTALL32_IP3x")) 160 struct utsname instsys;
 161 uname(&instsys);
 162
 163 if (strstr(instsys.version, "(INSTALL32_IP3x"))
160 return run_program(RUN_DISPLAY, 164 return run_program(RUN_DISPLAY,
161 "%s %s", "/usr/mdec/sgivol -f -w boot /usr/mdec/ip3xboot", 165 "%s %s", "/usr/mdec/sgivol -f -w boot /usr/mdec/ip3xboot",
162 pm->diskdev); 166 pm->diskdev);
163 167
164 if (strstr(instsys.version, "(INSTALL32_IP2x")) { 168 if (strstr(instsys.version, "(INSTALL32_IP2x")) {
165 run_program(RUN_DISPLAY, 169 run_program(RUN_DISPLAY,
166 "%s %s", "/usr/mdec/sgivol -f -w aoutboot /usr/mdec/aoutboot", 170 "%s %s", "/usr/mdec/sgivol -f -w aoutboot /usr/mdec/aoutboot",
167 pm->diskdev); 171 pm->diskdev);
168 return run_program(RUN_DISPLAY, 172 return run_program(RUN_DISPLAY,
169 "%s %s", "/usr/mdec/sgivol -f -w boot /usr/mdec/ip2xboot", 173 "%s %s", "/usr/mdec/sgivol -f -w boot /usr/mdec/ip2xboot",
170 pm->diskdev); 174 pm->diskdev);
171 } 175 }
172 176
@@ -184,41 +188,44 @@ md_post_newfs(void) @@ -184,41 +188,44 @@ md_post_newfs(void)
184{ 188{
185 return 0; 189 return 0;
186} 190}
187 191
188int 192int
189md_post_extract(void) 193md_post_extract(void)
190{ 194{
191 return 0; 195 return 0;
192} 196}
193 197
194void 198void
195md_cleanup_install(void) 199md_cleanup_install(void)
196{ 200{
 201 struct utsname instsys;
 202
197#ifndef DEBUG 203#ifndef DEBUG
198 enable_rc_conf(); 204 enable_rc_conf();
199#endif 205#endif
 206 uname(&instsys);
200 207
201 if (strstr(instsys.version, "(GENERIC32_IP12")) 208 if (strstr(instsys.version, "(GENERIC32_IP12"))
202 run_program(0, "/usr/mdec/sgivol -f -w netbsd %s %s", 209 run_program(0, "/usr/mdec/sgivol -f -w netbsd %s %s",
203 target_expand("/netbsd.ecoff"), pm->diskdev); 210 target_expand("/netbsd.ecoff"), pm->diskdev);
204} 211}
205 212
206int 213int
207md_pre_update(void) 214md_pre_update(void)
208{ 215{
209 return 1; 216 return 1;
210} 217}
211 218
212/* Upgrade support */ 219/* Upgrade support */
213int 220int
214md_update(void) 221md_update(void)
215{ 222{
216 md_post_newfs(); 223 md_post_disklabel();
217 return 1; 224 return 1;
218} 225}
219 226
220int 227int
221md_pre_mount() 228md_pre_mount()
222{ 229{
223 return 0; 230 return 0;
224} 231}