]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: split out check that udev property can be updated
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 8 Jan 2024 17:54:43 +0000 (02:54 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 9 Jan 2024 19:27:41 +0000 (04:27 +0900)
src/libsystemd/sd-device/device-util.h
src/udev/udev-rules.c

index a9a9b7ad988165304c092fc974b00c8888a87e50..534a296715b360c97a75eceb104adf277cac0869 100644 (file)
@@ -10,6 +10,7 @@
 #include "alloc-util.h"
 #include "log.h"
 #include "macro.h"
+#include "strv.h"
 
 #define device_unref_and_replace(a, b)                                  \
         unref_and_replace_full(a, b, sd_device_ref, sd_device_unref)
@@ -105,3 +106,10 @@ char** device_make_log_fields(sd_device *device);
 
 bool device_in_subsystem(sd_device *device, const char *subsystem);
 bool device_is_devtype(sd_device *device, const char *devtype);
+
+static inline bool device_property_can_set(const char *property) {
+        return property &&
+                !STR_IN_SET(property,
+                            "ACTION", "DEVLINKS", "DEVNAME", "DEVPATH", "DEVTYPE", "DRIVER",
+                            "IFINDEX", "MAJOR", "MINOR", "SEQNUM", "SUBSYSTEM", "TAGS");
+}
index 9d01e5866c41b0aff16eca49f083b0d5189f10a6..3ec675746bc6e0282070b65ea84740c6882425c6 100644 (file)
@@ -691,9 +691,7 @@ static int parse_token(UdevRuleLine *rule_line, const char *key, char *attr, Ude
                 }
 
                 if (!is_match) {
-                        if (STR_IN_SET(attr,
-                                       "ACTION", "DEVLINKS", "DEVNAME", "DEVPATH", "DEVTYPE", "DRIVER",
-                                       "IFINDEX", "MAJOR", "MINOR", "SEQNUM", "SUBSYSTEM", "TAGS"))
+                        if (!device_property_can_set(attr))
                                 return log_line_error_errno(rule_line, SYNTHETIC_ERRNO(EINVAL),
                                                             "Invalid ENV attribute. '%s' cannot be set.", attr);