[systemd-devel] [PATCH 3/4] udev: Allow the 'udevadm settle' timeout to be set via the kernel cmdline

Colin Guthrie colin at mageia.org
Mon Jul 2 01:15:54 PDT 2012


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 | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c
index e70b351..37c0db1 100644
--- a/src/udev/udevadm-settle.c
+++ b/src/udev/udevadm-settle.c
@@ -53,6 +53,7 @@ static int adm_settle(struct udev *udev, int argc, char *argv[])
         int quiet = 0;
         const char *exists = NULL;
         unsigned int timeout = 120;
+        FILE *f;
         struct pollfd pfd[1] = { {.fd = -1}, };
         struct udev_queue *udev_queue = NULL;
         int rc = EXIT_FAILURE;
@@ -99,6 +100,28 @@ static int adm_settle(struct udev *udev, int argc, char *argv[])
                 }
         }
 
+        /*
+         * read the kernel commandline, in case we need to tweak timeout
+         *   udev.settle-timeout=<timeout>  settle timeout
+         *
+         */
+        f = fopen("/proc/cmdline", "r");
+        if (f != NULL) {
+                char cmdline[4096];
+
+                if (fgets(cmdline, sizeof(cmdline), f) != NULL) {
+                        char *pos;
+
+                        pos = strstr(cmdline, "udev.settle-timeout=");
+                        if (pos != NULL) {
+                                pos += strlen("udev.settle-timeout=");
+                                timeout = strtoul(pos, NULL, 0);
+                                log_debug("timeout=%i (via kernel cmdline)\n", timeout);
+                        }
+                }
+                fclose(f);
+        }
+
         udev_queue = udev_queue_new(udev);
         if (udev_queue == NULL)
                 exit(2);
-- 
1.7.11



More information about the systemd-devel mailing list