Skip to content

Commit e1fe870

Browse files
authored
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 <[email protected]>
2 parents 7aa9ed5 + f04fce5 commit e1fe870

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/devmon.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ static void drop_node(struct dev_node *node)
7575
void devmon_add_cond(const char *cond)
7676
{
7777
struct dev_node *node;
78+
char path[PATH_MAX];
7879

7980
if (!cond || strncmp(cond, "dev/", 4)) {
8081
// dbg("no match %s", cond ?: "<NIL>");
@@ -103,6 +104,10 @@ void devmon_add_cond(const char *cond)
103104
node->refcnt = 1;
104105

105106
TAILQ_INSERT_TAIL(&dev_node_list, node, link);
107+
108+
snprintf(path, sizeof(path), "/%s", cond);
109+
if (fexist(path))
110+
cond_set(cond);
106111
}
107112

108113
void devmon_del_cond(const char *cond)

0 commit comments

Comments
 (0)