X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udev_rules.c;h=f8844a8438df8af7ae277c248489ece37d145d7e;hb=1ce3e4fef08b9e5af230f9fc25972473aa23b8db;hp=d1c3f042c390ce5dd4c913a664159ffce350f1c2;hpb=c0c865d4664ea10309b0ffc12b2fad19ecb98129;p=elogind.git diff --git a/udev_rules.c b/udev_rules.c index d1c3f042c..f8844a843 100644 --- a/udev_rules.c +++ b/udev_rules.c @@ -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); } } @@ -230,7 +236,7 @@ static int import_parent_into_env(struct udevice *udev, const char *filter) struct name_entry *name_loop; dbg("found parent '%s', get the node name", dev_parent->devpath); - udev_parent = udev_device_init(); + udev_parent = udev_device_init(NULL); if (udev_parent == NULL) return -1; /* import the udev_db of the parent */ @@ -283,7 +289,7 @@ static int wait_for_sysfs(struct udevice *udev, const char *file, int timeout) info("file '%s' appeared after %i loops", filepath, (timeout * WAIT_LOOP_PER_SECOND) - loop-1); return 0; } - /* make sure the device does not have disappeared in the meantime */ + /* make sure, the device did not disappear in the meantime */ if (stat(devicepath, &stats) != 0) { info("device disappeared while waiting for '%s'", filepath); return -2; @@ -512,7 +518,7 @@ found: struct udevice *udev_parent; dbg("found parent '%s', get the node name", dev_parent->devpath); - udev_parent = udev_device_init(); + udev_parent = udev_device_init(NULL); if (udev_parent != NULL) { /* lookup the name in the udev_db with the DEVPATH of the parent */ if (udev_db_get_device(udev_parent, dev_parent->devpath) == 0) { @@ -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') {