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");
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.