65 lines
2.4 KiB
Diff
65 lines
2.4 KiB
Diff
From 962169813b50b3497574e21bed4692046f23affe Mon Sep 17 00:00:00 2001
|
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
Date: Sat, 11 Jan 2025 03:45:38 +0900
|
|
Subject: [PATCH] udev-rules: log the first line number when continued
|
|
|
|
(cherry picked from commit 8e0f023548fae141acc6e3fb2a2ae4de4a284960)
|
|
|
|
Resolves: RHEL-75774
|
|
---
|
|
src/udev/udev-rules.c | 12 ++++++++----
|
|
test/units/TEST-17-UDEV.11.sh | 2 +-
|
|
2 files changed, 9 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
|
|
index ec4660968c..4d9fbd39a5 100644
|
|
--- a/src/udev/udev-rules.c
|
|
+++ b/src/udev/udev-rules.c
|
|
@@ -1631,10 +1631,8 @@ static void udev_check_rule_line(UdevRuleLine *line) {
|
|
|
|
int udev_rules_parse_file(UdevRules *rules, const char *filename, bool extra_checks, UdevRuleFile **ret) {
|
|
_cleanup_(udev_rule_file_freep) UdevRuleFile *rule_file = NULL;
|
|
- _cleanup_free_ char *continuation = NULL, *name = NULL;
|
|
+ _cleanup_free_ char *name = NULL;
|
|
_cleanup_fclose_ FILE *f = NULL;
|
|
- bool ignore_line = false;
|
|
- unsigned line_nr = 0;
|
|
struct stat st;
|
|
int r;
|
|
|
|
@@ -1685,6 +1683,9 @@ int udev_rules_parse_file(UdevRules *rules, const char *filename, bool extra_che
|
|
|
|
LIST_APPEND(rule_files, rules->rule_files, rule_file);
|
|
|
|
+ _cleanup_free_ char *continuation = NULL;
|
|
+ unsigned line_nr = 0, current_line_nr = 0;
|
|
+ bool ignore_line = false;
|
|
for (;;) {
|
|
_cleanup_free_ char *buf = NULL;
|
|
size_t len;
|
|
@@ -1696,7 +1697,10 @@ int udev_rules_parse_file(UdevRules *rules, const char *filename, bool extra_che
|
|
if (r == 0)
|
|
break;
|
|
|
|
- line_nr++;
|
|
+ current_line_nr++;
|
|
+ if (!continuation)
|
|
+ line_nr = current_line_nr;
|
|
+
|
|
line = skip_leading_chars(buf, NULL);
|
|
|
|
/* Lines beginning with '#' are ignored regardless of line continuation. */
|
|
diff --git a/test/units/TEST-17-UDEV.11.sh b/test/units/TEST-17-UDEV.11.sh
|
|
index 8413d3c189..c0d87b7151 100755
|
|
--- a/test/units/TEST-17-UDEV.11.sh
|
|
+++ b/test/units/TEST-17-UDEV.11.sh
|
|
@@ -174,7 +174,7 @@ assert_0 "${rules}"
|
|
printf 'RUN+="/bin/true"%8176s\\\n #\n' ' ' ' ' >"${rules}"
|
|
echo >>"${rules}"
|
|
cat >"${exp}" <<EOF
|
|
-${rules}:5 Line is too long, ignored.
|
|
+${rules}:1 Line is too long, ignored.
|
|
${rules}: udev rules check failed.
|
|
EOF
|
|
assert_1 "${rules}"
|