1 |
From dc67bd34a6c04ac97702df6eddff99b960fe3d9f Mon Sep 17 00:00:00 2001 |
2 |
From: Colin Guthrie <colin@mageia.org> |
3 |
Date: Wed, 11 Apr 2012 16:02:21 +0100 |
4 |
Subject: [PATCH 503/509] udev: Allow the 'udevadm settle' timeout to be set |
5 |
via the kernel cmdline |
6 |
|
7 |
On some really old hardware, the default timeout of 120 (which may even |
8 |
be reduced further on the command line) is insufficient. |
9 |
|
10 |
While such cases are specialist and (nowadays) relatively rare, it is |
11 |
still nice to be able to provide a method to increase the timeout |
12 |
when needed. |
13 |
|
14 |
Bug Link: https://bugs.mageia.org/show_bug.cgi?id=3315 |
15 |
--- |
16 |
src/udev/udevadm-settle.c | 34 ++++++++++++++++++++++++++++++++++ |
17 |
1 file changed, 34 insertions(+) |
18 |
|
19 |
diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c |
20 |
index 0af3e6412..980d2e721 100644 |
21 |
--- a/src/udev/udevadm-settle.c |
22 |
+++ b/src/udev/udevadm-settle.c |
23 |
@@ -27,7 +27,9 @@ |
24 |
#include <string.h> |
25 |
#include <unistd.h> |
26 |
|
27 |
+#include "fileio.h" |
28 |
#include "parse-util.h" |
29 |
+#include "string-util.h" |
30 |
#include "udev.h" |
31 |
#include "udevadm-util.h" |
32 |
#include "util.h" |
33 |
@@ -56,6 +58,7 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) { |
34 |
usec_t deadline; |
35 |
const char *exists = NULL; |
36 |
unsigned int timeout = 120; |
37 |
+ char *line; |
38 |
struct pollfd pfd[1] = { {.fd = -1}, }; |
39 |
int c; |
40 |
struct udev_queue *queue; |
41 |
@@ -106,6 +109,37 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) { |
42 |
return EXIT_FAILURE; |
43 |
} |
44 |
|
45 |
+ /* |
46 |
+ * read the kernel commandline, in case we need to tweak timeout |
47 |
+ * udev.settle-timeout=<timeout> settle timeout |
48 |
+ * |
49 |
+ */ |
50 |
+ if (read_one_line_file("/proc/cmdline", &line) >= 0) { |
51 |
+ char *w, *state; |
52 |
+ size_t l; |
53 |
+ |
54 |
+ FOREACH_WORD_QUOTED(w, l, line, state) { |
55 |
+ char *s, *opt; |
56 |
+ |
57 |
+ s = strndup(w, l); |
58 |
+ if (!s) |
59 |
+ break; |
60 |
+ |
61 |
+ /* accept the same options for the initrd, prefixed with "rd." */ |
62 |
+ if (in_initrd() && startswith(s, "rd.")) |
63 |
+ opt = s + 3; |
64 |
+ else |
65 |
+ opt = s; |
66 |
+ |
67 |
+ if (startswith(opt, "udev.settle-timeout=") && safe_atou(opt + 20, &timeout) >= 0) |
68 |
+ log_debug("timeout=%i (via kernel cmdline)\n", timeout); |
69 |
+ |
70 |
+ free(s); |
71 |
+ } |
72 |
+ |
73 |
+ free(line); |
74 |
+ } |
75 |
+ |
76 |
deadline = now(CLOCK_MONOTONIC) + timeout * USEC_PER_SEC; |
77 |
|
78 |
/* guarantee that the udev daemon isn't pre-processing */ |
79 |
-- |
80 |
2.13.5 |
81 |
|