1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-21 02:50:18 +03:00

bpf-devices: if a device node is referenced which doesn't exist, downgrade log message

Currently in many of our test cases you'll see a warning about a tun
device not being around. Let's make that quiet, since if there's no such
device there's no point in adding it to a policy anyway, and it makes
useless noise go away.

We keep the warning as a warning if a device node is missing for other
errors than ENOENT.
This commit is contained in:
Lennart Poettering 2024-02-09 12:28:10 +01:00
parent 958b73bef1
commit 3a51cf673f

View File

@ -372,8 +372,14 @@ int bpf_devices_allow_list_device(
return log_warning_errno(r, "Couldn't parse major/minor from device path '%s': %m", node);
struct stat st;
if (stat(node, &st) < 0)
if (stat(node, &st) < 0) {
if (errno == ENOENT) {
log_debug_errno(errno, "Device '%s' does not exist, skipping.", node);
return 0; /* returning 0 means → skipped */
}
return log_warning_errno(errno, "Couldn't stat device %s: %m", node);
}
if (!S_ISCHR(st.st_mode) && !S_ISBLK(st.st_mode))
return log_warning_errno(SYNTHETIC_ERRNO(ENODEV), "%s is not a device.", node);