diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-07-15 19:10:06 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2007-07-15 19:10:06 +0200 |
commit | 254d6d3ca2188a396706b363d0840431d360fbd9 (patch) | |
tree | 762216cf0122b28c74b8c0c9660033f50d29970a /udevd.c | |
parent | 9aeded07a0229a64cdc1ec8999ad2e2c58e4d38f (diff) |
handle dynamic rules created in /dev/.udev/rules.d/
Diffstat (limited to 'udevd.c')
-rw-r--r-- | udevd.c | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -1102,10 +1102,17 @@ int main(int argc, char *argv[], char *envp[]) /* watch rules directory */ inotify_fd = inotify_init(); - if (inotify_fd >= 0) + if (inotify_fd >= 0) { + char filename[PATH_MAX]; + inotify_add_watch(inotify_fd, udev_rules_dir, IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE); - else if (errno == ENOSYS) - err("the kernel does not support inotify, udevd can't monitor configuration file changes"); + + /* watch dynamic rules directory */ + strlcpy(filename, udev_root, sizeof(filename)); + strlcat(filename, "/"RULES_DYN_DIR, sizeof(filename)); + inotify_add_watch(inotify_fd, filename, IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE); + } else if (errno == ENOSYS) + err("the kernel does not support inotify, udevd can't monitor rules file changes"); else err("inotify_init failed: %s", strerror(errno)); @@ -1190,12 +1197,12 @@ int main(int argc, char *argv[], char *envp[]) int nbytes; /* discard all possible events, we can just reload the config */ - if ((ioctl(inotify_fd, FIONREAD, &nbytes) == 0) && nbytes) { + if ((ioctl(inotify_fd, FIONREAD, &nbytes) == 0) && nbytes > 0) { char *buf; reload_config = 1; buf = malloc(nbytes); - if (!buf) { + if (buf != NULL) { err("error getting buffer for inotify, disable watching"); close(inotify_fd); inotify_fd = -1; |