Print this page
3788 /etc/bootrc is defunct and should be removed
fix _OBP comment in kobj_bootflags.c
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/krtld/kobj_bootflags.c
+++ new/usr/src/uts/common/krtld/kobj_bootflags.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26
27 27 #include <sys/types.h>
28 28 #include <sys/reboot.h>
29 29 #include <sys/cmn_err.h>
30 30 #include <sys/bootconf.h>
31 31 #include <sys/promif.h>
32 32 #include <sys/obpdefs.h>
33 33 #include <sys/sunddi.h>
34 34 #include <sys/systm.h>
35 35 #include <sys/kobj.h>
36 36 #include <sys/kobj_impl.h>
37 37 #include <util/getoptstr.h>
38 38
39 39 char *kobj_kmdb_argv[11]; /* 10 arguments and trailing NULL */
40 40
41 41 /*
42 42 * Parse the boot line to determine boot flags.
43 43 */
44 44 void
45 45 bootflags(struct bootops *ops)
46 46 {
47 47 struct gos_params params;
48 48 uchar_t num_O_opt = 0;
49 49 char *cp;
50 50 int c;
51 51 char scratch[BOOTARGS_MAX];
52 52
53 53 if (BOP_GETPROP(ops, "bootargs", kern_bootargs) == -1) {
↓ open down ↓ |
53 lines elided |
↑ open up ↑ |
54 54 boothowto |= RB_ASKNAME;
55 55 return;
56 56 }
57 57
58 58 (void) BOP_GETPROP(ops, "boot-file", kern_bootfile);
59 59
60 60 cp = kern_bootargs;
61 61
62 62 #if defined(_OBP)
63 63 /*
64 - * x86: The boot scripts (i.e., /etc/bootrc) don't prepend the kernel
65 - * name to the boot arguments. (And beware making it do so: if the
66 - * run-kernel command returns, it will loop, and you will end up with
67 - * multiple copies of the kernel name.)
64 + * Sparc only, _OBP isn't defined on x86 any more.
68 65 */
69 66 if (cp[0] != '-') {
70 67 /* if user booted kadb or kmdb, load kmdb */
71 68 if (cp[0] == 'k' && (cp[1] == 'a' || cp[1] == 'm') &&
72 69 cp[2] == 'd' && cp[3] == 'b' &&
73 70 (cp[4] == ' ' || cp[4] == ' ' || cp[4] == 0))
74 71 boothowto |= RB_KMDB;
75 72 SKIP_WORD(cp); /* Skip the kernel's filename. */
76 73 }
77 74 #endif
78 75 SKIP_SPC(cp);
79 76
80 77 #if defined(_OBP)
81 78 /* skip bootblk args */
82 79 params.gos_opts = "abcdDf:F:gGHhi:km:o:O:rsvVwxZ:";
83 80 #else
84 81 params.gos_opts = "abcdgGhi:km:O:rsvwx";
85 82 #endif
86 83 params.gos_strp = cp;
87 84 getoptstr_init(¶ms);
88 85 while ((c = getoptstr(¶ms)) != -1) {
89 86
90 87 switch (c) {
91 88 case 'a':
92 89 boothowto |= RB_ASKNAME;
93 90 break;
94 91 case 'b':
95 92 boothowto |= RB_NOBOOTRC;
96 93 break;
97 94 case 'c':
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
98 95 boothowto |= RB_CONFIG;
99 96 break;
100 97 case 'd':
101 98 boothowto |= RB_DEBUGENTER;
102 99 break;
103 100 #if defined(_OBP)
104 101 case 'D':
105 102 case 'F':
106 103 break;
107 104 case 'f':
108 - (void)prom_setprop(prom_optionsnode(), "diag-level",
105 + (void) prom_setprop(prom_optionsnode(), "diag-level",
109 106 (char *)params.gos_optargp,
110 107 params.gos_optarglen + 1);
111 108 break;
112 109 #endif
113 110 case 'g':
114 111 boothowto |= RB_FORTHDEBUG;
115 112 break;
116 113 case 'G':
117 114 boothowto |= RB_FORTHDEBUGDBP;
118 115 break;
119 116 case 'h':
120 117 boothowto |= RB_HALT;
121 118 break;
122 119 #if defined(_OBP)
123 120 case 'H':
124 121 break;
125 122 #endif
126 123 case 'i':
127 124 if (params.gos_optarglen + 1 > sizeof (initname)) {
128 125 _kobj_printf(ops, "krtld: initname too long. "
129 126 "Ignoring.\n");
130 127 } else {
131 128 (void) strncpy(initname, params.gos_optargp,
132 129 params.gos_optarglen);
133 130 initname[params.gos_optarglen] = '\0';
134 131 }
135 132 break;
136 133 case 'k':
137 134 boothowto |= RB_KMDB;
138 135 break;
139 136 case 'm':
140 137 if (strlen(initargs) + 3 + params.gos_optarglen + 1 >
141 138 sizeof (initargs)) {
142 139 _kobj_printf(ops,
143 140 "unix: init options too long. "
144 141 "Ignoring -m.\n");
145 142 break;
146 143 }
147 144 /* gos_optargp is not null terminated */
148 145 (void) strncpy(scratch, params.gos_optargp,
149 146 params.gos_optarglen);
150 147 scratch[params.gos_optarglen] = '\0';
151 148 (void) strlcat(initargs, "-m ", sizeof (initargs));
152 149 (void) strlcat(initargs, scratch,
153 150 sizeof (initargs));
154 151 (void) strlcat(initargs, " ", sizeof (initargs));
155 152 break;
156 153 #if defined(_OBP)
157 154 /* Ignore argument meant for wanboot standalone */
158 155 case 'o':
159 156 break;
160 157 #endif
161 158 case 'O': {
162 159 char **str = &kobj_kmdb_argv[num_O_opt];
163 160
164 161 if (++num_O_opt > (sizeof (kobj_kmdb_argv) /
165 162 sizeof (char *)) - 1) {
166 163 _kobj_printf(ops, "krtld: too many kmdb "
167 164 "options - ignoring option #%d.\n",
168 165 num_O_opt);
169 166 continue;
170 167 }
171 168
172 169 *str = kobj_alloc(params.gos_optarglen + 1, KM_TMP);
173 170 (void) strncpy(*str, params.gos_optargp,
174 171 params.gos_optarglen);
175 172 (*str)[params.gos_optarglen] = '\0';
176 173 break;
177 174 }
178 175 case 'r':
179 176 if (strlen(initargs) + 3 + 1 > sizeof (initargs)) {
180 177 _kobj_printf(ops, "unix: init options too "
181 178 "long. Ignoring -r.\n");
182 179 break;
183 180 }
184 181 boothowto |= RB_RECONFIG;
185 182 (void) strlcat(initargs, "-r ", sizeof (initargs));
186 183 break;
187 184 case 's':
188 185 if (strlen(initargs) + 3 + 1 > sizeof (initargs)) {
189 186 _kobj_printf(ops, "unix: init options too "
190 187 "long. Ignoring -s.\n");
191 188 break;
192 189 }
193 190 boothowto |= RB_SINGLE;
194 191 (void) strlcat(initargs, "-s ", sizeof (initargs));
195 192 break;
196 193 case 'v':
197 194 if (strlen(initargs) + 3 + 1 > sizeof (initargs)) {
198 195 _kobj_printf(ops, "unix: init options too "
199 196 "long. Ignoring -v.\n");
200 197 break;
201 198 }
202 199 boothowto |= RB_VERBOSE;
203 200 (void) strlcat(initargs, "-v ", sizeof (initargs));
204 201 break;
205 202 #if defined(_OBP)
206 203 case 'V':
207 204 break;
208 205 case 'Z':
209 206 break;
210 207 #endif
211 208 case 'w':
212 209 boothowto |= RB_WRITABLE;
213 210 break;
214 211 case 'x':
215 212 boothowto |= RB_NOBOOTCLUSTER;
216 213 break;
217 214 case '?':
218 215 switch (params.gos_last_opt) {
219 216 case 'i':
220 217 _kobj_printf(ops, "krtld: Required argument "
221 218 "for -i flag missing. Ignoring.\n");
222 219 break;
223 220 default:
224 221 _kobj_printf(ops, "krtld: Ignoring invalid "
225 222 "kernel option -%c.\n",
226 223 params.gos_last_opt);
227 224 }
228 225 break;
229 226 default:
230 227 _kobj_printf(ops, "krtld: Ignoring unimplemented "
231 228 "option -%c.\n", c);
232 229 }
233 230 }
234 231
235 232 if ((boothowto & (RB_DEBUGENTER | RB_KMDB)) == RB_DEBUGENTER) {
236 233 _kobj_printf(ops, "krtld: -d is not valid without -k.\n");
237 234 boothowto &= ~RB_DEBUGENTER;
238 235 }
239 236
240 237 if (*params.gos_strp) {
241 238 /* Unused arguments. */
242 239 if (params.gos_strp[0] == '-' && ISSPACE(params.gos_strp[1])) {
243 240 /*EMPTY*/
244 241 /* Lousy install arguments. Silently ignore. */
245 242 } else {
246 243 _kobj_printf(ops, "krtld: Unused kernel arguments: "
247 244 "`%s'.\n", params.gos_strp);
248 245 }
249 246 }
250 247 }
↓ open down ↓ |
132 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX