diff options
author | David Tardon <dtardon@redhat.com> | 2024-01-05 15:45:04 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-01-11 21:11:14 +0100 |
commit | 07f5e35fe7967c824a87f18a3a1d3c22e5be70f5 (patch) | |
tree | 2506ac53bb1bf888f467744b00358fb6802a50cc /src/shared/udev-util.c | |
parent | udevd: use config. parser to parse udev.conf (diff) | |
download | systemd-07f5e35fe7967c824a87f18a3a1d3c22e5be70f5.tar.xz systemd-07f5e35fe7967c824a87f18a3a1d3c22e5be70f5.zip |
udev-util: use config. parser to parse udev.conf
Diffstat (limited to 'src/shared/udev-util.c')
-rw-r--r-- | src/shared/udev-util.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/shared/udev-util.c b/src/shared/udev-util.c index cf28ba8647..5ea03d6740 100644 --- a/src/shared/udev-util.c +++ b/src/shared/udev-util.c @@ -5,6 +5,7 @@ #include <unistd.h> #include "alloc-util.h" +#include "conf-parser.h" #include "device-nodes.h" #include "device-private.h" #include "device-util.h" @@ -45,20 +46,27 @@ int udev_set_max_log_level(char *str) { } int udev_parse_config(void) { - _cleanup_free_ char *log_val = NULL; - int r; + int r, log_val = -1; + const ConfigTableItem config_table[] = { + { NULL, "udev_log", config_parse_log_level, 0, &log_val }, + {} + }; - r = parse_env_file(NULL, "/etc/udev/udev.conf", - "udev_log", &log_val); + r = config_parse_config_file_full( + "udev.conf", + "udev", + /* sections = */ NULL, + config_item_table_lookup, + config_table, + CONFIG_PARSE_WARN, + /* userdata = */ NULL); 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 (log_val >= 0) + log_set_max_level(log_val); return 0; } |