]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: factor out config parser call into function
authorDavid Tardon <dtardon@redhat.com>
Fri, 5 Jan 2024 15:11:24 +0000 (16:11 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 11 Jan 2024 20:12:42 +0000 (05:12 +0900)
... 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.

src/shared/udev-util.c
src/shared/udev-util.h
src/udev/udevd.c

index 68e594e065c61aa5a332a3a865e9ecf4d2c5773c..7a86289d166df9ca0a33b2d24eb33e4d6564b42b 100644 (file)
@@ -5,7 +5,6 @@
 #include <unistd.h>
 
 #include "alloc-util.h"
-#include "conf-parser.h"
 #include "device-nodes.h"
 #include "device-private.h"
 #include "device-util.h"
 #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;
 
index 958acc9382a047fff8d2b1eb80a0870a67721c98..5f49e87116179db7989374a1fec74491de4adc3f 100644 (file)
@@ -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);
index ff43c6a2b56274600a662d522f37113284687f1e..684ced1315f81dfa0c8f113e154439f4698aed5d 100644 (file)
@@ -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;