Deleted Added
sdiff udiff text old ( 61659 ) new ( 64187 )
full compact
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 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? */
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;
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
166autoboot(int timeout, char *prompt)
167{
168 time_t when, otime, ntime;
169 int c, yes;
170 char *argv[2], *cp, *ep;
171
172 autoboot_tried = 1;
173
174 if (timeout == -1) {
175 /* try to get a delay from the environment */
176 if ((cp = getenv("autoboot_delay"))) {
177 timeout = strtol(cp, &ep, 0);
178 if (cp == ep)
179 timeout = -1;
180 }
181 }
182 if (timeout == -1) /* all else fails */
183 timeout = 10;
184
185 otime = time(NULL);
186 when = otime + timeout; /* when to boot */
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;
230 size_t len;
231
232 /* we use dynamic storage */
233 if (name != NULL) {
234 free(name);
235 name = NULL;
236 }
237
238 /*

--- 96 unchanged lines hidden ---