... that allows to pass additional properties to fall back to.
return -ENOENT;
}
+
+int device_get_property_value_with_fallback(
+ sd_device *device,
+ const char *prop,
+ Hashmap *extra_props,
+ const char **ret) {
+ const char *value;
+ int r;
+
+ assert(device);
+ assert(prop);
+ assert(ret);
+
+ r = sd_device_get_property_value(device, prop, &value);
+ if (r < 0) {
+ if (r != -ENOENT)
+ return r;
+
+ value = hashmap_get(extra_props, prop);
+ if (!value)
+ return -ENOENT;
+ }
+
+ *ret = value;
+
+ return 1;
+}
#include "sd-device.h"
+#include "hashmap.h"
#include "time-util.h"
int udev_set_max_log_level(char *str);
int device_get_vendor_string(sd_device *device, const char **ret);
int device_get_model_string(sd_device *device, const char **ret);
+
+int device_get_property_value_with_fallback(
+ sd_device *device,
+ const char *prop,
+ Hashmap *extra_props,
+ const char **ret);