diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2009-11-16 23:39:33 +0100 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2009-11-16 23:39:33 +0100 |
commit | 6d87ee2e0024074b77001e57ff1d7b7d24b1be68 (patch) | |
tree | 9224ce893283438f4433647f3ce17cb2c4f1fcd6 | |
parent | cdae488a3fbca5a61b3f8ea0651730cfa2da9cb0 (diff) |
print warning for BUS=, SYSFS{}=, ID=
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | TODO | 7 | ||||
-rw-r--r-- | udev/udev-rules.c | 63 |
3 files changed, 65 insertions, 9 deletions
@@ -7,6 +7,10 @@ ignore an event, as libudev events can not be suppressed by rules. It only prevented RUN keys from being executed, which results in an inconsistent behavior in current setups. +BUS=, SYSFS{}=, ID= are long deprecated and should be SUBSYSTEM(S)=, +ATTR(S){}=, KERNEL(S)=. It will cause a warning once for every rule +file from now on. + udev 147 ======== Bugfixes. @@ -1,6 +1,7 @@ o convert firmware.sh to C - o get rid of braindead "scan all devices to find myself" libusb interface - if it can not be fixed, drop libusb entirely + o get rid of "scan all devices to find myself" libusb interface + if it can not be fixed, drop libusb entirely and add a simple + wrapper around the Linux usb ioctls we need o drop all support for the DEPRECATED sysfs layout - o add warning for BUS, SYSFS, ID + o remove deprecated BUS=, SYSFS{}=, ID= keys diff --git a/udev/udev-rules.c b/udev/udev-rules.c index 07cb4a7fbf..3da2033d51 100644 --- a/udev/udev-rules.c +++ b/udev/udev-rules.c @@ -19,6 +19,7 @@ #include <stddef.h> #include <limits.h> #include <stdlib.h> +#include <stdbool.h> #include <string.h> #include <stdio.h> #include <fcntl.h> @@ -1156,6 +1157,9 @@ static int add_rule(struct udev_rules *rules, char *line, char *linepos; char *attr; struct rule_tmp rule_tmp; + bool bus_warn = false; + bool sysfs_warn = false; + bool id_warn = false; memset(&rule_tmp, 0x00, sizeof(struct rule_tmp)); rule_tmp.rules = rules; @@ -1240,8 +1244,7 @@ static int add_rule(struct udev_rules *rules, char *line, continue; } - if (strcmp(key, "KERNELS") == 0 || - strcmp(key, "ID") == 0) { + if (strcmp(key, "KERNELS") == 0) { if (op > OP_MATCH_MAX) { err(rules->udev, "invalid KERNELS operation\n"); goto invalid; @@ -1250,8 +1253,37 @@ static int add_rule(struct udev_rules *rules, char *line, continue; } - if (strcmp(key, "SUBSYSTEMS") == 0 || - strcmp(key, "BUS") == 0) { + if (strcmp(key, "ID") == 0) { + if (!id_warn) { + id_warn = true; + err(rules->udev, "ID= will be removed in a future udev version, " + "please use KERNEL= to match the event device, or KERNELS= " + "to match a parent device, in %s:%u\n", filename, lineno); + } + if (op > OP_MATCH_MAX) { + err(rules->udev, "invalid KERNELS operation\n"); + goto invalid; + } + rule_add_key(&rule_tmp, TK_M_KERNELS, op, value, NULL); + continue; + } + + if (strcmp(key, "SUBSYSTEMS") == 0) { + if (op > OP_MATCH_MAX) { + err(rules->udev, "invalid SUBSYSTEMS operation\n"); + goto invalid; + } + rule_add_key(&rule_tmp, TK_M_SUBSYSTEMS, op, value, NULL); + continue; + } + + if (strcmp(key, "BUS") == 0) { + if (!bus_warn) { + bus_warn = true; + err(rules->udev, "BUS= will be removed in a future udev version, " + "please use SUBSYSTEM= to match the event device, or SUBSYSTEMS= " + "to match a parent device, in %s:%u\n", filename, lineno); + } if (op > OP_MATCH_MAX) { err(rules->udev, "invalid SUBSYSTEMS operation\n"); goto invalid; @@ -1269,8 +1301,7 @@ static int add_rule(struct udev_rules *rules, char *line, continue; } - if (strncmp(key, "ATTRS{", sizeof("ATTRS{")-1) == 0 || - strncmp(key, "SYSFS{", sizeof("SYSFS{")-1) == 0) { + if (strncmp(key, "ATTRS{", sizeof("ATTRS{")-1) == 0) { if (op > OP_MATCH_MAX) { err(rules->udev, "invalid ATTRS operation\n"); goto invalid; @@ -1290,6 +1321,26 @@ static int add_rule(struct udev_rules *rules, char *line, continue; } + if (strncmp(key, "SYSFS{", sizeof("SYSFS{")-1) == 0) { + if (!sysfs_warn) { + sysfs_warn = true; + err(rules->udev, "SYSFS{}= will be removed in a future udev version, " + "please use ATTR{}= to match the event device, or ATTRS{}= " + "to match a parent device, in %s:%u\n", filename, lineno); + } + if (op > OP_MATCH_MAX) { + err(rules->udev, "invalid ATTRS operation\n"); + goto invalid; + } + attr = get_key_attribute(rules->udev, key + sizeof("ATTRS")-1); + if (attr == NULL) { + err(rules->udev, "error parsing ATTRS attribute\n"); + goto invalid; + } + rule_add_key(&rule_tmp, TK_M_ATTRS, op, value, attr); + continue; + } + if (strncmp(key, "ENV{", sizeof("ENV{")-1) == 0) { attr = get_key_attribute(rules->udev, key + sizeof("ENV")-1); if (attr == NULL) { |