summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>1999-04-20 21:15:13 +0000
committerdes <des@FreeBSD.org>1999-04-20 21:15:13 +0000
commitd3e9d9a7c34ce206f106afc9d6b999308ef969de (patch)
tree4fdbd4baf68eea7d6173c6ec3d60bc42ae5a082d /sys
parentd96217d0989df758c433d4b5a80c72f298e83b75 (diff)
downloadFreeBSD-src-d3e9d9a7c34ce206f106afc9d6b999308ef969de.zip
FreeBSD-src-d3e9d9a7c34ce206f106afc9d6b999308ef969de.tar.gz
Make the location of init(8) tunable at boot time.
Diffstat (limited to 'sys')
-rw-r--r--sys/boot/common/help.common11
-rw-r--r--sys/boot/common/loader.86
-rw-r--r--sys/boot/forth/loader.conf3
-rw-r--r--sys/boot/i386/loader/loader.86
-rw-r--r--sys/kern/init_main.c45
5 files changed, 51 insertions, 20 deletions
diff --git a/sys/boot/common/help.common b/sys/boot/common/help.common
index 3478d9a..95c075e 100644
--- a/sys/boot/common/help.common
+++ b/sys/boot/common/help.common
@@ -184,9 +184,18 @@
Selects the default device. Syntax for devices is odd.
################################################################################
+# Tset Sinit_path DSet the list of init candidates
+
+ set init_path=<path>[;<path>...]
+
+ Sets the list of binaries which the kernel will try to run as initial
+ process.
+
+
+################################################################################
# Tset Smodule_path DSet the module search path
- set module_path=<path>[,<path>...]
+ set module_path=<path>[;<path>...]
Sets the list of directories which will be searched in for modules
named in a load command or implicitly required by a dependancy.
diff --git a/sys/boot/common/loader.8 b/sys/boot/common/loader.8
index 32133d8..2ed7acd 100644
--- a/sys/boot/common/loader.8
+++ b/sys/boot/common/loader.8
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id$
+.\" $Id: loader.8,v 1.1 1999/03/15 08:52:23 dcs Exp $
.\"
.\" Note: The date here should be updated whenever a non-trivial
.\" change is made to the manual page.
@@ -316,6 +316,10 @@ is
Defines the current console.
.It Va currdev
Selects the default device. Syntax for devices is odd.
+.It Va init_path
+Sets the list of binaries which the kernel will try to run as initial
+process. The default is
+.Li Dq /sbin/init;/sbin/oinit;/sbin/init.bak;/stand/sysinstall .
.It Va interpret
Has the value
.Li Dq ok
diff --git a/sys/boot/forth/loader.conf b/sys/boot/forth/loader.conf
index b38c642..4a65831 100644
--- a/sys/boot/forth/loader.conf
+++ b/sys/boot/forth/loader.conf
@@ -6,7 +6,7 @@
#
# All arguments must be in double quotes.
#
-# $Id: loader.conf,v 1.1 1999/03/09 14:06:55 dcs Exp $
+# $Id: loader.conf,v 1.2 1999/03/14 21:57:49 dcs Exp $
##############################################################
### Basic configuration options ############################
@@ -61,6 +61,7 @@ bitmap_type="splash_image_data"
#boot_single="NO" # Start system in single-user mode
#boot_userconfig="NO" # Run kernel's interactive device configuration program
#boot_verbose="NO" # Causes extra debugging information to be printed
+#init_path="/sbin/init" # Sets the list of init candidates
##############################################################
diff --git a/sys/boot/i386/loader/loader.8 b/sys/boot/i386/loader/loader.8
index 32133d8..2ed7acd 100644
--- a/sys/boot/i386/loader/loader.8
+++ b/sys/boot/i386/loader/loader.8
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id$
+.\" $Id: loader.8,v 1.1 1999/03/15 08:52:23 dcs Exp $
.\"
.\" Note: The date here should be updated whenever a non-trivial
.\" change is made to the manual page.
@@ -316,6 +316,10 @@ is
Defines the current console.
.It Va currdev
Selects the default device. Syntax for devices is odd.
+.It Va init_path
+Sets the list of binaries which the kernel will try to run as initial
+process. The default is
+.Li Dq /sbin/init;/sbin/oinit;/sbin/init.bak;/stand/sysinstall .
.It Va interpret
Has the value
.Li Dq ok
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index 671bfb7..82dd788 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -39,7 +39,7 @@
* SUCH DAMAGE.
*
* @(#)init_main.c 8.9 (Berkeley) 1/21/94
- * $Id: init_main.c,v 1.110 1999/02/25 11:03:08 bde Exp $
+ * $Id: init_main.c,v 1.111 1999/02/28 10:53:29 bde Exp $
*/
#include "opt_devfs.h"
@@ -591,16 +591,12 @@ kthread_init(dummy)
/*
* List of paths to try when searching for "init".
*/
-static char *initpaths[] = {
- "/sbin/init",
- "/sbin/oinit",
- "/sbin/init.bak",
- "/stand/sysinstall",
- NULL,
-};
+static char init_path[MAXPATHLEN] =
+ "/sbin/init;/sbin/oinit;/sbin/init.bak;/stand/sysinstall";
+SYSCTL_STRING(_kern, OID_AUTO, init_path, CTLFLAG_RD, init_path, 0, "");
/*
- * Start the initial user process; try exec'ing each pathname in "initpaths".
+ * Start the initial user process; try exec'ing each pathname in init_path.
* The program is invoked with one argument containing the boot flags.
*/
static void
@@ -609,8 +605,9 @@ start_init(p)
{
vm_offset_t addr;
struct execve_args args;
- int options, i, error;
- char **pathp, *path, *ucp, **uap, *arg0, *arg1;
+ int options, error;
+ char *var, *path, *next, *s;
+ char *ucp, **uap, *arg0, *arg1;
initproc = p;
@@ -618,12 +615,27 @@ start_init(p)
* Need just enough stack to hold the faked-up "execve()" arguments.
*/
addr = trunc_page(USRSTACK - PAGE_SIZE);
- if (vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &addr, PAGE_SIZE, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0) != 0)
+ if (vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &addr, PAGE_SIZE,
+ FALSE, VM_PROT_ALL, VM_PROT_ALL, 0) != 0)
panic("init: couldn't allocate argument space");
p->p_vmspace->vm_maxsaddr = (caddr_t)addr;
p->p_vmspace->vm_ssize = 1;
- for (pathp = &initpaths[0]; (path = *pathp) != NULL; pathp++) {
+ if ((var = getenv("init_path")) != NULL) {
+ strncpy(init_path, var, MAXPATHLEN);
+ init_path[sizeof init_path - 1] = 0;
+ }
+
+ for (path = init_path; path != '\0'; path = next) {
+ while (*path == ';')
+ path++;
+ if (path == '\0')
+ break;
+ for (next = path; *next != '\0' && *next != ';'; next++)
+ /* nothing */ ;
+ if (bootverbose)
+ printf("start_init: trying %.*s\n", next-path, path);
+
/*
* Move out the boot flag argument.
*/
@@ -653,8 +665,9 @@ start_init(p)
/*
* Move out the file name (also arg 0).
*/
- for (i = strlen(path) + 1; i >= 0; i--)
- (void)subyte(--ucp, path[i]);
+ (void)subyte(--ucp, 0);
+ for (s = next - 1; s >= path; s--)
+ (void)subyte(--ucp, *s);
arg0 = ucp;
/*
@@ -682,7 +695,7 @@ start_init(p)
if ((error = execve(p, &args)) == 0)
return;
if (error != ENOENT)
- printf("exec %s: error %d\n", path, error);
+ printf("exec %.*s: error %d\n", next-path, path, error);
}
printf("init: not found\n");
panic("no init");
OpenPOWER on IntegriCloud