Don't add inotify watch until RUN rules processed.

The programs we RUN can open device nodes, and thus we can end up
chasing our own tail.
This commit is contained in:
Scott James Remnant 2009-02-23 17:17:20 +00:00
parent e8c84c98b9
commit 5ae82640c5
2 changed files with 10 additions and 8 deletions

View file

@ -600,14 +600,6 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules)
/* create new node and symlinks */
err = udev_node_add(dev, event->mode, event->uid, event->gid);
/* watch for changes */
if (event->inotify_watch && inotify_fd != -1) {
info(event->udev, "device will be watched for changes\n");
udev_watch_begin(event->udev, event->dev);
} else {
udev_watch_clear(event->udev, event->dev);
}
goto exit;
}

View file

@ -226,6 +226,16 @@ static void event_fork(struct udev_event *event)
if (err == 0 && !event->ignore_device && udev_get_run(event->udev))
udev_event_execute_run(event);
/* apply/restore inotify watch */
if (err == 0 && event->inotify_watch && inotify_fd != -1 &&
major(udev_device_get_devnum(event->dev)) != 0 &&
strcmp(udev_device_get_action(event->dev), "remove") != 0) {
info(event->udev, "device will be watched for changes\n");
udev_watch_begin(event->udev, event->dev);
} else {
udev_watch_clear(event->udev, event->dev);
}
info(event->udev, "seq %llu exit with %i\n", udev_device_get_seqnum(event->dev), err);
logging_close();
if (err != 0)