From: David Tardon Date: Fri, 5 Jan 2024 15:11:24 +0000 (+0100) Subject: udev: factor out config parser call into function X-Git-Tag: v256-rc1~1183^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=09dd8e77fc7da645e716f34ba7fa38d4666460f6;p=thirdparty%2Fsystemd.git udev: factor out config parser call into function ... which is then called from both places. This makes sure that the configuration is parsed by udevd and other tools in exactly the same way. --- diff --git a/src/shared/udev-util.c b/src/shared/udev-util.c index 68e594e065c..7a86289d166 100644 --- a/src/shared/udev-util.c +++ b/src/shared/udev-util.c @@ -5,7 +5,6 @@ #include #include "alloc-util.h" -#include "conf-parser.h" #include "device-nodes.h" #include "device-private.h" #include "device-util.h" @@ -23,12 +22,10 @@ #include "udev-util.h" #include "utf8.h" -int udev_parse_config(void) { - int r, log_val = -1; - const ConfigTableItem config_table[] = { - { NULL, "udev_log", config_parse_log_level, 0, &log_val }, - {} - }; +int udev_parse_config_full(const ConfigTableItem config_table[]) { + int r; + + assert(config_table); r = config_parse_config_file_full( "udev.conf", @@ -40,6 +37,17 @@ int udev_parse_config(void) { /* userdata = */ NULL); if (r == -ENOENT) return 0; + return r; +} + +int udev_parse_config(void) { + int r, log_val = -1; + const ConfigTableItem config_table[] = { + { NULL, "udev_log", config_parse_log_level, 0, &log_val }, + {} + }; + + r = udev_parse_config_full(config_table); if (r < 0) return r; diff --git a/src/shared/udev-util.h b/src/shared/udev-util.h index 958acc9382a..5f49e871161 100644 --- a/src/shared/udev-util.h +++ b/src/shared/udev-util.h @@ -3,9 +3,11 @@ #include "sd-device.h" +#include "conf-parser.h" #include "hashmap.h" #include "time-util.h" +int udev_parse_config_full(const ConfigTableItem config_table[]); int udev_parse_config(void); int device_wait_for_initialization(sd_device *device, const char *subsystem, usec_t timeout_usec, sd_device **ret); diff --git a/src/udev/udevd.c b/src/udev/udevd.c index ff43c6a2b56..684ced1315f 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -83,16 +83,7 @@ static int manager_parse_udev_config(Manager *manager) { {} }; - 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; + r = udev_parse_config_full(config_table); if (r < 0) return r;