Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-updates-src > by-pkgid > 3dd8bca5a331f46a5ba1cbec6d91c01d > files > 26

systemd-217-11.2.mga5.src.rpm

From 856d4e41e6ec53e2aa4105a07b67bce1b6cfe4b4 Mon Sep 17 00:00:00 2001
From: Colin Guthrie <colin@mageia.org>
Date: Wed, 11 Apr 2012 16:02:21 +0100
Subject: [PATCH 506/511] 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 | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c
index fa5b0c2..78ec642 100644
--- a/src/udev/udevadm-settle.c
+++ b/src/udev/udevadm-settle.c
@@ -34,6 +34,7 @@
 #include <sys/types.h>
 
 #include "udev.h"
+#include "fileio.h"
 #include "udev-util.h"
 #include "util.h"
 
@@ -57,6 +58,7 @@ static int adm_settle(struct udev *udev, int argc, char *argv[])
         };
         const char *exists = NULL;
         unsigned int timeout = 120;
+        char *line;
         struct pollfd pfd[1] = { {.fd = -1}, };
         int c;
         struct udev_queue *queue;
@@ -93,6 +95,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);
+        }
+
         /* guarantee that the udev daemon isn't pre-processing */
         if (getuid() == 0) {
                 struct udev_ctrl *uctrl;
-- 
1.9.2