From: Harald Hoyer Date: Wed, 13 Feb 2013 14:09:36 +0000 (+0100) Subject: log_error() if inotify_add_watch() fails X-Git-Tag: v198~268 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=2826d14091e43ed3397d862dee79d09d0115c84e log_error() if inotify_add_watch() fails [zj: Reworded message s/to watch/to add watch on/ to make it clear that it was the watch init action that failed, and not the "process of watching". I think this way it'll be clearer to people who don't know what inotify does.] --- diff --git a/src/login/sd-login.c b/src/login/sd-login.c index b81dddf86..865527f8d 100644 --- a/src/login/sd-login.c +++ b/src/login/sd-login.c @@ -733,6 +733,7 @@ _public_ int sd_login_monitor_new(const char *category, sd_login_monitor **m) { if (!category || streq(category, "seat")) { k = inotify_add_watch(fd, "/run/systemd/seats/", IN_MOVED_TO|IN_DELETE); if (k < 0) { + log_error("Failed to add watch on /run/systemd/seats/: %m"); close_nointr_nofail(fd); return -errno; } @@ -743,6 +744,7 @@ _public_ int sd_login_monitor_new(const char *category, sd_login_monitor **m) { if (!category || streq(category, "session")) { k = inotify_add_watch(fd, "/run/systemd/sessions/", IN_MOVED_TO|IN_DELETE); if (k < 0) { + log_error("Failed to add watch on /run/systemd/sessions/: %m"); close_nointr_nofail(fd); return -errno; } @@ -753,6 +755,7 @@ _public_ int sd_login_monitor_new(const char *category, sd_login_monitor **m) { if (!category || streq(category, "uid")) { k = inotify_add_watch(fd, "/run/systemd/users/", IN_MOVED_TO|IN_DELETE); if (k < 0) { + log_error("Failed to add watch on /run/systemd/users/: %m"); close_nointr_nofail(fd); return -errno; } diff --git a/src/readahead/readahead-common.c b/src/readahead/readahead-common.c index 41aaff0a3..1599ac15a 100644 --- a/src/readahead/readahead-common.c +++ b/src/readahead/readahead-common.c @@ -227,7 +227,7 @@ int open_inotify(void) { mkdir("/run/systemd/readahead", 0755); if (inotify_add_watch(fd, "/run/systemd/readahead", IN_CREATE) < 0) { - log_error("Failed to watch /run/systemd/readahead: %m"); + log_error("Failed to add watch on /run/systemd/readahead: %m"); close_nointr_nofail(fd); return -errno; } diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c index 8a0fb89a8..10e6ae061 100644 --- a/src/shared/ask-password-api.c +++ b/src/shared/ask-password-api.c @@ -78,6 +78,7 @@ int ask_password_tty( } if (inotify_add_watch(notify, flag_file, IN_ATTRIB /* for the link count */) < 0) { + log_error("Failed to add watch on %s: %m", flag_file); r = -errno; goto finish; } diff --git a/src/shared/util.c b/src/shared/util.c index d754c836f..6ef191422 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -2220,6 +2220,7 @@ int acquire_terminal( wd = inotify_add_watch(notify, name, IN_CLOSE); if (wd < 0) { r = -errno; + log_error("Failed to add watch on %s: %m", name); goto fail; } } 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 99a626c6c..276ccf978 100644 --- a/src/tty-ask-password-agent/tty-ask-password-agent.c +++ b/src/tty-ask-password-agent/tty-ask-password-agent.c @@ -81,6 +81,7 @@ static int ask_password_plymouth( } if (inotify_add_watch(notify, flag_file, IN_ATTRIB /* for the link count */) < 0) { + log_error("Failed to add watch on %s: %m", flag_file); r = -errno; goto finish; } @@ -577,6 +578,7 @@ static int watch_passwords(void) { } if (inotify_add_watch(notify, "/run/systemd/ask-password", IN_CLOSE_WRITE|IN_MOVED_TO) < 0) { + log_error("Failed to add watch on /run/systemd/ask-password: %m"); r = -errno; goto finish; }