Deleted Added
full compact
boot.c (61659) boot.c (64187)
1/*-
2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/boot/common/boot.c 61659 2000-06-14 10:34:29Z ps $
26 * $FreeBSD: head/sys/boot/common/boot.c 64187 2000-08-03 09:14:02Z jhb $
27 */
28
29/*
30 * Loading modules, booting the system
31 */
32
33#include <stand.h>
34#include <string.h>
35
36#include "bootstrap.h"
37
38static char *getbootfile(int try);
39
40/* List of kernel names to try (may be overwritten by boot.config) XXX should move from here? */
27 */
28
29/*
30 * Loading modules, booting the system
31 */
32
33#include <stand.h>
34#include <string.h>
35
36#include "bootstrap.h"
37
38static char *getbootfile(int try);
39
40/* List of kernel names to try (may be overwritten by boot.config) XXX should move from here? */
41static char *default_bootfiles = "kernel;kernel.old";
41static const char *default_bootfiles = "kernel;kernel.old";
42
43static int autoboot_tried;
44
45/*
46 * The user wants us to boot.
47 */
48COMMAND_SET(boot, "boot", "boot a file or loaded kernel", command_boot);
49
50static int
51command_boot(int argc, char *argv[])
52{
53 struct preloaded_file *fp;
54 char *cp;
55 int try;
42
43static int autoboot_tried;
44
45/*
46 * The user wants us to boot.
47 */
48COMMAND_SET(boot, "boot", "boot a file or loaded kernel", command_boot);
49
50static int
51command_boot(int argc, char *argv[])
52{
53 struct preloaded_file *fp;
54 char *cp;
55 int try;
56 int i;
57
58 /*
59 * See if the user has specified an explicit kernel to boot.
60 */
61 if ((argc > 1) && (argv[1][0] != '-')) {
62
63 /* XXX maybe we should discard everything and start again? */
64 if (file_findfile(NULL, NULL) != NULL) {

--- 94 unchanged lines hidden (view full) ---

159 char *cp;
160
161 cp = getenv("autoboot_delay");
162 if ((autoboot_tried == 0) && ((cp == NULL) || strcasecmp(cp, "NO")))
163 autoboot(-1, NULL); /* try to boot automatically */
164}
165
166int
56
57 /*
58 * See if the user has specified an explicit kernel to boot.
59 */
60 if ((argc > 1) && (argv[1][0] != '-')) {
61
62 /* XXX maybe we should discard everything and start again? */
63 if (file_findfile(NULL, NULL) != NULL) {

--- 94 unchanged lines hidden (view full) ---

158 char *cp;
159
160 cp = getenv("autoboot_delay");
161 if ((autoboot_tried == 0) && ((cp == NULL) || strcasecmp(cp, "NO")))
162 autoboot(-1, NULL); /* try to boot automatically */
163}
164
165int
167autoboot(int delay, char *prompt)
166autoboot(int timeout, char *prompt)
168{
169 time_t when, otime, ntime;
170 int c, yes;
171 char *argv[2], *cp, *ep;
172
173 autoboot_tried = 1;
174
167{
168 time_t when, otime, ntime;
169 int c, yes;
170 char *argv[2], *cp, *ep;
171
172 autoboot_tried = 1;
173
175 if (delay == -1) {
174 if (timeout == -1) {
176 /* try to get a delay from the environment */
177 if ((cp = getenv("autoboot_delay"))) {
175 /* try to get a delay from the environment */
176 if ((cp = getenv("autoboot_delay"))) {
178 delay = strtol(cp, &ep, 0);
177 timeout = strtol(cp, &ep, 0);
179 if (cp == ep)
178 if (cp == ep)
180 delay = -1;
179 timeout = -1;
181 }
182 }
180 }
181 }
183 if (delay == -1) /* all else fails */
184 delay = 10;
182 if (timeout == -1) /* all else fails */
183 timeout = 10;
185
186 otime = time(NULL);
184
185 otime = time(NULL);
187 when = otime + delay; /* when to boot */
186 when = otime + timeout; /* when to boot */
188 yes = 0;
189
190 /* XXX could try to work out what we might boot */
191 printf("%s\n", (prompt == NULL) ? "Hit [Enter] to boot immediately, or any other key for command prompt." : prompt);
192
193 for (;;) {
194 if (ischar()) {
195 c = getchar();

--- 27 unchanged lines hidden (view full) ---

223/*
224 * Scrounge for the name of the (try)'th file we will try to boot.
225 */
226static char *
227getbootfile(int try)
228{
229 static char *name = NULL;
230 char *spec, *ep;
187 yes = 0;
188
189 /* XXX could try to work out what we might boot */
190 printf("%s\n", (prompt == NULL) ? "Hit [Enter] to boot immediately, or any other key for command prompt." : prompt);
191
192 for (;;) {
193 if (ischar()) {
194 c = getchar();

--- 27 unchanged lines hidden (view full) ---

222/*
223 * Scrounge for the name of the (try)'th file we will try to boot.
224 */
225static char *
226getbootfile(int try)
227{
228 static char *name = NULL;
229 char *spec, *ep;
231 int len;
230 size_t len;
232
233 /* we use dynamic storage */
234 if (name != NULL) {
235 free(name);
236 name = NULL;
237 }
238
239 /*

--- 96 unchanged lines hidden ---
231
232 /* we use dynamic storage */
233 if (name != NULL) {
234 free(name);
235 name = NULL;
236 }
237
238 /*

--- 96 unchanged lines hidden ---