[systemd-commits] 2 commits - man/systemd-udevd.xml src/core src/udev

Kay Sievers kay at kemper.freedesktop.org
Mon Jun 4 13:47:04 PDT 2012


 man/systemd-udevd.xml |    4 ++
 src/core/execute.c    |    2 -
 src/udev/udevd.c      |   76 ++++++++++++++++++++++++++++----------------------
 3 files changed, 48 insertions(+), 34 deletions(-)

New commits:
commit e6f86cac1619d504ea51c08608fa60b8e4359c52
Author: Kay Sievers <kay at vrfy.org>
Date:   Mon Jun 4 22:46:32 2012 +0200

    udev: kernel cmdline - accept rd.* parameters

diff --git a/man/systemd-udevd.xml b/man/systemd-udevd.xml
index 1be356f..79f917e 100644
--- a/man/systemd-udevd.xml
+++ b/man/systemd-udevd.xml
@@ -116,20 +116,24 @@
 
   <refsect1><title>Kernel command line</title>
     <variablelist>
+      <para>The parameters starting with "rd.", will be read when udev is used in an initrd.</para>
       <varlistentry>
         <term><varname>udev.log-priority=</varname></term>
+        <term><varname>rd.udev.log-priority=</varname></term>
         <listitem>
           <para>Set the logging priority.</para>
         </listitem>
       </varlistentry>
       <varlistentry>
         <term><varname>udev.children-max=</varname></term>
+        <term><varname>rd.udev.children-max=</varname></term>
         <listitem>
           <para>Limit the number of parallel executed events.</para>
         </listitem>
       </varlistentry>
       <varlistentry>
         <term><varname>udev.exec-delay=</varname></term>
+        <term><varname>rd.udev.exec-delay=</varname></term>
         <listitem>
           <para>Number of seconds to delay the execution of RUN instructions.
           This might be useful when debugging system crashes during coldplug
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 2ac9fde..75e7766 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -1013,6 +1013,48 @@ static int systemd_fds(struct udev *udev, int *rctrl, int *rnetlink)
         return 0;
 }
 
+/*
+ * 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_options(struct udev *udev)
+{
+        char *line, *w, *state;
+        size_t l;
+
+        if (read_one_line_file("/proc/cmdline", &line) < 0)
+                return;
+
+        FOREACH_WORD_QUOTED(w, l, line, state) {
+                char *s, *opt;
+
+                s = strndup(w, l);
+                if (!s)
+                        break;
+
+                /* accept the same options for the initrd, prefixed with "rd." */
+                if (in_initrd() && startswith(s, "rd."))
+                        opt = s + 3;
+                else
+                        opt = s;
+
+                if (startswith(opt, "udev.log-priority="))
+                        udev_set_log_priority(udev, util_log_priority(opt + 18));
+
+                if (startswith(opt, "udev.children-max="))
+                        children_max = strtoul(opt + 18, NULL, 0);
+
+                if (startswith(opt, "udev.exec-delay="))
+                        exec_delay = strtoul(opt + 16, NULL, 0);
+
+                free(s);
+        }
+
+        free(line);
+}
+
 int main(int argc, char *argv[])
 {
         struct udev *udev;
@@ -1101,39 +1143,7 @@ int main(int argc, char *argv[])
                 }
         }
 
-        /*
-         * 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_options(udev);
 
         if (getuid() != 0) {
                 fprintf(stderr, "root privileges required\n");

commit f96096dbbf0cc7335babf0386b8888431cd70728
Author: Kay Sievers <kay at vrfy.org>
Date:   Mon Jun 4 22:27:39 2012 +0200

    silence gcc warning on 32 bit

diff --git a/src/core/execute.c b/src/core/execute.c
index 1b56f6b..bbc430e 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1728,7 +1728,7 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
         }
 
         if (c->timer_slack_nsec != (nsec_t) -1)
-                fprintf(f, "%sTimerSlackNSec: %lu\n", prefix, c->timer_slack_nsec);
+                fprintf(f, "%sTimerSlackNSec: %lu\n", prefix, (unsigned long)c->timer_slack_nsec);
 
         fprintf(f,
                 "%sStandardInput: %s\n"



More information about the systemd-commits mailing list