1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00

print warning for BUS=, SYSFS{}=, ID=

This commit is contained in:
Kay Sievers 2009-11-16 23:39:33 +01:00
parent cdae488a3f
commit 6d87ee2e00
3 changed files with 65 additions and 9 deletions

4
NEWS
View File

@ -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.

7
TODO
View File

@ -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

View File

@ -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) {