]> err.no Git - systemd/commitdiff
libudev: device - add udev_device_get_property_value()
authorKay Sievers <kay.sievers@vrfy.org>
Mon, 5 Jan 2009 23:26:28 +0000 (00:26 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Mon, 5 Jan 2009 23:26:28 +0000 (00:26 +0100)
udev/lib/exported_symbols
udev/lib/libudev-device.c
udev/lib/libudev.h
udev/udev-event.c
udev/udev-rules.c

index abf50517919ec0f4c141dfff861b9f0cbd2eda32..86ab1059fe74130b7d7359252297cbca8fe2a642 100644 (file)
@@ -29,6 +29,7 @@ udev_device_get_subsystem
 udev_device_get_devtype
 udev_device_get_devlinks_list_entry
 udev_device_get_properties_list_entry
+udev_device_get_properties_value
 udev_device_get_action
 udev_device_get_driver
 udev_device_get_devnum
index 0cb59212815459924f7319187ff7e5b0d81e9f21..a7722b3f6e824319e37153d2ab603042f2cf2167 100644 (file)
@@ -1059,6 +1059,20 @@ struct udev_list_entry *udev_device_add_property_from_string(struct udev_device
        return udev_device_add_property(udev_device, name, val);
 }
 
+const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key)
+{
+       struct udev_list_entry *list_entry;
+
+       if (udev_device == NULL)
+               return NULL;
+       if (key == NULL)
+               return NULL;
+
+       list_entry = udev_device_get_properties_list_entry(udev_device);
+       list_entry =  udev_list_entry_get_by_name(list_entry, key);
+       return udev_list_entry_get_value(list_entry);
+}
+
 #define ENVP_SIZE                      128
 #define MONITOR_BUF_SIZE               4096
 static int update_envp_monitor_buf(struct udev_device *udev_device)
index 6d6618a9ec7a0c93d283f0879cb569399e3a0f5a..58d7ef98c440005b3f2bb8fed284fd79b177b440 100644 (file)
@@ -75,6 +75,7 @@ extern const char *udev_device_get_sysnum(struct udev_device *udev_device);
 extern const char *udev_device_get_devnode(struct udev_device *udev_device);
 extern struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_device *udev_device);
 extern struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_device *udev_device);
+extern const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key);
 extern const char *udev_device_get_driver(struct udev_device *udev_device);
 extern dev_t udev_device_get_devnum(struct udev_device *udev_device);
 extern const char *udev_device_get_action(struct udev_device *udev_device);
index 93a65e7352602b27d3a993a1e62d3516ffb9f40a..9e82f8de42f1baaf7ae2cfd29972b31cbe14a8af 100644 (file)
@@ -421,14 +421,9 @@ found:
                                dbg(event->udev, "missing attribute\n");
                                break;
                        } else {
-                               struct udev_list_entry *list_entry;
                                const char *value;
 
-                               list_entry = udev_device_get_properties_list_entry(event->dev);
-                               list_entry = udev_list_entry_get_by_name(list_entry, attr);
-                               if (list_entry == NULL)
-                                       break;
-                               value = udev_list_entry_get_value(list_entry);
+                               value = udev_device_get_property_value(event->dev, attr);
                                if (value == NULL)
                                        break;
                                dbg(event->udev, "substitute env '%s=%s'\n", attr, value);
index 9861a88a52b3a6a7f5fbe91bb4b4d073d6cc5253..7ba52208fb243daafaf971d82befe26cbb15d451 100644 (file)
@@ -2059,13 +2059,10 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
                        break;
                case TK_M_ENV:
                        {
-                               struct udev_list_entry *list_entry;
                                const char *key_name = &rules->buf[cur->key.attr_off];
                                const char *value;
 
-                               list_entry = udev_device_get_properties_list_entry(event->dev);
-                               list_entry = udev_list_entry_get_by_name(list_entry, key_name);
-                               value = udev_list_entry_get_value(list_entry);
+                               value = udev_device_get_property_value(event->dev, key_name);
                                if (value == NULL) {
                                        dbg(event->udev, "ENV{%s} is not set, treat as empty\n", key_name);
                                        value = "";