diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 1999-04-20 21:15:13 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 1999-04-20 21:15:13 +0000 |
commit | 5f967b24fc6104c42ab3c253aac05f4ce6eb4b5b (patch) | |
tree | 105172802ca11aeffeca071a45aea539a8ac60df /sys/kern | |
parent | 157ddd95397940df777bff8d5bfc820f5dd6f6fb (diff) | |
download | src-5f967b24fc6104c42ab3c253aac05f4ce6eb4b5b.tar.gz src-5f967b24fc6104c42ab3c253aac05f4ce6eb4b5b.zip |
Make the location of init(8) tunable at boot time.
Notes
Notes:
svn path=/head/; revision=45881
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/init_main.c | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 671bfb77f851..82dd7880797b 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"); |