chiark / gitweb /
remove old error message
[elogind.git] / udev_rules.c
index d1c3f042c390ce5dd4c913a664159ffce350f1c2..c0f4cd2077b1f643898eeb7e9e9a97cda5982413 100644 (file)
@@ -186,7 +186,13 @@ static int import_keys_into_env(struct udevice *udev, const char *buf, size_t bu
                linepos = line;
                if (get_key(&linepos, &variable, &value) == 0) {
                        dbg("import '%s=%s'", variable, value);
-                       name_list_key_add(&udev->env_list, variable, value);
+
+                       /* handle device, renamed by external tool, returning new path */
+                       if (strcmp(variable, "DEVPATH") == 0) {
+                               info("updating devpath from '%s' to '%s'", udev->dev->devpath, value);
+                               sysfs_device_set_values(udev->dev, value, NULL, NULL);
+                       } else
+                               name_list_key_add(&udev->env_list, variable, value);
                        setenv(variable, value, 1);
                }
        }
@@ -842,18 +848,20 @@ try_parent:
 
                if (pair->key.operation == KEY_OP_ASSIGN) {
                        const char *key_name = key_pair_name(rule, pair);
-                       const char *key_value = key_val(rule, &pair->key);
                        char attr[PATH_SIZE];
+                       char value[NAME_SIZE];
                        FILE *f;
 
                        strlcpy(attr, sysfs_path, sizeof(attr));
                        strlcat(attr, udev->dev->devpath, sizeof(attr));
                        strlcat(attr, "/", sizeof(attr));
                        strlcat(attr, key_name, sizeof(attr));
-                       dbg("write '%s' to '%s'", key_value, attr);
+                       strlcpy(value, key_val(rule, &pair->key), sizeof(value));
+                       udev_rules_apply_format(udev, value, sizeof(value));
+                       info("writing '%s' to sysfs file '%s'", value, attr);
                        f = fopen(attr, "w");
                        if (f != NULL) {
-                               if (fprintf(f, "%s\n", key_value) <= 0)
+                               if (fprintf(f, "%s", value) <= 0)
                                        err("error writing ATTR{%s}: %s", attr, strerror(errno));
                                fclose(f);
                        } else
@@ -901,6 +909,10 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udev)
                                udev->ignore_remove = 1;
                                dbg("remove event should be ignored");
                        }
+                       if (rule->link_priority) {
+                               udev->link_priority = rule->link_priority;
+                               info("link_priority=%i", udev->link_priority);
+                       }
                        /* apply all_partitions option only at a main block device */
                        if (rule->partitions &&
                            strcmp(udev->dev->subsystem, "block") == 0 && udev->dev->kernel_number[0] == '\0') {