Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F148361642
D16625.id46633.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D16625.id46633.diff
View Options
Index: sbin/init/init.8
===================================================================
--- sbin/init/init.8
+++ sbin/init/init.8
@@ -316,6 +316,14 @@
.Xr reboot 8
.Fl r
for details.
+.It Va init_exec
+If set to a valid file name in the root file system,
+instructs
+.Nm
+to directly execute that file as the very first action,
+replacing
+.Nm
+as PID 1.
.It Va init_script
If set to a valid file name in the root file system,
instructs
@@ -341,6 +349,8 @@
The default is
.Dq Li /bin/sh .
It is used for running the
+.Va init_exec
+or
.Va init_script
if set, as well as for the
.Pa /etc/rc
Index: sbin/init/init.c
===================================================================
--- sbin/init/init.c
+++ sbin/init/init.c
@@ -196,6 +196,19 @@
static session_t *find_session(pid_t);
static DB *session_db;
+static void
+run_exec(char *path)
+{
+ char *argv[3];
+ char sh[] = "sh";
+
+ argv[0] = sh;
+ argv[1] = path;
+ argv[2] = NULL;
+
+ execute_script(argv);
+}
+
/*
* The mother of all processes.
*/
@@ -329,6 +342,11 @@
close(0);
close(1);
close(2);
+
+ if (kenv(KENV_GET, "init_exec", kenv_value, sizeof(kenv_value)) > 0) {
+ run_exec(kenv_value);
+ _exit(0); /* reboot */
+ }
if (kenv(KENV_GET, "init_script", kenv_value, sizeof(kenv_value)) > 0) {
state_func_t next_transition;
Index: stand/man/loader.8
===================================================================
--- stand/man/loader.8
+++ stand/man/loader.8
@@ -492,6 +492,9 @@
.It Va init_chroot
See
.Xr init 8 .
+.It Va init_exec
+See
+.Xr init 8 .
.It Va init_path
Sets the list of binaries which the kernel will try to run as the initial
process.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 18, 9:04 AM (8 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29895979
Default Alt Text
D16625.id46633.diff (1 KB)
Attached To
Mode
D16625: sbin/init/init.c: Add init_exec
Attached
Detach File
Event Timeline
Log In to Comment