summaryrefslogtreecommitdiffstats
path: root/src/vconsole
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2024-02-09 12:55:27 +0100
committerLennart Poettering <lennart@poettering.net>2024-02-09 14:19:20 +0100
commitf244e7a7ead3194807a367a986f2d8427b3b0888 (patch)
tree872d005a72cd98f04712398e610d934f298c249f /src/vconsole
parentdev-setup: normalize logging around lock_dev_console() (diff)
downloadsystemd-f244e7a7ead3194807a367a986f2d8427b3b0888.tar.xz
systemd-f244e7a7ead3194807a367a986f2d8427b3b0888.zip
pid1,vconsole-setup: gracefully handle if /dev/vconsole is not accessible due to ENODEV
I think this is generally the right thing to do and is just an extension of the existing ENOENT check. Prompted by: #31257
Diffstat (limited to 'src/vconsole')
-rw-r--r--src/vconsole/vconsole-setup.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
index 83e43b16ff..554d00e5b7 100644
--- a/src/vconsole/vconsole-setup.c
+++ b/src/vconsole/vconsole-setup.c
@@ -624,14 +624,10 @@ static int run(int argc, char **argv) {
/* Take lock around the remaining operation to avoid being interrupted by a tty reset operation
* performed for services with TTYVHangup=yes. */
lock_fd = lock_dev_console();
- if (lock_fd < 0) {
- log_full_errno(lock_fd == -ENOENT ? LOG_DEBUG : LOG_ERR,
- lock_fd,
- "Failed to lock /dev/console%s: %m",
- lock_fd == -ENOENT ? ", ignoring" : "");
- if (lock_fd != -ENOENT)
- return lock_fd;
- }
+ if (ERRNO_IS_NEG_DEVICE_ABSENT(lock_fd))
+ log_debug_errno(lock_fd, "Device /dev/console does not exist, proceeding without locking it: %m");
+ else if (lock_fd < 0)
+ return log_error_errno(lock_fd, "Failed to lock /dev/console: %m");
(void) toggle_utf8_sysfs(utf8);
(void) toggle_utf8_vc(vc, fd, utf8);