summaryrefslogtreecommitdiff
path: root/src/tty-ask-password-agent
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2019-09-17 11:16:52 +0200
committerFranck Bui <fbui@suse.com>2019-10-05 08:08:20 +0200
commit27c3112dcbd1b5f171c36c32550d9c6331375b0b (patch)
tree2615b1f194118bd0726803704d12392cb32ad82a /src/tty-ask-password-agent
parent5461cdebfa5e385706592253ce6261f92ce531db (diff)
downloadsystemd-27c3112dcbd1b5f171c36c32550d9c6331375b0b.tar.gz
fs-util: introduce inotify_add_watch_and_warn() helper
The default message for ENOSPC is very misleading: it says that the disk is filled, but in fact the inotify watch limit is the problem. So let's introduce and use a wrapper that simply calls inotify_add_watch(2) and which fixes the error message up in case ENOSPC is returned.
Diffstat (limited to 'src/tty-ask-password-agent')
-rw-r--r--src/tty-ask-password-agent/tty-ask-password-agent.c11
1 files changed, 4 insertions, 7 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 0553abca64..f57f0ec261 100644
--- a/src/tty-ask-password-agent/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
@@ -11,7 +11,6 @@
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
-#include <sys/inotify.h>
#include <sys/prctl.h>
#include <sys/signalfd.h>
#include <sys/socket.h>
@@ -29,6 +28,7 @@
#include "exit-status.h"
#include "fd-util.h"
#include "fileio.h"
+#include "fs-util.h"
#include "hashmap.h"
#include "io-util.h"
#include "macro.h"
@@ -510,12 +510,9 @@ static int process_and_watch_password_files(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) {
- 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");
- }
+ r = inotify_add_watch_and_warn(notify, "/run/systemd/ask-password", IN_CLOSE_WRITE|IN_MOVED_TO);
+ if (r < 0)
+ return r;
assert_se(sigemptyset(&mask) >= 0);
assert_se(sigset_add_many(&mask, SIGINT, SIGTERM, -1) >= 0);