Convert finit to use libev and fix so plugin ctors runs on dlopen().

Lots of cleanup and simplification of the main code in this commit.
Most notably libev has been added to take care of the main loop and
monitor services. Still TODO is migrating to use the libev signal
handling.

Convert initctl.c:listen_initctl() to a plugin instead.  This also
meant introducing a new form of I/O plugin to finit, also handled
by libev.

Load plugins *after* we've setup the base filesystem (BASEFS) in case
plugins reside on a filesystem not reachable before "mount -a" has run.
This also has the side effect of lining up nicely with the first level
plugin hooks.

If a plugin wants to hook up with a loded service we connect them by
their respective numeric IDs in plugin_register().  I.e., the service
monitor checks if a service has a registered callback, which in turn
decides if a service should be started, stopped or reloaded.

Rip out old EeePC distribution defines from finit.h, none of it really
applies anymore.  If you need distribution specific settings this is
the place to put them.

Make hookpoint names (#defines) clearer: after BASEFS, after networking,
after all setup, etc.

Use #inlude_next <signal.h> in signal.h to include system header file!

Simplify service monitor: move essential code to svc.c and rip out
the TIPC dependency. Write your own service.so plugin, or wait for
a more complete example of how to extend service monitoring using
the primitives in svc.c

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2012-09-25 14:23:23 +02:00
1 parent 5dda9051ac
commit 0e02429e75
25 files changed
+620 -1073

No files matched your search

+1 -39
View File
@@ -30,9 +30,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <syslog.h>
#define DO_LOG(level, fmt, args...) \
@@ -56,35 +53,7 @@
# define MDEV "/sbin/mdev"
# define GETTY "/sbin/getty -L 115200 ttyS0 vt100"
# define LISTEN_INITCTL
#elif defined DIST_MDV /* Mandriva */
# define RANDOMSEED "/var/lib/random-seed"
# define SYSROOT "/sysroot"
# define CONSOLE "/dev/console"
# define GETTY "/usr/bin/openvt /sbin/mingetty tty2"
# define RUNPARTS "/usr/bin/run-parts"
# define REMOUNT_ROOTFS_RW
# define PAM_CONSOLE
# define LISTEN_INITCTL
# define RUNLEVEL 5
# define USE_MESSAGE_BUS
#elif defined DIST_EEEXUBUNTU /* eeeXubuntu */
# define RANDOMSEED "/var/lib/urandom/random-seed"
# define SYSROOT "/sysroot"
# define CONSOLE "/dev/console"
# define GETTY "/usr/bin/openvt /sbin/getty 38400 tty2"
# define RUNPARTS "/bin/run-parts"
# define REMOUNT_ROOTFS_RW
# define TOUCH_ETC_NETWORK_RUN_IFSTATE
# define LISTEN_INITCTL
#elif defined DIST_ORIGEEE /* original EeePC distribution */
# define RANDOMSEED "/var/lib/urandom/random-seed"
# define SYSROOT "/mnt"
# define CONSOLE "/dev/console"
# define GETTY "/usr/bin/openvt /sbin/getty 38400 tty2"
# define RUNPARTS "/bin/run-parts"
# define TOUCH_ETC_NETWORK_RUN_IFSTATE
# define USE_ETC_RESOLVCONF_RUN
#else /* Ubuntu */
#else /* Debian/Ubuntu based distributions */
# define RANDOMSEED "/var/lib/urandom/random-seed"
# define CONSOLE "/dev/tty1"
# define GETTY "/sbin/getty -8 38400 tty1"
@@ -125,10 +94,6 @@
#define UNUSED(x) UNUSED_ ## x __attribute__ ((unused))
#endif
/* Match one command. */
#define MATCH_CMD(l, c, x) \
(!strncmp(l, c, strlen(c)) && (x = (l) + strlen(c)))
#define echo(fmt, args...) do { if (1) { fprintf(stderr, fmt "\n", ##args); } } while (0)
#define _d(fmt, args...) do { if (debug) { fprintf(stderr, "finit:%s() - " fmt "\n", __func__, ##args); } } while (0)
#define _e(fmt, args...) do { fprintf(stderr, "finit:%s() - " fmt "\n", __func__, ##args); } while (0)
@@ -142,9 +107,6 @@ extern char *startx;
extern char *hostname;
extern char *username;
/* initctl.c */
void listen_initctl (void);
/* strlcpy.c */
size_t strlcpy(char *dst, const char *src, size_t siz);