Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-updates-src > by-pkgid > afb9784a56b892cac8e79bfb9f238d3a > files > 14

systemd-230-12.3.mga6.src.rpm

From 1ce8f7b14870335b1a6c593d7921387444c28d72 Mon Sep 17 00:00:00 2001
From: Colin Guthrie <colin@mageia.org>
Date: Wed, 11 Apr 2012 16:02:21 +0100
Subject: [PATCH] udev: Allow the 'udevadm settle' timeout to be set via the
 kernel cmdline

On some really old hardware, the default timeout of 120 (which may even
be reduced further on the command line) is insufficient.

While such cases are specialist and (nowadays) relatively rare, it is
still nice to be able to provide a method to increase the timeout
when needed.

Bug Link: https://bugs.mageia.org/show_bug.cgi?id=3315
---
 src/udev/udevadm-settle.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c
index 6a5dc6e..624f497 100644
--- a/src/udev/udevadm-settle.c
+++ b/src/udev/udevadm-settle.c
@@ -26,7 +26,9 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "fileio.h"
 #include "parse-util.h"
+#include "string-util.h"
 #include "udev.h"
 #include "util.h"
 
@@ -53,6 +55,7 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) {
         usec_t deadline;
         const char *exists = NULL;
         unsigned int timeout = 120;
+        char *line;
         struct pollfd pfd[1] = { {.fd = -1}, };
         int c;
         struct udev_queue *queue;
@@ -99,6 +102,37 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) {
                 return EXIT_FAILURE;
         }
 
+        /*
+         * read the kernel commandline, in case we need to tweak timeout
+         *   udev.settle-timeout=<timeout>  settle timeout
+         *
+         */
+        if (read_one_line_file("/proc/cmdline", &line) >= 0) {
+                char *w, *state;
+                size_t l;
+
+                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.settle-timeout=") && safe_atou(opt + 20, &timeout) >= 0)
+                                log_debug("timeout=%i (via kernel cmdline)\n", timeout);
+
+                        free(s);
+                }
+
+                free(line);
+        }
+
         deadline = now(CLOCK_MONOTONIC) + timeout * USEC_PER_SEC;
 
         /* guarantee that the udev daemon isn't pre-processing */
-- 
2.5.0