+static int device_make_description(Unit *u, struct udev_device *dev, const char *path) {
+ const char *model;
+
+ assert(u);
+ assert(dev);
+ assert(path);
+
+ model = udev_device_get_property_value(dev, "ID_MODEL_FROM_DATABASE");
+ if (!model)
+ model = udev_device_get_property_value(dev, "ID_MODEL");
+
+ if (model) {
+ const char *label;
+
+ /* Try to concatenate the device model string with a label, if there is one */
+ label = udev_device_get_property_value(dev, "ID_FS_LABEL");
+ if (!label)
+ label = udev_device_get_property_value(dev, "ID_PART_ENTRY_NAME");
+ if (!label)
+ label = udev_device_get_property_value(dev, "ID_PART_ENTRY_NUMBER");
+
+ if (label) {
+ _cleanup_free_ char *j;
+
+ j = strjoin(model, " ", label, NULL);
+ if (j)
+ return unit_set_description(u, j);
+ }
+
+ return unit_set_description(u, model);
+ }
+
+ return unit_set_description(u, path);
+}
+
+static int device_add_udev_wants(Unit *u, struct udev_device *dev) {
+ const char *wants;
+ char *state, *w;
+ size_t l;
+ int r;
+
+ assert(u);
+ assert(dev);
+
+ wants = udev_device_get_property_value(
+ dev,
+ u->manager->running_as == SYSTEMD_USER ? "SYSTEMD_USER_WANTS" : "SYSTEMD_WANTS");
+
+ if (!wants)
+ return 0;
+
+ FOREACH_WORD_QUOTED(w, l, wants, state) {
+ _cleanup_free_ char *n = NULL;
+ char e[l+1];
+
+ memcpy(e, w, l);
+ e[l] = 0;
+
+ n = unit_name_mangle(e, MANGLE_NOGLOB);
+ if (!n)
+ return -ENOMEM;
+
+ r = unit_add_dependency_by_name(u, UNIT_WANTS, n, NULL, true);
+ if (r < 0)
+ return r;
+ }
+
+ return 0;
+}
+