chiark / gitweb /
remove asmlinkage
[elogind.git] / udev / udevd.c
index 6de1196421eacd096da57fea3c78e95bb3cb1358..419c486ddd4fca09a341fb5d551337090c7e95ce 100644 (file)
@@ -67,10 +67,10 @@ static int debug_trace;
 static struct udev_rules *rules;
 static struct udev_ctrl *udev_ctrl;
 static struct udev_monitor *kernel_monitor;
-static volatile int sigchilds_waiting;
-static volatile int udev_exit;
-static volatile int reload_config;
-static volatile int signal_received;
+static volatile sig_atomic_t sigchilds_waiting;
+static volatile sig_atomic_t udev_exit;
+static volatile sig_atomic_t reload_config;
+static volatile sig_atomic_t signal_received;
 static volatile pid_t settle_pid;
 static int run_exec_q;
 static int stop_exec_q;
@@ -172,10 +172,10 @@ static void event_queue_delete(struct udev_event *event)
        udev_event_unref(event);
 }
 
-static void asmlinkage event_sig_handler(int signum)
+static void event_sig_handler(int signum)
 {
        if (signum == SIGALRM)
-               exit(1);
+               _exit(1);
 }
 
 static void event_fork(struct udev_event *event)
@@ -202,7 +202,7 @@ static void event_fork(struct udev_event *event)
 
                /* set signal handlers */
                memset(&act, 0x00, sizeof(act));
-               act.sa_handler = (void (*)(int)) event_sig_handler;
+               act.sa_handler = event_sig_handler;
                sigemptyset (&act.sa_mask);
                act.sa_flags = 0;
                sigaction(SIGALRM, &act, NULL);
@@ -295,7 +295,7 @@ static void event_queue_insert(struct udev_event *event)
 
 static int mem_size_mb(void)
 {
-       FILEf;
+       FILE *f;
        char buf[4096];
        long int memsize = -1;
 
@@ -339,7 +339,7 @@ static int compare_devpath(const char *running, const char *waiting)
        return 0;
 }
 
-/* lookup event for identical, parent, child, or physical device */
+/* lookup event for identical, parent, child device */
 static int devpath_busy(struct udev_event *event)
 {
        struct udev_list_node *loop;
@@ -390,19 +390,6 @@ static int devpath_busy(struct udev_event *event)
                        event->delaying_seqnum = udev_device_get_seqnum(loop_event->dev);
                        return 5;
                }
-
-               /* check physical device event (special case of parent) */
-               if (udev_device_get_physdevpath(event->dev) != NULL &&
-                   strcmp(udev_device_get_action(event->dev), "add") == 0)
-                       if (compare_devpath(udev_device_get_devpath(loop_event->dev),
-                                           udev_device_get_physdevpath(event->dev)) != 0) {
-                               dbg(event->udev, "%llu, physical device event still pending %llu (%s)\n",
-                                   udev_device_get_seqnum(event->dev),
-                                   udev_device_get_seqnum(loop_event->dev),
-                                   udev_device_get_devpath(loop_event->dev));
-                               event->delaying_seqnum = udev_device_get_seqnum(loop_event->dev);
-                               return 6;
-                       }
        }
        return 0;
 }
@@ -583,7 +570,7 @@ static int handle_inotify(struct udev *udev)
        return 0;
 }
 
-static void asmlinkage sig_handler(int signum)
+static void sig_handler(int signum)
 {
        switch (signum) {
                case SIGINT:
@@ -708,6 +695,34 @@ static void export_initial_seqnum(struct udev *udev)
        }
 }
 
+static void startup_log(struct udev *udev)
+{
+       FILE *f;
+       char path[UTIL_PATH_SIZE];
+       struct stat statbuf;
+
+       f = fopen("/dev/kmsg", "w");
+       if (f != NULL)
+               fprintf(f, "<6>udev: starting version " VERSION "\n");
+
+       util_strlcpy(path, udev_get_sys_path(udev), sizeof(path));
+       util_strlcat(path, "/class/mem/null", sizeof(path));
+       if (lstat(path, &statbuf) == 0 && S_ISDIR(statbuf.st_mode)) {
+               const char *depr_str =
+                       "udev: missing sysfs features; please update the kernel "
+                       "or disable the kernel's CONFIG_SYSFS_DEPRECATED option; "
+                       "udev may fail to work correctly";
+
+               if (f != NULL)
+                       fprintf(f, "<3>%s\n", depr_str);
+               err(udev, "%s\n", depr_str);
+               sleep(3);
+       }
+
+       if (f != NULL)
+               fclose(f);
+}
+
 int main(int argc, char *argv[])
 {
        struct udev *udev;
@@ -875,31 +890,11 @@ int main(int argc, char *argv[])
                close(fd);
        }
 
-       fd = open("/dev/kmsg", O_WRONLY);
-       if (fd > 0) {
-               const char *ver_str = "<6>udev: starting version " VERSION "\n";
-               char path[UTIL_PATH_SIZE];
-               struct stat statbuf;
-
-               write(fd, ver_str, strlen(ver_str));
-               util_strlcpy(path, udev_get_sys_path(udev), sizeof(path));
-               util_strlcat(path, "/class/mem/null", sizeof(path));
-               if (lstat(path, &statbuf) == 0) {
-                       if (S_ISDIR(statbuf.st_mode)) {
-                               const char *depr_str =
-                                       "<6>udev: deprecated sysfs layout; update the kernel or "
-                                       "disable CONFIG_SYSFS_DEPRECATED; some udev features will "
-                                       "not work correctly\n";
-
-                               write(fd, depr_str, strlen(depr_str));
-                       }
-               }
-               close(fd);
-       }
+       startup_log(udev);
 
        /* set signal handlers */
        memset(&act, 0x00, sizeof(struct sigaction));
-       act.sa_handler = (void (*)(int)) sig_handler;
+       act.sa_handler = sig_handler;
        sigemptyset(&act.sa_mask);
        act.sa_flags = SA_RESTART;
        sigaction(SIGINT, &act, NULL);