3 @@ -4,7 +4,24 @@ SOFTWARE=hotplug2
6 BINS=hotplug2 hotplug2-modwrap
7 -SUBDIRS=parser rules workers
11 + hotplug2.o netlink.o seqnum.o settings.o uevent.o xmemutils.o \
12 + workers/loader.o parser/parser.o parser/buffer.o parser/token.o \
13 + parser/token_queue.o parser/lexer.o rules/ruleset.o rules/rule.o \
14 + rules/condition.o rules/expression.o rules/execution.o \
18 + ifeq ($(wildcard workers/worker_$(STATIC_WORKER).c),)
19 + $(error Worker source worker/worker_$(STATIC_WORKER).c not found)
21 + hotplug2-objs += action.o workers/worker_$(STATIC_WORKER).o
29 @@ -13,13 +30,16 @@ all: $(BINS)
31 $(INSTALL_BIN) $(BINS) $(DESTDIR)/sbin/
34 -hotplug2: hotplug2.o netlink.o seqnum.o settings.o uevent.o xmemutils.o \
35 - workers/loader.o parser/parser.o parser/buffer.o parser/token.o \
36 - parser/token_queue.o parser/lexer.o rules/ruleset.o rules/rule.o \
37 - rules/condition.o rules/expression.o rules/execution.o \
39 +hotplug2: $(hotplug2-objs)
41 coldplug2: coldplug2.o
46 + CFLAGS += -DSTATIC_WORKER=1
57 -CFLAGS=-Os -Wall -g -fPIC
65 INSTALL=install -c -m 644
66 INSTALL_BIN=install -c -m 755
67 --- a/workers/loader.c
68 +++ b/workers/loader.c
74 +extern struct worker_module_t worker_module;
75 +static struct loader_ctx_t static_ctx = {
76 + .module = &worker_module
79 +struct loader_ctx_t *worker_load(const char *name)
84 +void worker_free(struct loader_ctx_t *ctx)
90 struct loader_ctx_t *worker_load(const char *name) {
91 struct loader_ctx_t *ctx;
93 @@ -12,7 +30,7 @@ struct loader_ctx_t *worker_load(const c
97 - ctx->module = dlsym(ctx->dl_handle, "module");
98 + ctx->module = dlsym(ctx->dl_handle, "worker_module");
99 if (ctx->module == NULL) {
100 fprintf(stderr, "Loader error: %s\n", dlerror());
102 @@ -31,3 +49,5 @@ void worker_free(struct loader_ctx_t *ct
110 @@ -261,17 +261,21 @@ int main(int argc, char *argv[]) {
113 /* Load the worker. */
114 +#ifndef STATIC_WORKER
115 if (settings->worker_name == NULL) {
116 fprintf(stderr, "Missing worker name.\n");
117 settings_clear(settings);
121 settings->worker = worker_load(settings->worker_name);
122 +#ifndef STATIC_WORKER
123 if (settings->worker == NULL) {
124 fprintf(stderr, "Unable to load worker: %s\n", settings->worker_name);
125 settings_clear(settings);
130 /* Prepare a netlink connection to the kernel. */
131 settings->netlink_socket = netlink_init();
132 --- a/workers/worker_example.c
133 +++ b/workers/worker_example.c
134 @@ -62,7 +62,7 @@ static int worker_example_process(void *
138 -struct worker_module_t module = {
139 +struct worker_module_t worker_module = {
140 "Hotplug2 example module",
142 worker_example_deinit,
143 --- a/workers/worker_fork.c
144 +++ b/workers/worker_fork.c
145 @@ -443,7 +443,7 @@ static int worker_fork_process(void *in_
149 -struct worker_module_t module = {
150 +struct worker_module_t worker_module = {
151 "Hotplug2 forking module",
154 --- a/workers/worker_single.c
155 +++ b/workers/worker_single.c
156 @@ -18,7 +18,7 @@ static int worker_single_process(void *s
160 -struct worker_module_t module = {
161 +struct worker_module_t worker_module = {
162 "Hotplug2 single process module",
164 worker_single_deinit,