Commits

braindamaged committed cb641e8

udev: kernel cmdline parsing moved

Comments (0)

Files changed (1)

         return changed;
 }
 
+/*
+ * read the kernel commandline, in case we need to get into debug mode
+ * udev.log-priority=<level>              syslog priority
+ * udev.children-max=<number of workers>  events are fully serialized if set to 1
+ * udev.exec-delay=<number of seconds>    delay execution of every executed program
+ */
+
+static void kernel_cmdline_opts(struct udev *udev)
+{
+        FILE *f;
+
+        f = fopen("/proc/cmdline", "r");
+        if (f != NULL) {
+                char cmdline[4096];
+
+                if (fgets(cmdline, sizeof(cmdline), f) != NULL) {
+                        char *pos;
+
+                        pos = strstr(cmdline, "udev.log-priority=");
+                        if (pos != NULL) {
+                                pos += strlen("udev.log-priority=");
+                                udev_set_log_priority(udev, util_log_priority(pos));
+                        }
+
+                        pos = strstr(cmdline, "udev.children-max=");
+                        if (pos != NULL) {
+                                pos += strlen("udev.children-max=");
+                                children_max = strtoul(pos, NULL, 0);
+                        }
+
+                        pos = strstr(cmdline, "udev.exec-delay=");
+                        if (pos != NULL) {
+                                pos += strlen("udev.exec-delay=");
+                                exec_delay = strtoul(pos, NULL, 0);
+                        }
+                }
+                fclose(f);
+        }
+}
+
 int main(int argc, char *argv[])
 {
         struct udev *udev;
                 }
         }
 
-        /*
-         * read the kernel commandline, in case we need to get into debug mode
-         *   udev.log-priority=<level>              syslog priority
-         *   udev.children-max=<number of workers>  events are fully serialized if set to 1
-         *
-         */
-        f = fopen("/proc/cmdline", "r");
-        if (f != NULL) {
-                char cmdline[4096];
-
-                if (fgets(cmdline, sizeof(cmdline), f) != NULL) {
-                        char *pos;
-
-                        pos = strstr(cmdline, "udev.log-priority=");
-                        if (pos != NULL) {
-                                pos += strlen("udev.log-priority=");
-                                udev_set_log_priority(udev, util_log_priority(pos));
-                        }
-
-                        pos = strstr(cmdline, "udev.children-max=");
-                        if (pos != NULL) {
-                                pos += strlen("udev.children-max=");
-                                children_max = strtoul(pos, NULL, 0);
-                        }
-
-                        pos = strstr(cmdline, "udev.exec-delay=");
-                        if (pos != NULL) {
-                                pos += strlen("udev.exec-delay=");
-                                exec_delay = strtoul(pos, NULL, 0);
-                        }
-                }
-                fclose(f);
-        }
+        kernel_cmdline_opts(udev);
 
         if (getuid() != 0) {
                 fprintf(stderr, "root privileges required\n");