summaryrefslogtreecommitdiffstats
path: root/sys/boot/common/boot.c
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>1998-10-07 02:38:26 +0000
committermsmith <msmith@FreeBSD.org>1998-10-07 02:38:26 +0000
commit387d0e8c2b336bf34a8b434f0f090fd31e4e3d7f (patch)
treef649378e8cb57ba1e3a2d3e85e6ba1f68a44bd51 /sys/boot/common/boot.c
parent436333e172727c23d47b79a4e1e45dbc916b5dec (diff)
downloadFreeBSD-src-387d0e8c2b336bf34a8b434f0f090fd31e4e3d7f.zip
FreeBSD-src-387d0e8c2b336bf34a8b434f0f090fd31e4e3d7f.tar.gz
- VERBOSE_LS is obsolete, as the heap is much better behaved now.
- Don't whine about nodes we can't stat(); these are usually symlinks that lead out of the filesystem. - Autoboot is now controlled by $autoboot_delay, which is a value in seconds or NO to disable autoboot. - Don't autoboot at the end of boot.conf if we have already tried. - Add a 'read' command to complement 'echo'. Both are still hidden. - Improve the 'source' command/function so that it is possible to source scripts off removable media. The entire script is read and saved before beginning execution. Script lines beginning with '@' will not be echoed when being executed. Script execution will normally terminate at the first error, however if the script line begins with '-' this behaviour is overriden for that command.
Diffstat (limited to 'sys/boot/common/boot.c')
-rw-r--r--sys/boot/common/boot.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/sys/boot/common/boot.c b/sys/boot/common/boot.c
index e0ea678..d54201c 100644
--- a/sys/boot/common/boot.c
+++ b/sys/boot/common/boot.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: boot.c,v 1.3 1998/09/28 22:03:01 peter Exp $
+ * $Id: boot.c,v 1.4 1998/10/02 16:22:26 msmith Exp $
*/
/*
@@ -40,6 +40,8 @@ static char *getbootfile(int try);
/* List of kernel names to try (may be overwritten by boot.config) XXX should move from here? */
static char *default_bootfiles = "kernel,kernel.old";
+static int autoboot_tried;
+
/*
* The user wants us to boot.
*/
@@ -119,9 +121,6 @@ command_boot(int argc, char *argv[])
COMMAND_SET(autoboot, "autoboot", "boot automatically after a delay", command_autoboot);
-/*
- * XXX note the 'prompt' argument is not really useful until quoting is implemented
- */
static int
command_autoboot(int argc, char *argv[])
{
@@ -149,15 +148,39 @@ command_autoboot(int argc, char *argv[])
return(CMD_ERROR);
}
+/*
+ * Called before we go interactive. If we think we can autoboot, and
+ * we haven't tried already, try now.
+ */
+void
+autoboot_maybe()
+{
+ char *cp;
+
+ cp = getenv("autoboot_delay");
+ if ((autoboot_tried == 0) && ((cp == NULL) || strcasecmp(cp, "NO")))
+ autoboot(-1, NULL); /* try to boot automatically */
+}
+
int
autoboot(int delay, char *prompt)
{
time_t when, otime, ntime;
int c, yes;
- char *argv[2];
+ char *argv[2], *cp, *ep;
- if (delay == -1)
- delay = 5; /* env var? compile-time define? */
+ autoboot_tried = 1;
+
+ if (delay == -1) {
+ /* try to get a delay from the environment */
+ if ((cp = getenv("autoboot_delay"))) {
+ delay = strtol(cp, &ep, 0);
+ if (cp == ep)
+ delay = -1;
+ }
+ }
+ if (delay == -1) /* all else fails */
+ delay = 10;
otime = time(NULL);
when = otime + delay; /* when to boot */
@@ -183,7 +206,6 @@ autoboot(int delay, char *prompt)
otime = ntime;
}
}
- printf("\n");
if (yes) {
argv[0] = "boot";
argv[1] = NULL;
OpenPOWER on IntegriCloud