Fix I/O plugin watcher, load plugins earlier to enable a new early hook!

Restructure start by calling the plugin loader earlier. This makes it
possible to run hooks even earlier.  This also adds a new hook:
HOOK_ROOTFS_UP which runs as soon as the system root (/) is available.

Another very notable change is the slow refactor of helpers.c into a finit
helper library called libite.so (-lite). This is a light-weight

Also, lots of misc. fixes all over the place. Signal handling still really
needs to be looked into once more!

Makefile:
        Add dependency handling for parallell build
        Add libite library

ChangeLog:
        Update with new 1.4 release. There is a lot of fixes!

libite/:
        Collection of utility functions and C library extensions for
        finit & its plugins

reboot.c:
        New reboot tool. Simply sends SIGINT to PID 1

finit.h:
        Cleanup old LISTEN_INITCTL define, code is in an optional plugin now

finit.c:
        Let mdev/udev run *after* cls()
        Add useful debug statement for /proc/cmdline
        Earlier plugin load => new early hook point
        Show OK/FAIL for total plugin load, not for each plugin => speedup

helpers.h:
        Rename syslog macros to prevent common name clashes (DEBUG/ERROR)
        Add __FILE__ to _e(), _d() and _pe() macros

helpers.c:
        In ifconfig() the addr and mask arguments are now optional
        The copyfile() has been moved to libite.so
        Temporarily remove const directive from some functions to build
        Use DFLSIG() macro in run_getty() to simplify code

plugin.h:
        Add new HOOK_ROOTFS_UP hook

plugin.c:
        Fix init_plugins() to actually register the plugin's I/O fd
        Skip verbose listing of all plugins in plugin_load_all()

svc.c:
        svc_start(): Dito

plugins/Makefile:
        Inherit CFLAGS and LDFLAGS, but make sure to filter out -rdynamic
        from LDFLAGS, it's used by the daemon, only

plugins/initctl.c:
        New includes after helpers.h refactor

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2012-10-02 08:25:50 +02:00
1 parent c002b5301f
commit 65c9e7ebc6
22 files changed
+1324 -111

No files matched your search

+13 -9
View File
@@ -84,7 +84,7 @@ int plugin_register(plugin_t *plugin)
}
if (!inuse) {
_e("No service \"%s\" loaded, and no I/O or finit hooks, skipping plugin.", basename(plugin->name));
_d("No service \"%s\" loaded, and no I/O or finit hooks, skipping plugin.", basename(plugin->name));
return 1;
}
@@ -173,15 +173,16 @@ static void init_plugins(void)
PLUGIN_ITERATOR(p) {
if (is_io_plugin(p)) {
_d("Initializing plugin %s for I/O", basename(p->name));
fds[i].revents = 0;
fds[i].events = p->io.flags;
fds[num_fds++].fd = p->io.fd;
fds[i].revents = 0;
fds[i].events = p->io.flags;
fds[i++].fd = p->io.fd;
}
}
}
int plugin_load_all(char *path)
{
int fail = 0;
DIR *dp = opendir(path);
struct dirent *entry;
@@ -194,25 +195,28 @@ int plugin_load_all(char *path)
char *ext = entry->d_name + strlen(entry->d_name) - 3;
if (!strcmp(ext, ".so")) {
int result = 0;
void *handle;
char plugin[1024];
snprintf(plugin, sizeof(plugin), "%s/%s", path, entry->d_name);
print_desc(" Loading plugin ", basename(plugin));
// print_desc(" Loading plugin ", basename(plugin));
handle = dlopen(plugin, RTLD_LAZY | RTLD_GLOBAL);
if (!handle) {
_d("Failed loading plugin %s: %s", plugin, dlerror());
print_result(1);
return 1;
result = 1;
}
print_result(0);
if (result)
fail++;
// print_result(result);
}
}
closedir(dp);
init_plugins();
return 0;
return fail;
}
/**