mirror of
https://git.yoctoproject.org/poky
synced 2026-05-02 00:32:12 +02:00
udev-115: Kernel events filtering improvement.
In order to avoid creating dozens of ttys and ptys, we have to discard some specific kernel events. git-svn-id: https://svn.o-hand.com/repos/poky/trunk@2820 311d38ba-8fff-0310-9ca6-ca027cbcb966
This commit is contained in:
@@ -0,0 +1,104 @@
|
|||||||
|
---
|
||||||
|
udevtrigger.c | 40 ++++++++++++++++++++++++++++++++++++++++
|
||||||
|
1 file changed, 40 insertions(+)
|
||||||
|
|
||||||
|
Index: udev-115/udevtrigger.c
|
||||||
|
===================================================================
|
||||||
|
--- udev-115.orig/udevtrigger.c 2007-08-24 01:29:54.000000000 +0200
|
||||||
|
+++ udev-115/udevtrigger.c 2007-09-21 18:45:28.000000000 +0200
|
||||||
|
@@ -39,6 +39,8 @@
|
||||||
|
LIST_HEAD(device_list);
|
||||||
|
LIST_HEAD(filter_subsystem_match_list);
|
||||||
|
LIST_HEAD(filter_subsystem_nomatch_list);
|
||||||
|
+LIST_HEAD(filter_kernel_match_list);
|
||||||
|
+LIST_HEAD(filter_kernel_nomatch_list);
|
||||||
|
LIST_HEAD(filter_attr_match_list);
|
||||||
|
LIST_HEAD(filter_attr_nomatch_list);
|
||||||
|
|
||||||
|
@@ -218,6 +220,26 @@
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int kernel_filtered(const char *kernel)
|
||||||
|
+{
|
||||||
|
+ struct name_entry *loop_name;
|
||||||
|
+
|
||||||
|
+ /* skip devices matching the prohibited kernel device names */
|
||||||
|
+ list_for_each_entry(loop_name, &filter_kernel_nomatch_list, node)
|
||||||
|
+ if (fnmatch(loop_name->name, kernel, 0) == 0)
|
||||||
|
+ return 1;
|
||||||
|
+
|
||||||
|
+ /* skip devices not matching the listed kernel device names */
|
||||||
|
+ if (!list_empty(&filter_kernel_match_list)) {
|
||||||
|
+ list_for_each_entry(loop_name, &filter_kernel_match_list, node)
|
||||||
|
+ if (fnmatch(loop_name->name, kernel, 0) == 0)
|
||||||
|
+ return 0;
|
||||||
|
+ return 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int attr_filtered(const char *path)
|
||||||
|
{
|
||||||
|
struct name_entry *loop_name;
|
||||||
|
@@ -296,6 +318,9 @@
|
||||||
|
if (dent2->d_name[0] == '.')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
+ if (kernel_filtered(dent2->d_name))
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
strlcpy(dirname2, dirname, sizeof(dirname2));
|
||||||
|
strlcat(dirname2, "/", sizeof(dirname2));
|
||||||
|
strlcat(dirname2, dent2->d_name, sizeof(dirname2));
|
||||||
|
@@ -402,6 +427,9 @@
|
||||||
|
if (!strcmp(dent2->d_name, "device"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
+ if (kernel_filtered(dent2->d_name))
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
strlcpy(dirname2, dirname, sizeof(dirname2));
|
||||||
|
strlcat(dirname2, "/", sizeof(dirname2));
|
||||||
|
strlcat(dirname2, dent2->d_name, sizeof(dirname2));
|
||||||
|
@@ -458,6 +486,8 @@
|
||||||
|
{ "subsystem-nomatch", 1, NULL, 'S' },
|
||||||
|
{ "attr-match", 1, NULL, 'a' },
|
||||||
|
{ "attr-nomatch", 1, NULL, 'A' },
|
||||||
|
+ { "kernel-match", 1, NULL, 'k' },
|
||||||
|
+ { "kernel-nomatch", 1, NULL, 'K' },
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
@@ -496,6 +526,12 @@
|
||||||
|
case 'A':
|
||||||
|
name_list_add(&filter_attr_nomatch_list, optarg, 0);
|
||||||
|
break;
|
||||||
|
+ case 'k':
|
||||||
|
+ name_list_add(&filter_kernel_match_list, optarg, 0);
|
||||||
|
+ break;
|
||||||
|
+ case 'K':
|
||||||
|
+ name_list_add(&filter_kernel_nomatch_list, optarg, 0);
|
||||||
|
+ break;
|
||||||
|
case 'h':
|
||||||
|
printf("Usage: udevtrigger OPTIONS\n"
|
||||||
|
" --verbose print the list of devices while running\n"
|
||||||
|
@@ -504,6 +540,8 @@
|
||||||
|
" marked as failed during a previous run\n"
|
||||||
|
" --subsystem-match=<subsystem> trigger devices from a matching subystem\n"
|
||||||
|
" --subsystem-nomatch=<subsystem> exclude devices from a matching subystem\n"
|
||||||
|
+ " --kernel-match=<subsystem> trigger devices from a matching kernel device name\n"
|
||||||
|
+ " --kernel-nomatch=<subsystem> exclude devices from a matching kernel device name\n"
|
||||||
|
" --attr-match=<file[=<value>]> trigger devices with a matching sysfs\n"
|
||||||
|
" attribute\n"
|
||||||
|
" --attr-nomatch=<file[=<value>]> exclude devices with a matching sysfs\n"
|
||||||
|
@@ -549,6 +587,8 @@
|
||||||
|
exit:
|
||||||
|
name_list_cleanup(&filter_subsystem_match_list);
|
||||||
|
name_list_cleanup(&filter_subsystem_nomatch_list);
|
||||||
|
+ name_list_cleanup(&filter_kernel_match_list);
|
||||||
|
+ name_list_cleanup(&filter_kernel_nomatch_list);
|
||||||
|
name_list_cleanup(&filter_attr_match_list);
|
||||||
|
name_list_cleanup(&filter_attr_nomatch_list);
|
||||||
|
|
||||||
@@ -9,6 +9,7 @@ SRC_URI = "http://kernel.org/pub/linux/utils/kernel/hotplug/udev-${PV}.tar.gz \
|
|||||||
file://noasmlinkage.patch;patch=1 \
|
file://noasmlinkage.patch;patch=1 \
|
||||||
file://flags.patch;patch=1 \
|
file://flags.patch;patch=1 \
|
||||||
file://vol_id_ld.patch;patch=1 \
|
file://vol_id_ld.patch;patch=1 \
|
||||||
|
file://udevtrigger_add_devname_filtering.patch;patch=1 \
|
||||||
file://mount.blacklist \
|
file://mount.blacklist \
|
||||||
"
|
"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user