Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion procd.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ static int usage(const char *prog)
" -s <path> Path to ubus socket\n"
" -h <path> run as hotplug daemon\n"
" -d <level> Enable debug messages\n"
" -I <path> Path to init.d directory\n"
" -R <path> Path to rc.d directory\n"
" -S Print messages to stdout\n"
"\n", prog);
return 1;
Expand All @@ -99,7 +101,7 @@ int main(int argc, char **argv)
unsetenv("DBGLVL");
}

while ((ch = getopt(argc, argv, "d:s:h:S")) != -1) {
while ((ch = getopt(argc, argv, "d:s:h:I:R:S")) != -1) {
switch (ch) {
case 'h':
return hotplug_run(optarg);
Expand All @@ -109,6 +111,12 @@ int main(int argc, char **argv)
case 'd':
debug = atoi(optarg);
break;
case 'I':
init_d_path = optarg;
break;
case 'R':
rc_d_path = optarg;
break;
case 'S':
ulog_channels = ULOG_STDIO;
break;
Expand Down
5 changes: 4 additions & 1 deletion procd.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@

#define __init __attribute__((constructor))

extern char *ubus_socket;
extern const char *init_d_path;
extern const char *rc_d_path;

extern const char *ubus_socket;

void procd_connect_ubus(void);
void procd_reconnect_ubus(int reconnect);
Expand Down
17 changes: 10 additions & 7 deletions rcS.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#include "procd.h"
#include "rcS.h"

const char *init_d_path = "/etc/init.d";
const char *rc_d_path = "/etc/rc.d";

static struct runqueue q, r;

struct initd {
Expand Down Expand Up @@ -125,7 +128,7 @@ static void q_initd_complete(struct runqueue *q, struct runqueue_task *p)
free(s);
}

static bool find_runqueue_list_entry(struct list_head *list, char *file, char *param)
static bool find_runqueue_list_entry(struct list_head *list, const char *file, const char *param)
{
struct initd *s;

Expand All @@ -135,7 +138,7 @@ static bool find_runqueue_list_entry(struct list_head *list, char *file, char *p
return false;
}

static void add_initd(struct runqueue *q, char *file, char *param)
static void add_initd(struct runqueue *q, const char *file, const char *param)
{
static const struct runqueue_task_type initd_type = {
.run = q_initd_run,
Expand Down Expand Up @@ -168,7 +171,7 @@ static void add_initd(struct runqueue *q, char *file, char *param)
runqueue_task_add(q, &s->proc.task, false);
}

static int _rc(struct runqueue *q, char *path, const char *file, char *pattern, char *param)
static int _rc(struct runqueue *q, const char *path, const char *file, const char *pattern, const char *param)
{
char *dir = alloca(2 + strlen(path) + strlen(file) + strlen(pattern));
glob_t gl;
Expand All @@ -194,18 +197,18 @@ static int _rc(struct runqueue *q, char *path, const char *file, char *pattern,
return 0;
}

int rcS(char *pattern, char *param, void (*q_empty)(struct runqueue *))
int rcS(const char *pattern, const char *param, void (*q_empty)(struct runqueue *))
{
runqueue_init(&q);
q.empty_cb = q_empty;
q.max_running_tasks = 1;

return _rc(&q, "/etc/rc.d", pattern, "*", param);
return _rc(&q, rc_d_path, pattern, "*", param);
}

int rc(const char *file, char *param)
int rc(const char *file, const char *param)
{
return _rc(&r, "/etc/init.d", file, "", param);
return _rc(&r, init_d_path, file, "", param);
}

static void r_empty(struct runqueue *q)
Expand Down
4 changes: 2 additions & 2 deletions rcS.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <libubox/runqueue.h>

extern int rcS(char *pattern, char *param, void (*q_empty)(struct runqueue *));
extern int rc(const char *file, char *param);
extern int rcS(const char *pattern, const char *param, void (*q_empty)(struct runqueue *));
extern int rc(const char *file, const char *param);

#endif
2 changes: 1 addition & 1 deletion ubus.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "procd.h"

char *ubus_socket = NULL;
const char *ubus_socket = NULL;
static struct ubus_context *ctx;
static struct uloop_timeout ubus_timer;
static int timeout;
Expand Down
Loading