summaryrefslogtreecommitdiffstats
path: root/src/udev/udev-rules.c
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@strace.io>2023-03-02 09:00:00 +0100
committerDmitry V. Levin <ldv@strace.io>2023-03-08 19:55:40 +0100
commitacdba85e0e2bf229f356ad09a2b880e89224715d (patch)
treec070f6407dd1bd639708e1c7dfb5243478f4dd05 /src/udev/udev-rules.c
parentudev_rules_parse_file: mark logged issues (diff)
downloadsystemd-acdba85e0e2bf229f356ad09a2b880e89224715d.tar.xz
systemd-acdba85e0e2bf229f356ad09a2b880e89224715d.zip
udevadm: introduce new 'verify' command
We seem to have no tool to verify udev rule files. There is a simple udev rules syntax checker in the tree, test/rule-syntax-check.py, but it is too simple to detect less trivial issues not detected by udev, e.g. redundant comparisons (#26593) or labels without references. Such a tool would be beneficial not only for maintaining udev rules distributed along with udev, but also and even more so for maintaining third party udev rules that are more likely to have issues with syntax and semantic correctness. Implement a udev rules syntax and semantics checker in the form of 'udevadm verify [OPTIONS] FILE...' command that is based on udev_rules_parse_file() interface and would apply further checks on top of it in subsequent commits. Resolves: #26606
Diffstat (limited to 'src/udev/udev-rules.c')
-rw-r--r--src/udev/udev-rules.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 840448d65c..c2e98e9a9e 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -1321,6 +1321,16 @@ int udev_rules_parse_file(UdevRules *rules, const char *filename) {
return 0;
}
+unsigned udev_check_current_rule_file(UdevRules *rules) {
+ assert(rules);
+
+ UdevRuleFile *rule_file = rules->current_file;
+ if (!rule_file)
+ return 0;
+
+ return rule_file->issues;
+}
+
UdevRules* udev_rules_new(ResolveNameTiming resolve_name_timing) {
assert(resolve_name_timing >= 0 && resolve_name_timing < _RESOLVE_NAME_TIMING_MAX);