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

Lennart Poettering lennart at poettering.net
Mon Jul 2 01:48:55 PDT 2012


On Mon, 02.07.12 09:15, Colin Guthrie (colin at mageia.org) wrote:

> 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.

Hmpf, the idea of settling things is borked, and just increasing the
timeout doesn't really fix that...

But anyway:

> +        /*
> +         * 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);
> +        }

Could you please use read_one_line_file() instead? Could you also please
use FOREACH_WORD to iterate through it, so that word boundaries are
respected? Also, please use safe_atou() to parse the integer? it gets
the error handling right, which is relly hard to with naked strtoul().

Thanks!

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list