From b0ca060e059734125ad7a59dcef0b2a81e10c65f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 24 Jul 2025 10:25:59 +0200 Subject: [PATCH 1/2] core/socket: shorten/reword message about restarted sockets log_unit_warning() already prints the full unit name, so we don't need to say that it is a socket unit. And in technical messages articles like "the" are generally skipped to make the messages shorter. Use simpler tense and simpler wording. Example from log: fedora.local systemd[1]: systemd-initctl.socket: Socket unit configuration has changed while unit has been running, no open socket file descriptor left. The socket unit is not functional until restarted. This is just too wordy and says "socket" four times. --- src/core/socket.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/socket.c b/src/core/socket.c index f648721f05..34f3e3ea4d 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -1931,9 +1931,9 @@ static int socket_coldplug(Unit *u) { SOCKET_RUNNING)) { /* Originally, we used to simply reopen all sockets here that we didn't have file descriptors - * for. However, this is problematic, as we won't traverse through the SOCKET_START_CHOWN state for - * them, and thus the UID/GID wouldn't be right. Hence, instead simply check if we have all fds open, - * and if there's a mismatch, warn loudly. + * for. However, this is problematic, as we won't traverse through the SOCKET_START_CHOWN + * state for them, and thus the UID/GID wouldn't be right. Hence, instead simply check if we + * have all fds open, and if there's a mismatch, warn loudly. * * Note that SOCKET_START_OPEN requires no special treatment, as it's only intermediate * between SOCKET_START_PRE and SOCKET_START_CHOWN and shall otherwise not be observed. @@ -1942,14 +1942,14 @@ static int socket_coldplug(Unit *u) { r = socket_check_open(s); if (r == SOCKET_OPEN_NONE) log_unit_warning(UNIT(s), - "Socket unit configuration has changed while unit has been running, " - "no open socket file descriptor left. " - "The socket unit is not functional until restarted."); + "Unit configuration changed while unit was running, " + "and no socket file descriptors are open. " + "Unit not functional until restarted."); else if (r == SOCKET_OPEN_SOME) log_unit_warning(UNIT(s), - "Socket unit configuration has changed while unit has been running, " + "Unit configuration changed while unit was running, " "and some socket file descriptors have not been opened yet. " - "The socket unit is not fully functional until restarted."); + "Unit not fully functional until restarted."); } if (s->deserialized_state == SOCKET_LISTENING) { From 56631ac8df7479b7ac1cc4c81d97d0c93e3b2ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 24 Jul 2025 10:42:50 +0200 Subject: [PATCH 2/2] udev: downgrade ENOMEDIUM warnings I noticed similar warnings in many VM boots: fedora (udev-worker)[475]: sr0: Failed to open device node: No medium found This particular one is from src/udev/udev-builtin-uaccess.c:125, but I think the same principle should be used in all places: if we are ignoring errors that the device has been removed, we should also ignore ENOMEDIUM. --- src/basic/errno-util.h | 7 +++++++ src/udev/ata_id/ata_id.c | 2 +- src/udev/mtd_probe/mtd_probe.c | 2 +- src/udev/udev-builtin-blkid.c | 2 +- src/udev/udev-builtin-btrfs.c | 2 +- src/udev/udev-builtin-keyboard.c | 4 ++-- src/udev/udev-builtin-uaccess.c | 2 +- src/udev/udev-node.c | 6 +++--- src/udev/udev-worker.c | 4 ++-- src/udev/v4l_id/v4l_id.c | 2 +- 10 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/basic/errno-util.h b/src/basic/errno-util.h index 05d416d7ae..5fe337cfb1 100644 --- a/src/basic/errno-util.h +++ b/src/basic/errno-util.h @@ -212,6 +212,13 @@ static inline bool ERRNO_IS_NEG_DEVICE_ABSENT(intmax_t r) { } _DEFINE_ABS_WRAPPER(DEVICE_ABSENT); +/* Device is absent or "empty". We get -ENOMEDIUM from CD/DVD devices, also in VMs. */ +static inline bool ERRNO_IS_NEG_DEVICE_ABSENT_OR_EMPTY(intmax_t r) { + return ERRNO_IS_NEG_DEVICE_ABSENT(r) || + r == -ENOMEDIUM; +} +_DEFINE_ABS_WRAPPER(DEVICE_ABSENT_OR_EMPTY); + /* Quite often we want to handle cases where the backing FS doesn't support extended attributes at all and * where it simply doesn't have the requested xattr the same way */ static inline bool ERRNO_IS_NEG_XATTR_ABSENT(intmax_t r) { diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c index 6a3614acac..508f99b01a 100644 --- a/src/udev/ata_id/ata_id.c +++ b/src/udev/ata_id/ata_id.c @@ -413,7 +413,7 @@ static int run(int argc, char *argv[]) { fd = open(ASSERT_PTR(arg_device), O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY); if (fd < 0) { - bool ignore = ERRNO_IS_DEVICE_ABSENT(errno); + bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(errno); log_full_errno(ignore ? LOG_DEBUG : LOG_WARNING, errno, "Failed to open device node '%s'%s: %m", arg_device, ignore ? ", ignoring" : ""); diff --git a/src/udev/mtd_probe/mtd_probe.c b/src/udev/mtd_probe/mtd_probe.c index 5899f5ae9c..d79a0617e2 100644 --- a/src/udev/mtd_probe/mtd_probe.c +++ b/src/udev/mtd_probe/mtd_probe.c @@ -75,7 +75,7 @@ static int run(int argc, char** argv) { mtd_fd = open(argv[1], O_RDONLY|O_CLOEXEC|O_NOCTTY); if (mtd_fd < 0) { - bool ignore = ERRNO_IS_DEVICE_ABSENT(errno); + bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(errno); log_full_errno(ignore ? LOG_DEBUG : LOG_WARNING, errno, "Failed to open device node '%s'%s: %m", argv[1], ignore ? ", ignoring" : ""); diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index c5d3e89c77..1480efd743 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -499,7 +499,7 @@ static int builtin_blkid(UdevEvent *event, int argc, char *argv[]) { fd = sd_device_open(dev, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY); if (fd < 0) { - bool ignore = ERRNO_IS_DEVICE_ABSENT(fd); + bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(fd); log_device_debug_errno(dev, fd, "Failed to open block device %s%s: %m", devnode, ignore ? ", ignoring" : ""); return ignore ? 0 : fd; diff --git a/src/udev/udev-builtin-btrfs.c b/src/udev/udev-builtin-btrfs.c index 4b5a5fc610..c96d8e9732 100644 --- a/src/udev/udev-builtin-btrfs.c +++ b/src/udev/udev-builtin-btrfs.c @@ -35,7 +35,7 @@ static int builtin_btrfs(UdevEvent *event, int argc, char *argv[]) { _cleanup_close_ int fd = open("/dev/btrfs-control", O_RDWR|O_CLOEXEC|O_NOCTTY); if (fd < 0) { - if (ERRNO_IS_DEVICE_ABSENT(errno)) { + if (ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(errno)) { /* Driver not installed? Then we aren't ready. This is useful in initrds that lack * btrfs.ko. After the host transition (where btrfs.ko will hopefully become * available) the device can be retriggered and will then be considered ready. */ diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c index 93a20639b8..5ab40a3552 100644 --- a/src/udev/udev-builtin-keyboard.c +++ b/src/udev/udev-builtin-keyboard.c @@ -201,7 +201,7 @@ static int builtin_keyboard(UdevEvent *event, int argc, char *argv[]) { if (fd < 0) { fd = sd_device_open(dev, O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY); if (fd < 0) { - bool ignore = ERRNO_IS_DEVICE_ABSENT(fd); + bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(fd); log_device_full_errno(dev, ignore ? LOG_DEBUG : LOG_WARNING, fd, "Failed to open device '%s'%s: %m", node, ignore ? ", ignoring" : ""); @@ -223,7 +223,7 @@ static int builtin_keyboard(UdevEvent *event, int argc, char *argv[]) { if (fd < 0) { fd = sd_device_open(dev, O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY); if (fd < 0) { - bool ignore = ERRNO_IS_DEVICE_ABSENT(fd); + bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(fd); log_device_full_errno(dev, ignore ? LOG_DEBUG : LOG_WARNING, fd, "Failed to open device '%s'%s: %m", node, ignore ? ", ignoring" : ""); diff --git a/src/udev/udev-builtin-uaccess.c b/src/udev/udev-builtin-uaccess.c index 1f09ec36cd..c382f957cf 100644 --- a/src/udev/udev-builtin-uaccess.c +++ b/src/udev/udev-builtin-uaccess.c @@ -122,7 +122,7 @@ static int builtin_uaccess(UdevEvent *event, int argc, char *argv[]) { _cleanup_close_ int fd = sd_device_open(dev, O_CLOEXEC|O_PATH); if (fd < 0) { - bool ignore = ERRNO_IS_DEVICE_ABSENT(fd); + bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(fd); log_device_full_errno(dev, ignore ? LOG_DEBUG : LOG_WARNING, fd, "Failed to open device node%s: %m", ignore ? ", ignoring" : ""); diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c index 849de60177..75e8b09e89 100644 --- a/src/udev/udev-node.c +++ b/src/udev/udev-node.c @@ -431,7 +431,7 @@ static int link_update(sd_device *dev, const char *slink, bool add) { return r; r = node_get_current(slink, dirfd, ¤t_id, add ? ¤t_prio : NULL); - if (r < 0 && !ERRNO_IS_DEVICE_ABSENT(r)) + if (r < 0 && !ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(r)) return log_device_debug_errno(dev, r, "Failed to get the current device node priority for '%s': %m", slink); r = stack_directory_update(dev, dirfd, add); @@ -702,7 +702,7 @@ int udev_node_apply_permissions( node_fd = sd_device_open(dev, O_PATH|O_CLOEXEC); if (node_fd < 0) { - if (ERRNO_IS_DEVICE_ABSENT(node_fd)) { + if (ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(node_fd)) { log_device_debug_errno(dev, node_fd, "Device node %s is missing, skipping handling.", devnode); return 0; /* This is necessarily racey, so ignore missing the device */ } @@ -735,7 +735,7 @@ int static_node_apply_permissions( node_fd = open(devnode, O_PATH|O_CLOEXEC); if (node_fd < 0) { - bool ignore = ERRNO_IS_DEVICE_ABSENT(errno); + bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(errno); log_full_errno(ignore ? LOG_DEBUG : LOG_WARNING, errno, "Failed to open device node '%s'%s: %m", devnode, ignore ? ", ignoring" : ""); diff --git a/src/udev/udev-worker.c b/src/udev/udev-worker.c index 2a7235589b..c75947a0cb 100644 --- a/src/udev/udev-worker.c +++ b/src/udev/udev-worker.c @@ -112,7 +112,7 @@ static int worker_lock_whole_disk(UdevWorker *worker, sd_device *dev, int *ret_f fd = sd_device_open(dev_whole_disk, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY); if (fd < 0) { - bool ignore = ERRNO_IS_DEVICE_ABSENT(fd); + bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(fd); log_device_debug_errno(dev, fd, "Failed to open '%s'%s: %m", whole_disk, ignore ? ", ignoring" : ""); if (!ignore) @@ -178,7 +178,7 @@ static int worker_mark_block_device_read_only(sd_device *dev) { _cleanup_close_ int fd = sd_device_open(dev, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY); if (fd < 0) { - bool ignore = ERRNO_IS_DEVICE_ABSENT(fd); + bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(fd); log_device_full_errno(dev, ignore ? LOG_DEBUG : LOG_WARNING, fd, "Failed to open device node '%s'%s: %m", node, ignore ? ", ignoring" : ""); diff --git a/src/udev/v4l_id/v4l_id.c b/src/udev/v4l_id/v4l_id.c index cab1308d67..1e374c393c 100644 --- a/src/udev/v4l_id/v4l_id.c +++ b/src/udev/v4l_id/v4l_id.c @@ -61,7 +61,7 @@ static int run(int argc, char *argv[]) { fd = open(arg_device, O_RDONLY|O_CLOEXEC|O_NOCTTY); if (fd < 0) { - bool ignore = ERRNO_IS_DEVICE_ABSENT(errno); + bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(errno); log_full_errno(ignore ? LOG_DEBUG : LOG_WARNING, errno, "Failed to open device node '%s'%s: %m", arg_device, ignore ? ", ignoring" : "");