udevadm: gracefully handle when a maked file is specified to udevadm verify/cat

Previously, since 7cb4508c5a, if a masked
file is specified, the commands failed.
Let's warn that the file is masked and ignore the file.
This commit is contained in:
Yu Watanabe
2026-01-16 23:05:33 +09:00
parent 01efa01dd2
commit 782569afd0
3 changed files with 12 additions and 5 deletions
+10 -2
View File
@@ -248,7 +248,11 @@ static int search_rules_file_in_conf_dirs(const char *s, const char *root, ConfF
return log_oom();
_cleanup_(conf_file_freep) ConfFile *c = NULL;
r = conf_file_new(path, root, CONF_FILES_REGULAR, &c);
r = conf_file_new(path, root, CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED, &c);
if (r == -ERFKILL) {
log_warning_errno(r, "File '%s%s' is a mask, ignoring.", empty_to_root(root), skip_leading_slash(path));
return 1; /* Found masked file. */
}
if (r == -ENOENT)
continue;
if (r < 0)
@@ -278,7 +282,11 @@ static int search_rules_file(const char *s, const char *root, ConfFile ***files,
/* If not found, or if it is a path, then chase it. */
_cleanup_(conf_file_freep) ConfFile *c = NULL;
r = conf_file_new(s, root, CONF_FILES_REGULAR, &c);
r = conf_file_new(s, root, CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED, &c);
if (r == -ERFKILL) {
log_warning_errno(r, "File '%s%s' is a mask, ignoring.", empty_to_root(root), skip_leading_slash(s));
return 0; /* Found masked file. */
}
if (r >= 0) {
if (!GREEDY_REALLOC_APPEND(*files, *n_files, &c, 1))
return log_oom();
+1 -1
View File
@@ -38,7 +38,7 @@ udevadm cat 99-systemd
udevadm cat 99-systemd.rules
udevadm cat /usr/lib/udev/rules.d/99-systemd.rules
udevadm cat /usr/lib/udev/rules.d
(! udevadm cat /dev/null)
udevadm cat /dev/null
udevadm cat --config
udevadm cat -h
+1 -2
View File
@@ -118,8 +118,7 @@ assert_1 --resolve-names=now
assert_1 ./nosuchfile
# Failed to parse rules file ./nosuchfile: No such file or directory
assert_1 ./nosuchfile /dev/null
# '/dev/null' is neither a regular file nor a directory: File descriptor in bad state
assert_1 /dev/null
assert_0 /dev/null
rules_dir='etc/udev/rules.d'
mkdir -p "${rules_dir}"