chiark / gitweb /
rules: fix typo in 80-drivers.rules
[elogind.git] / udevd.c
diff --git a/udevd.c b/udevd.c
index 0999b5fa756bfc7b553dd413fa9672ca388dc9be..8f56de6ffb7670f12e6d732062fcc9d97db68165 100644 (file)
--- a/udevd.c
+++ b/udevd.c
@@ -135,24 +135,8 @@ static int udev_event_process(struct udevd_uevent_msg *msg)
        retval = udev_device_event(&rules, udev);
 
        /* run programs collected by RUN-key*/
-       if (retval == 0 && !udev->ignore_device && udev_run) {
-               struct name_entry *name_loop;
-
-               dbg("executing run list");
-               list_for_each_entry(name_loop, &udev->run_list, node) {
-                       if (strncmp(name_loop->name, "socket:", strlen("socket:")) == 0)
-                               pass_env_to_socket(&name_loop->name[strlen("socket:")], udev->dev->devpath, udev->action);
-                       else {
-                               char program[PATH_SIZE];
-
-                               strlcpy(program, name_loop->name, sizeof(program));
-                               udev_rules_apply_format(udev, program, sizeof(program));
-                               if (run_program(program, udev->dev->subsystem, NULL, 0, NULL,
-                                               (udev_log_priority >= LOG_INFO)))
-                                       retval = -1;
-                       }
-               }
-       }
+       if (retval == 0 && !udev->ignore_device && udev_run)
+               retval = udev_rules_run(udev);
 
        udev_device_cleanup(udev);
        return retval;
@@ -258,7 +242,7 @@ static void udev_event_run(struct udevd_uevent_msg *msg)
                setpriority(PRIO_PROCESS, 0, UDEV_PRIORITY);
 
                retval = udev_event_process(msg);
-               info("seq %llu finished", msg->seqnum);
+               info("seq %llu finished with %i", msg->seqnum, retval);
 
                logging_close();
                if (retval)
@@ -1118,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));
 
@@ -1206,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;