From 2397901d9d5cdc1ccf42777036e70fe9248182a0 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Mon, 18 Nov 2013 11:32:11 +0100 Subject: [PATCH] add a function to add calls to the front of the rcS queue Signed-off-by: John Crispin --- rcS.c | 19 ++++++++++++++++--- rcS.h | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/rcS.c b/rcS.c index ae8f08e..d6a3f7c 100644 --- a/rcS.c +++ b/rcS.c @@ -102,7 +102,7 @@ static void q_initd_complete(struct runqueue *q, struct runqueue_task *p) free(s); } -static void add_initd(struct runqueue *q, char *file, char *param) +static void add_initd(struct runqueue *q, char *file, char *param, int first) { static const struct runqueue_task_type initd_type = { .run = q_initd_run, @@ -116,7 +116,10 @@ static void add_initd(struct runqueue *q, char *file, char *param) s->proc.task.complete = q_initd_complete; s->param = param; s->file = file; - runqueue_task_add(q, &s->proc.task, false); + if (first) + runqueue_task_add_first(q, &s->proc.task, false); + else + runqueue_task_add(q, &s->proc.task, false); } static int _rc(struct runqueue *q, char *path, const char *file, char *pattern, char *param) @@ -134,7 +137,7 @@ static int _rc(struct runqueue *q, char *path, const char *file, char *pattern, } for (j = 0; j < gl.gl_pathc; j++) - add_initd(q, gl.gl_pathv[j], param); + add_initd(q, gl.gl_pathv[j], param, 0); return 0; } @@ -153,6 +156,16 @@ int rc(const char *file, char *param) return _rc(&r, "/etc/init.d", file, "", param); } +int rcnow(const char *file, char *param) +{ + char path[64] = { 0 }; + + snprintf(path, sizeof(path), "/etc/init.d/%s", file); + add_initd(&r, path, param, 0); + + return 0; +} + static void r_empty(struct runqueue *q) { diff --git a/rcS.h b/rcS.h index 91d37d1..c6d56b0 100644 --- a/rcS.h +++ b/rcS.h @@ -19,5 +19,6 @@ extern int rcS(char *pattern, char *param, void (*q_empty)(struct runqueue *)); extern int rc(const char *file, char *param); +extern int rcnow(const char *file, char *param); #endif -- 2.25.1