)
-SET(SOURCES procd.c signal.c watchdog.c state.c inittab.c rcS.c ubus.c system.c
+SET(SOURCES procd.c signal.c state.c inittab.c rcS.c ubus.c system.c
service/service.c service/instance.c service/validate.c service/trigger.c service/watch.c
- plug/coldplug.c plug/hotplug.c utils/utils.c)
+ utils/utils.c)
+IF(NOT DISABLE_INIT)
+ SET(SOURCES ${SOURCES} watchdog.c plug/coldplug.c plug/hotplug.c)
+ENDIF()
SET(LIBS ubox ubus json-c blobmsg_json json_script)
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
)
-IF(NOT DISABLE_INIT)
+IF(DISABLE_INIT)
+ADD_DEFINITIONS(-DDISABLE_INIT)
+ELSE()
ADD_EXECUTABLE(init initd/init.c initd/early.c initd/preinit.c initd/mkdev.c watchdog.c
utils/utils.c ${SOURCES_ZRAM})
TARGET_LINK_LIBRARIES(init ${LIBS})
INSTALL(TARGETS init
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
)
-ENDIF()
-
ADD_EXECUTABLE(udevtrigger plug/udevtrigger.c)
INSTALL(TARGETS udevtrigger
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
)
+ENDIF()
ADD_EXECUTABLE(askfirst utils/askfirst.c)
#include <libubox/uloop.h>
+#ifndef DISABLE_INIT
void hotplug(char *rules);
int hotplug_run(char *rules);
void hotplug_shutdown(void);
void hotplug_last_event(uloop_timeout_handler handler);
+void procd_coldplug(void);
+#else
+static inline void hotplug(char *rules)
+{
+}
+
+static inline int hotplug_run(char *rules)
+{
+ return 0;
+}
+
+static inline void hotplug_shutdown(void)
+{
+}
+
+static inline void hotplug_last_event(uloop_timeout_handler handler)
+{
+}
+
+static inline void procd_coldplug(void)
+{
+}
+#endif
#endif
void procd_shutdown(int event);
void procd_early(void);
void procd_preinit(void);
-void procd_coldplug(void);
void procd_signal(void);
void procd_signal_preinit(void);
void procd_inittab(void);
#include <sys/socket.h>
#include <sys/types.h>
-#include <linux/types.h>
-#include <linux/netlink.h>
-
#include <libubox/blobmsg_json.h>
#include <libubox/json_script.h>
#include <libubox/runqueue.h>
int event = 0;
char *msg = NULL;
+#ifndef DISABLE_INIT
switch(signal) {
case SIGINT:
case SIGTERM:
msg = "poweroff";
break;
}
+#endif
DEBUG(1, "Triggering %s\n", msg);
if (event)
sigaction(SIGHUP, &sa_dummy, NULL);
sigaction(SIGKILL, &sa_dummy, NULL);
sigaction(SIGSTOP, &sa_dummy, NULL);
+#ifndef DISABLE_INIT
reboot(RB_DISABLE_CAD);
+#endif
}
kill(-1, SIGKILL);
sync();
sleep(1);
+#ifndef DISABLE_INIT
if (reboot_event == RB_POWER_OFF)
LOG("- power down -\n");
else
reboot(reboot_event);
_exit(EXIT_SUCCESS);
}
-
while (1)
sleep(1);
+#else
+ exit(0);
+#endif
break;
default:
#ifndef __PROCD_WATCHDOG_H
#define __PROCD_WATCHDOG_H
+#ifndef DISABLE_INIT
void watchdog_init(int preinit);
char* watchdog_fd(void);
int watchdog_timeout(int timeout);
bool watchdog_get_stopped(void);
void watchdog_no_cloexec(void);
void watchdog_ping(void);
+#else
+static inline void watchdog_init(int preinit)
+{
+}
+
+static inline char* watchdog_fd(void)
+{
+ return "";
+}
+
+static inline int watchdog_timeout(int timeout)
+{
+ return 0;
+}
+
+static inline int watchdog_frequency(int frequency)
+{
+ return 0;
+}
+
+static inline void watchdog_set_stopped(bool val)
+{
+}
+
+static inline bool watchdog_get_stopped(void)
+{
+ return true;
+}
+
+static inline void watchdog_no_cloexec(void)
+{
+}
+
+static inline void watchdog_ping(void)
+{
+}
+
+#endif
#endif