Skip to content
Merged
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
16 changes: 15 additions & 1 deletion src/devmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,26 @@ void devmon_add_cond(const char *cond)

void devmon_del_cond(const char *cond)
{
if (!cond || strcmp(cond, "dev/"))
if (!cond || strncmp(cond, COND_DEV, strlen(COND_DEV)))
return;

drop_node(find_node(cond));
}

void devmon_reconf(void)
{
struct dev_node *node, *tmp;
char path[PATH_MAX];

TAILQ_FOREACH_SAFE(node, &dev_node_list, link, tmp) {
snprintf(path, sizeof(path), "/%s", node->name);
if (fexist(path))
cond_set(node->name);
else
cond_clear(node->name);
}
}

static int devmon_add_path(struct iwatch *iw, char *path)
{
char *ptr;
Expand Down
1 change: 1 addition & 0 deletions src/devmon.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
void devmon_add_cond(const char *cond);
void devmon_del_cond(const char *cond);

void devmon_reconf(void);
void devmon_init(uev_ctx_t *ctx);

#endif /* FINIT_DEVMON_H_ */
4 changes: 4 additions & 0 deletions src/sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "cgroup.h"
#include "cond.h"
#include "conf.h"
#include "devmon.h"
#include "log.h"
#include "helpers.h"
#include "private.h"
Expand Down Expand Up @@ -515,6 +516,9 @@ void sm_step(void)
dbg("Calling reconf hooks ...");
plugin_run_hooks(HOOK_SVC_RECONF);

dbg("Update configuration generation of device conditions ...");
devmon_reconf();

dbg("Update configuration generation of unmodified non-native services ...");
service_notify_reconf();

Expand Down
5 changes: 5 additions & 0 deletions test/devmon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ test_one()

mkdev "$node"
assert_status "serv" "running"
assert_cond "$cond"

run "initctl reload"
assert_status "serv" "running"
assert_cond "$cond"

rmdev "$node"
assert_status "serv" "waiting"
Expand Down