Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit ba71111

Browse files
author
Damien Lespiau
committed
init: Only do the init process setup if launched as "init"
We base this detection on the name of the binary: "init" means we've been started as an init system. When not running as an init system, we can skip the basic initialisation as systemd or any other init system would have done that for us. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
1 parent 71f5e15 commit ba71111

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/init.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#define _GNU_SOURCE
2+
#include <stdbool.h>
23
#include <stdio.h>
34
#include <stdlib.h>
45
#include <string.h>
@@ -40,6 +41,9 @@ struct hyper_ctl ctl;
4041

4142
sigset_t orig_mask;
4243

44+
/* is_init is true when hyperstart is run as the Linux init process */
45+
static bool is_init;
46+
4347
static int hyper_handle_exit(struct hyper_pod *pod);
4448

4549
static int hyper_set_win_size(char *json, int length)
@@ -1266,6 +1270,9 @@ static int hyper_loop(void)
12661270

12671271
static int hyper_setup_init_process(void)
12681272
{
1273+
if (!is_init)
1274+
return 0;
1275+
12691276
/* mount the base file systems */
12701277
if (mount("proc", "/proc", "proc", MS_NOSUID| MS_NODEV| MS_NOEXEC, NULL) == -1) {
12711278
perror("mount proc failed");
@@ -1307,7 +1314,10 @@ static int hyper_setup_init_process(void)
13071314

13081315
int main(int argc, char *argv[])
13091316
{
1310-
char *cmdline, *ctl_serial, *tty_serial;
1317+
char *binary_name, *cmdline, *ctl_serial, *tty_serial;
1318+
1319+
binary_name = basename(argv[0]);
1320+
is_init = strncmp(binary_name, "init", 5) == 0;
13111321

13121322
if (hyper_setup_init_process() < 0) {
13131323
return -1;

0 commit comments

Comments
 (0)