From 916f95cb58604038695347ee41a430d8ca1f0556 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Thu, 14 Nov 2013 13:41:13 +0100 Subject: debloat and reorganize code split app into procd and init binaries remove log support, this is an external service now Signed-off-by: John Crispin --- preinit.c | 68 --------------------------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 preinit.c (limited to 'preinit.c') diff --git a/preinit.c b/preinit.c deleted file mode 100644 index c015ebd..0000000 --- a/preinit.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2013 Felix Fietkau - * Copyright (C) 2013 John Crispin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include - -#include -#include - -#include "procd.h" -#include "hotplug.h" -#include "watchdog.h" - -static struct uloop_process preinit; - -static void spawn_procd(struct uloop_process *proc, int ret) -{ - char *wdt_fd = watchdog_fd(); - char *argv[] = { "/sbin/procd", NULL }; - struct stat s; - - if (!stat("/tmp/sysupgrade", &s)) - while (true) - sleep(1); - - unsetenv("INITRAMFS"); - unsetenv("PREINIT"); - DEBUG(1, "Exec to real procd now\n"); - if (wdt_fd) - setenv("WDTFD", wdt_fd, 1); - execvp(argv[0], argv); -} - -void procd_preinit(void) -{ - char *argv[] = { "/bin/sh", "/etc/preinit", NULL }; - - LOG("- preinit -\n"); - - setenv("PREINIT", "1", 1); - preinit.cb = spawn_procd; - preinit.pid = fork(); - if (!preinit.pid) { - execvp(argv[0], argv); - ERROR("Failed to start preinit\n"); - exit(-1); - } - - if (preinit.pid <= 0) { - ERROR("Failed to start new preinit instance\n"); - return; - } - - uloop_process_add(&preinit); - DEBUG(2, "Launched preinit instance, pid=%d\n", (int) preinit.pid); -} -- cgit v1.2.3