mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 14:02:52 +07:00
Merge pull request #478 from mattiaswal/fix-initial-devmon
devmon: assert condition immediately if device already exists 1. udev fires early, creates device nodes in /dev/ 2. Config is parsed later, calling devmon_add_cond() for each dev/ condition 3. At this point the device already exists but the inotify event was missed 4. The PR's fexist() check catches this — new node is added to the TAILQ and condition is immediately asserted Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -75,6 +75,7 @@ static void drop_node(struct dev_node *node)
|
||||
void devmon_add_cond(const char *cond)
|
||||
{
|
||||
struct dev_node *node;
|
||||
char path[PATH_MAX];
|
||||
|
||||
if (!cond || strncmp(cond, "dev/", 4)) {
|
||||
// dbg("no match %s", cond ?: "<NIL>");
|
||||
@@ -103,6 +104,10 @@ void devmon_add_cond(const char *cond)
|
||||
node->refcnt = 1;
|
||||
|
||||
TAILQ_INSERT_TAIL(&dev_node_list, node, link);
|
||||
|
||||
snprintf(path, sizeof(path), "/%s", cond);
|
||||
if (fexist(path))
|
||||
cond_set(cond);
|
||||
}
|
||||
|
||||
void devmon_del_cond(const char *cond)
|
||||
|
||||
Reference in New Issue
Block a user