Sophie

Sophie

distrib > Mageia > 9 > armv7hl > media > core-release-src > by-pkgid > f688fb39cfed0426a20c0bac7361c521 > files > 3

systemd-253.7-1.mga9.src.rpm

From dc67bd34a6c04ac97702df6eddff99b960fe3d9f Mon Sep 17 00:00:00 2001
From: Colin Guthrie <colin@mageia.org>
Date: Wed, 11 Apr 2012 16:02:21 +0100
Subject: [PATCH 503/509] 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 0af3e6412..980d2e721 100644
--- a/src/udev/udevadm-settle.c
+++ b/src/udev/udevadm-settle.c
@@ -27,7 +27,9 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "fileio.h"
 #include "parse-util.h"
+#include "string-util.h"
 #include "udev.h"
 #include "udevadm-util.h"
 #include "util.h"
@@ -56,6 +58,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;
@@ -106,6 +109,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.13.5