From b206c3d655d65883da7f9a9b33065eea8039d542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= Date: Tue, 10 Feb 2026 19:51:22 +0100 Subject: [PATCH] devmon: re-evaluate device conditions on reconf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Device conditions tracked by devmon were lost on `initctl reload` because the reconf path did not re-assert them. Add devmon_reconf() to iterate all tracked device nodes and set or clear their conditions based on current device presence. Signed-off-by: Mattias Walström --- src/devmon.c | 14 ++++++++++++++ src/devmon.h | 1 + src/sm.c | 4 ++++ test/devmon.sh | 5 +++++ 4 files changed, 24 insertions(+) diff --git a/src/devmon.c b/src/devmon.c index 2341e86d..aa6b62ed 100644 --- a/src/devmon.c +++ b/src/devmon.c @@ -113,6 +113,20 @@ void devmon_del_cond(const char *cond) 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; diff --git a/src/devmon.h b/src/devmon.h index 3f7937e8..39f5b036 100644 --- a/src/devmon.h +++ b/src/devmon.h @@ -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_ */ diff --git a/src/sm.c b/src/sm.c index a1e982b2..213c0203 100644 --- a/src/sm.c +++ b/src/sm.c @@ -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" @@ -515,6 +516,9 @@ restart: 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(); diff --git a/test/devmon.sh b/test/devmon.sh index 7efd2bcf..cbf42eb8 100755 --- a/test/devmon.sh +++ b/test/devmon.sh @@ -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"