Print this page
3788 /etc/bootrc is defunct and should be removed
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 + * x86: The boot scripts don't prepend the kernel name to the boot
65 + * arguments. (And beware making it do so: if the run-kernel command
66 + * returns, it will loop, and you will end up with multiple copies
67 + * of the kernel name.)
68 68 */
69 69 if (cp[0] != '-') {
70 70 /* if user booted kadb or kmdb, load kmdb */
71 71 if (cp[0] == 'k' && (cp[1] == 'a' || cp[1] == 'm') &&
72 72 cp[2] == 'd' && cp[3] == 'b' &&
73 73 (cp[4] == ' ' || cp[4] == ' ' || cp[4] == 0))
74 74 boothowto |= RB_KMDB;
75 75 SKIP_WORD(cp); /* Skip the kernel's filename. */
76 76 }
77 77 #endif
78 78 SKIP_SPC(cp);
79 79
80 80 #if defined(_OBP)
81 81 /* skip bootblk args */
82 82 params.gos_opts = "abcdDf:F:gGHhi:km:o:O:rsvVwxZ:";
83 83 #else
84 84 params.gos_opts = "abcdgGhi:km:O:rsvwx";
85 85 #endif
86 86 params.gos_strp = cp;
87 87 getoptstr_init(¶ms);
88 88 while ((c = getoptstr(¶ms)) != -1) {
89 89
90 90 switch (c) {
91 91 case 'a':
92 92 boothowto |= RB_ASKNAME;
93 93 break;
94 94 case 'b':
95 95 boothowto |= RB_NOBOOTRC;
96 96 break;
97 97 case 'c':
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
98 98 boothowto |= RB_CONFIG;
99 99 break;
100 100 case 'd':
101 101 boothowto |= RB_DEBUGENTER;
102 102 break;
103 103 #if defined(_OBP)
104 104 case 'D':
105 105 case 'F':
106 106 break;
107 107 case 'f':
108 - (void)prom_setprop(prom_optionsnode(), "diag-level",
108 + (void) prom_setprop(prom_optionsnode(), "diag-level",
109 109 (char *)params.gos_optargp,
110 110 params.gos_optarglen + 1);
111 111 break;
112 112 #endif
113 113 case 'g':
114 114 boothowto |= RB_FORTHDEBUG;
115 115 break;
116 116 case 'G':
117 117 boothowto |= RB_FORTHDEBUGDBP;
118 118 break;
119 119 case 'h':
120 120 boothowto |= RB_HALT;
121 121 break;
122 122 #if defined(_OBP)
123 123 case 'H':
124 124 break;
125 125 #endif
126 126 case 'i':
127 127 if (params.gos_optarglen + 1 > sizeof (initname)) {
128 128 _kobj_printf(ops, "krtld: initname too long. "
129 129 "Ignoring.\n");
130 130 } else {
131 131 (void) strncpy(initname, params.gos_optargp,
132 132 params.gos_optarglen);
133 133 initname[params.gos_optarglen] = '\0';
134 134 }
135 135 break;
136 136 case 'k':
137 137 boothowto |= RB_KMDB;
138 138 break;
139 139 case 'm':
140 140 if (strlen(initargs) + 3 + params.gos_optarglen + 1 >
141 141 sizeof (initargs)) {
142 142 _kobj_printf(ops,
143 143 "unix: init options too long. "
144 144 "Ignoring -m.\n");
145 145 break;
146 146 }
147 147 /* gos_optargp is not null terminated */
148 148 (void) strncpy(scratch, params.gos_optargp,
149 149 params.gos_optarglen);
150 150 scratch[params.gos_optarglen] = '\0';
151 151 (void) strlcat(initargs, "-m ", sizeof (initargs));
152 152 (void) strlcat(initargs, scratch,
153 153 sizeof (initargs));
154 154 (void) strlcat(initargs, " ", sizeof (initargs));
155 155 break;
156 156 #if defined(_OBP)
157 157 /* Ignore argument meant for wanboot standalone */
158 158 case 'o':
159 159 break;
160 160 #endif
161 161 case 'O': {
162 162 char **str = &kobj_kmdb_argv[num_O_opt];
163 163
164 164 if (++num_O_opt > (sizeof (kobj_kmdb_argv) /
165 165 sizeof (char *)) - 1) {
166 166 _kobj_printf(ops, "krtld: too many kmdb "
167 167 "options - ignoring option #%d.\n",
168 168 num_O_opt);
169 169 continue;
170 170 }
171 171
172 172 *str = kobj_alloc(params.gos_optarglen + 1, KM_TMP);
173 173 (void) strncpy(*str, params.gos_optargp,
174 174 params.gos_optarglen);
175 175 (*str)[params.gos_optarglen] = '\0';
176 176 break;
177 177 }
178 178 case 'r':
179 179 if (strlen(initargs) + 3 + 1 > sizeof (initargs)) {
180 180 _kobj_printf(ops, "unix: init options too "
181 181 "long. Ignoring -r.\n");
182 182 break;
183 183 }
184 184 boothowto |= RB_RECONFIG;
185 185 (void) strlcat(initargs, "-r ", sizeof (initargs));
186 186 break;
187 187 case 's':
188 188 if (strlen(initargs) + 3 + 1 > sizeof (initargs)) {
189 189 _kobj_printf(ops, "unix: init options too "
190 190 "long. Ignoring -s.\n");
191 191 break;
192 192 }
193 193 boothowto |= RB_SINGLE;
194 194 (void) strlcat(initargs, "-s ", sizeof (initargs));
195 195 break;
196 196 case 'v':
197 197 if (strlen(initargs) + 3 + 1 > sizeof (initargs)) {
198 198 _kobj_printf(ops, "unix: init options too "
199 199 "long. Ignoring -v.\n");
200 200 break;
201 201 }
202 202 boothowto |= RB_VERBOSE;
203 203 (void) strlcat(initargs, "-v ", sizeof (initargs));
204 204 break;
205 205 #if defined(_OBP)
206 206 case 'V':
207 207 break;
208 208 case 'Z':
209 209 break;
210 210 #endif
211 211 case 'w':
212 212 boothowto |= RB_WRITABLE;
213 213 break;
214 214 case 'x':
215 215 boothowto |= RB_NOBOOTCLUSTER;
216 216 break;
217 217 case '?':
218 218 switch (params.gos_last_opt) {
219 219 case 'i':
220 220 _kobj_printf(ops, "krtld: Required argument "
221 221 "for -i flag missing. Ignoring.\n");
222 222 break;
223 223 default:
224 224 _kobj_printf(ops, "krtld: Ignoring invalid "
225 225 "kernel option -%c.\n",
226 226 params.gos_last_opt);
227 227 }
228 228 break;
229 229 default:
230 230 _kobj_printf(ops, "krtld: Ignoring unimplemented "
231 231 "option -%c.\n", c);
232 232 }
233 233 }
234 234
235 235 if ((boothowto & (RB_DEBUGENTER | RB_KMDB)) == RB_DEBUGENTER) {
236 236 _kobj_printf(ops, "krtld: -d is not valid without -k.\n");
237 237 boothowto &= ~RB_DEBUGENTER;
238 238 }
239 239
240 240 if (*params.gos_strp) {
241 241 /* Unused arguments. */
242 242 if (params.gos_strp[0] == '-' && ISSPACE(params.gos_strp[1])) {
243 243 /*EMPTY*/
244 244 /* Lousy install arguments. Silently ignore. */
245 245 } else {
246 246 _kobj_printf(ops, "krtld: Unused kernel arguments: "
247 247 "`%s'.\n", params.gos_strp);
248 248 }
249 249 }
250 250 }
↓ open down ↓ |
132 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX