mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
ignore duplicated rules file names
This commit is contained in:
parent
661c67953d
commit
8ef5af2db8
@ -74,8 +74,15 @@
|
||||
the custom rules directory <filename>/etc/udev/rules.d/</filename>
|
||||
and the temporary rules directory <filename>/dev/.udev/rules.d/</filename>.
|
||||
All rule files are sorted and processed in lexical order, regardless
|
||||
in which of these directories they live. Every line in the rules file contains at least
|
||||
one key value pair. There are two kind of keys, match and assignment keys.
|
||||
in which of these directories they live.</para>
|
||||
|
||||
<para>Rule files are required to have a unique name, duplicate file names
|
||||
are ignored. Files in <filename>/etc/udev/rules.d/</filename> have precedence
|
||||
over files with the same name in <filename>/lib/udev/rules.d/</filename>. This
|
||||
can be used to ignore a default rules file if needed.</para>
|
||||
|
||||
<para>Every line in the rules file contains at least one key value pair.
|
||||
There are two kind of keys, match and assignment keys.
|
||||
If all match keys are matching against its value, the rule gets applied and the
|
||||
assign keys get the specified value assigned.</para>
|
||||
|
||||
|
@ -741,11 +741,8 @@ int udev_rules_init(struct udev_rules *rules, int resolve_names)
|
||||
/* custom rules location for testing */
|
||||
add_matching_files(&name_list, udev_rules_dir, ".rules");
|
||||
} else {
|
||||
/* read default rules */
|
||||
add_matching_files(&name_list, UDEV_PREFIX "/lib/udev/rules.d", ".rules");
|
||||
|
||||
/* read user/custom rules */
|
||||
add_matching_files(&sort_list, SYSCONFDIR "/udev/rules.d", ".rules");
|
||||
add_matching_files(&name_list, SYSCONFDIR "/udev/rules.d", ".rules");
|
||||
|
||||
/* read dynamic/temporary rules */
|
||||
strlcpy(filename, udev_root, sizeof(filename));
|
||||
@ -758,6 +755,9 @@ int udev_rules_init(struct udev_rules *rules, int resolve_names)
|
||||
}
|
||||
add_matching_files(&sort_list, filename, ".rules");
|
||||
|
||||
/* read default rules */
|
||||
add_matching_files(&sort_list, UDEV_PREFIX "/lib/udev/rules.d", ".rules");
|
||||
|
||||
/* sort all rules files by basename into list of files */
|
||||
list_for_each_entry_safe(sort_loop, sort_tmp, &sort_list, node) {
|
||||
const char *sort_base = strrchr(sort_loop->name, '/');
|
||||
@ -771,10 +771,20 @@ int udev_rules_init(struct udev_rules *rules, int resolve_names)
|
||||
if (name_base == NULL)
|
||||
continue;
|
||||
|
||||
if (strcmp(name_base, sort_base) == 0) {
|
||||
info("rule file '%s' already added, ignoring '%s'\n",
|
||||
name_loop->name, sort_loop->name);
|
||||
list_del(&sort_loop->node);
|
||||
free(sort_loop);
|
||||
sort_loop = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(name_base, sort_base) > 0)
|
||||
break;
|
||||
}
|
||||
list_move_tail(&sort_loop->node, &name_loop->node);
|
||||
if (sort_loop != NULL)
|
||||
list_move_tail(&sort_loop->node, &name_loop->node);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user