Make the location of init(8) tunable at boot time.
This commit is contained in:
parent
157ddd9539
commit
5f967b24fc
@ -183,10 +183,19 @@
|
||||
|
||||
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.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
||||
##############################################################
|
||||
|
@ -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
|
||||
|
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user