DEFINE_STRING_TABLE_LOOKUP(resolve_name_timing, ResolveNameTiming);
-int udev_parse_config_full(
- unsigned *ret_children_max,
- usec_t *ret_exec_delay_usec,
- usec_t *ret_event_timeout_usec,
- ResolveNameTiming *ret_resolve_name_timing,
- int *ret_timeout_signal) {
-
- _cleanup_free_ char *log_val = NULL, *children_max = NULL, *exec_delay = NULL, *event_timeout = NULL, *resolve_names = NULL, *timeout_signal = NULL;
- int r;
+int udev_set_max_log_level(char *str) {
+ size_t n;
- r = parse_env_file(NULL, "/etc/udev/udev.conf",
- "udev_log", &log_val,
- "children_max", &children_max,
- "exec_delay", &exec_delay,
- "event_timeout", &event_timeout,
- "resolve_names", &resolve_names,
- "timeout_signal", &timeout_signal);
- if (r == -ENOENT)
- return 0;
- if (r < 0)
- return r;
+ /* This may modify input string. */
- if (log_val) {
- const char *log;
- size_t n;
-
- /* unquote */
- n = strlen(log_val);
- if (n >= 2 &&
- ((log_val[0] == '"' && log_val[n-1] == '"') ||
- (log_val[0] == '\'' && log_val[n-1] == '\''))) {
- log_val[n - 1] = '\0';
- log = log_val + 1;
- } else
- log = log_val;
-
- /* we set the udev log level here explicitly, this is supposed
- * to regulate the code in libudev/ and udev/. */
- r = log_set_max_level_from_string(log);
- if (r < 0)
- log_syntax(NULL, LOG_WARNING, "/etc/udev/udev.conf", 0, r,
- "failed to set udev log level '%s', ignoring: %m", log);
- }
-
- if (ret_children_max && children_max) {
- r = safe_atou(children_max, ret_children_max);
- if (r < 0)
- log_syntax(NULL, LOG_WARNING, "/etc/udev/udev.conf", 0, r,
- "failed to parse children_max=%s, ignoring: %m", children_max);
- }
+ if (isempty(str))
+ return 0;
- if (ret_exec_delay_usec && exec_delay) {
- r = parse_sec(exec_delay, ret_exec_delay_usec);
- if (r < 0)
- log_syntax(NULL, LOG_WARNING, "/etc/udev/udev.conf", 0, r,
- "failed to parse exec_delay=%s, ignoring: %m", exec_delay);
+ /* unquote */
+ n = strlen(str);
+ if (n >= 2 &&
+ ((str[0] == '"' && str[n - 1] == '"') ||
+ (str[0] == '\'' && str[n - 1] == '\''))) {
+ str[n - 1] = '\0';
+ str++;
}
- if (ret_event_timeout_usec && event_timeout) {
- r = parse_sec(event_timeout, ret_event_timeout_usec);
- if (r < 0)
- log_syntax(NULL, LOG_WARNING, "/etc/udev/udev.conf", 0, r,
- "failed to parse event_timeout=%s, ignoring: %m", event_timeout);
- }
+ /* we set the udev log level here explicitly, this is supposed
+ * to regulate the code in libudev/ and udev/. */
+ return log_set_max_level_from_string(str);
+}
- if (ret_resolve_name_timing && resolve_names) {
- ResolveNameTiming t;
+int udev_parse_config(void) {
+ _cleanup_free_ char *log_val = NULL;
+ int r;
- t = resolve_name_timing_from_string(resolve_names);
- if (t < 0)
- log_syntax(NULL, LOG_WARNING, "/etc/udev/udev.conf", 0, r,
- "failed to parse resolve_names=%s, ignoring.", resolve_names);
- else
- *ret_resolve_name_timing = t;
- }
+ r = parse_env_file(NULL, "/etc/udev/udev.conf",
+ "udev_log", &log_val);
+ if (r == -ENOENT)
+ return 0;
+ if (r < 0)
+ return r;
- if (ret_timeout_signal && timeout_signal) {
- r = signal_from_string(timeout_signal);
- if (r < 0)
- log_syntax(NULL, LOG_WARNING, "/etc/udev/udev.conf", 0, r,
- "failed to parse timeout_signal=%s, ignoring: %m", timeout_signal);
- else
- *ret_timeout_signal = r;
- }
+ r = udev_set_max_log_level(log_val);
+ if (r < 0)
+ log_syntax(NULL, LOG_WARNING, "/etc/udev/udev.conf", 0, r,
+ "Failed to set udev log level '%s', ignoring: %m", log_val);
return 0;
}
ResolveNameTiming resolve_name_timing_from_string(const char *s) _pure_;
const char *resolve_name_timing_to_string(ResolveNameTiming i) _const_;
-int udev_parse_config_full(
- unsigned *ret_children_max,
- usec_t *ret_exec_delay_usec,
- usec_t *ret_event_timeout_usec,
- ResolveNameTiming *ret_resolve_name_timing,
- int *ret_timeout_signal);
-
-static inline int udev_parse_config(void) {
- return udev_parse_config_full(NULL, NULL, NULL, NULL, NULL);
-}
+int udev_set_max_log_level(char *str);
+int udev_parse_config(void);
int device_wait_for_initialization(sd_device *device, const char *subsystem, usec_t timeout_usec, sd_device **ret);
int device_wait_for_devlink(const char *path, const char *subsystem, usec_t timeout_usec, sd_device **ret);
#include "sd-daemon.h"
#include "cpu-set-util.h"
+#include "env-file.h"
#include "errno-util.h"
#include "fd-util.h"
#include "limits-util.h"
#include "signal-util.h"
#include "syslog-util.h"
#include "udev-manager.h"
+#include "udev-util.h"
#include "udevd.h"
#include "version.h"
return 0;
}
+static int manager_parse_udev_config(Manager *manager) {
+ _cleanup_free_ char *log_val = NULL, *children_max = NULL, *exec_delay = NULL,
+ *event_timeout = NULL, *resolve_names = NULL, *timeout_signal = NULL;
+ int r;
+
+ assert(manager);
+
+ r = parse_env_file(NULL, "/etc/udev/udev.conf",
+ "udev_log", &log_val,
+ "children_max", &children_max,
+ "exec_delay", &exec_delay,
+ "event_timeout", &event_timeout,
+ "resolve_names", &resolve_names,
+ "timeout_signal", &timeout_signal);
+ if (r == -ENOENT)
+ return 0;
+ if (r < 0)
+ return r;
+
+ r = udev_set_max_log_level(log_val);
+ if (r < 0)
+ log_syntax(NULL, LOG_WARNING, "/etc/udev/udev.conf", 0, r,
+ "Failed to set udev log level '%s', ignoring: %m", log_val);
+
+ if (children_max) {
+ r = safe_atou(children_max, &manager->children_max);
+ if (r < 0)
+ log_syntax(NULL, LOG_WARNING, "/etc/udev/udev.conf", 0, r,
+ "Failed to parse children_max=%s, ignoring: %m", children_max);
+ }
+
+ if (exec_delay) {
+ r = parse_sec(exec_delay, &manager->exec_delay_usec);
+ if (r < 0)
+ log_syntax(NULL, LOG_WARNING, "/etc/udev/udev.conf", 0, r,
+ "Failed to parse exec_delay=%s, ignoring: %m", exec_delay);
+ }
+
+ if (event_timeout) {
+ r = parse_sec(event_timeout, &manager->timeout_usec);
+ if (r < 0)
+ log_syntax(NULL, LOG_WARNING, "/etc/udev/udev.conf", 0, r,
+ "Failed to parse event_timeout=%s, ignoring: %m", event_timeout);
+ }
+
+ if (resolve_names) {
+ ResolveNameTiming t;
+
+ t = resolve_name_timing_from_string(resolve_names);
+ if (t < 0)
+ log_syntax(NULL, LOG_WARNING, "/etc/udev/udev.conf", 0, r,
+ "Failed to parse resolve_names=%s, ignoring.", resolve_names);
+ else
+ manager->resolve_name_timing = t;
+ }
+
+ if (timeout_signal) {
+ r = signal_from_string(timeout_signal);
+ if (r < 0)
+ log_syntax(NULL, LOG_WARNING, "/etc/udev/udev.conf", 0, r,
+ "Failed to parse timeout_signal=%s, ignoring: %m", timeout_signal);
+ else
+ manager->timeout_signal = r;
+ }
+
+ return 0;
+}
+
/*
* read the kernel command line, in case we need to get into debug mode
* udev.log_level=<level> syslog priority
if (!manager)
return log_oom();
- udev_parse_config_full(
- &manager->children_max,
- &manager->exec_delay_usec,
- &manager->timeout_usec,
- &manager->resolve_name_timing,
- &manager->timeout_signal);
+ manager_parse_udev_config(manager);
log_parse_environment();
log_open(); /* Done again to update after reading configuration. */