From: Kay Sievers Date: Sun, 10 Jun 2007 21:53:40 +0000 (+0200) Subject: make ATTR{[$SUBSYSTEM/$KERNEL]}="" working X-Git-Tag: 174~1908 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=956cf79390e303925135663a858456dd0a26e6c6;p=systemd make ATTR{[$SUBSYSTEM/$KERNEL]}="" working --- diff --git a/udev_rules.c b/udev_rules.c index 598c1ba7..6ef320df 100644 --- a/udev_rules.c +++ b/udev_rules.c @@ -923,14 +923,28 @@ try_parent: if (pair->key.operation == KEY_OP_ASSIGN) { const char *key_name = key_pair_name(rule, pair); - char attr[PATH_SIZE]; + char devpath[PATH_SIZE]; + char *attrib; + 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)); + if (attr_get_by_subsys_id(key_name, devpath, sizeof(devpath), &attrib)) { + if (attrib != NULL) { + strlcpy(attr, sysfs_path, sizeof(attr)); + strlcat(attr, devpath, sizeof(attr)); + strlcat(attr, "/", sizeof(attr)); + strlcat(attr, attrib, sizeof(attr)); + } + } + + if (attr[0] == '\0') { + strlcpy(attr, sysfs_path, sizeof(attr)); + strlcat(attr, udev->dev->devpath, sizeof(attr)); + strlcat(attr, "/", sizeof(attr)); + strlcat(attr, key_name, sizeof(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);