From 1432d2dbdfa90963272a9b581dc4b55dd3ac514f Mon Sep 17 00:00:00 2001 From: Jan Synacek Date: Mon, 8 Oct 2018 15:14:38 +0200 Subject: [PATCH] ask-password: improve log message when inotify limit is reached When inotify_add_watch() fails because of the inotify limit, errno is set to ENOSPC and then gets shown to users as "No space left on device". That is very confusing and requires in-depth knowledge of the C library. Therefore, show user-friendly message when inotify limit is reached. Fixes #6030. --- src/tty-ask-password-agent/tty-ask-password-agent.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c index ba2e1d37f0e..1aa90b60400 100644 --- a/src/tty-ask-password-agent/tty-ask-password-agent.c +++ b/src/tty-ask-password-agent/tty-ask-password-agent.c @@ -519,8 +519,12 @@ static int watch_passwords(void) { if (notify < 0) return log_error_errno(errno, "Failed to allocate directory watch: %m"); - if (inotify_add_watch(notify, "/run/systemd/ask-password", IN_CLOSE_WRITE|IN_MOVED_TO) < 0) - return log_error_errno(errno, "Failed to add /run/systemd/ask-password to directory watch: %m"); + if (inotify_add_watch(notify, "/run/systemd/ask-password", IN_CLOSE_WRITE|IN_MOVED_TO) < 0) { + if (errno == ENOSPC) + return log_error_errno(errno, "Failed to add /run/systemd/ask-password to directory watch: inotify watch limit reached"); + else + return log_error_errno(errno, "Failed to add /run/systemd/ask-password to directory watch: %m"); + } assert_se(sigemptyset(&mask) >= 0); assert_se(sigset_add_many(&mask, SIGINT, SIGTERM, -1) >= 0);