[systemd-devel] [PATCH] log_error(), if inotify_add_watch() fails

harald at redhat.com harald at redhat.com
Wed Feb 13 06:09:36 PST 2013


From: Harald Hoyer <harald at redhat.com>

---
 src/login/sd-login.c                                | 3 +++
 src/shared/ask-password-api.c                       | 1 +
 src/shared/util.c                                   | 1 +
 src/tty-ask-password-agent/tty-ask-password-agent.c | 2 ++
 4 files changed, 7 insertions(+)

diff --git a/src/login/sd-login.c b/src/login/sd-login.c
index b81dddf..d204f34 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 watch /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 watch /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 watch /run/systemd/users/: %m");
                         close_nointr_nofail(fd);
                         return -errno;
                 }
diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c
index 8a0fb89..4f14280 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 watch %s: %m", flag_file);
                         r = -errno;
                         goto finish;
                 }
diff --git a/src/shared/util.c b/src/shared/util.c
index d754c83..d8203dc 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 watch %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 99a626c..88f5cd3 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 watch %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 watch /run/systemd/ask-password: %m");
                 r = -errno;
                 goto finish;
         }
-- 
1.8.1



More information about the systemd-devel mailing list