- fd = open("/dev/kmsg", O_WRONLY);
- if (fd > 0) {
- const char *str = "<6>udevd version " VERSION " started\n";
-
- write(fd, str, strlen(str));
- close(fd);
- }
-
- /* set signal handlers */
- memset(&act, 0x00, sizeof(struct sigaction));
- act.sa_handler = (void (*)(int)) sig_handler;
- sigemptyset(&act.sa_mask);
- act.sa_flags = SA_RESTART;
- sigaction(SIGINT, &act, NULL);
- sigaction(SIGTERM, &act, NULL);
- sigaction(SIGCHLD, &act, NULL);
- sigaction(SIGHUP, &act, NULL);
-
- /* watch rules directory */
- inotify_fd = inotify_init();
- if (inotify_fd >= 0) {
- if (udev_rules_dir[0] != '\0') {
- inotify_add_watch(inotify_fd, udev_rules_dir,
- IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
- } else {
- char filename[PATH_MAX];
-
- inotify_add_watch(inotify_fd, UDEV_PREFIX "/lib/udev/rules.d",
- IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
- inotify_add_watch(inotify_fd, SYSCONFDIR "/udev/rules.d",
- IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
-
- /* watch dynamic rules directory */
- strlcpy(filename, udev_root, sizeof(filename));
- strlcat(filename, "/.udev/rules.d", 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\n");
- else
- err("inotify_init failed: %s\n", strerror(errno));
-
- /* maximum limit of forked childs */
- value = getenv("UDEVD_MAX_CHILDS");
- if (value)
- max_childs = strtoul(value, NULL, 10);
- else {