sd-event,sd-journal: fix error handling of inotify_add_watch_fd()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 19 Apr 2024 04:19:00 +0000 (13:19 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 19 Apr 2024 09:10:55 +0000 (11:10 +0200)
Fixes a bug in 97ef5391697c34ee1c763fa9bddcd20a29ff3159 and
858749f7312bd0adb5433075a92e1c35a2fb56ac.

src/libsystemd/sd-event/sd-event.c
src/libsystemd/sd-journal/sd-journal.c

index 12aa98059381516a805e4eb5fddae02a61d08726..779c5fc3105d845273b1fc4987c44389178b3879 100644 (file)
@@ -2415,7 +2415,7 @@ static int inode_data_realize_watch(sd_event *e, struct inode_data *d) {
 
         wd = inotify_add_watch_fd(d->inotify_data->fd, d->fd, combined_mask);
         if (wd < 0)
-                return -errno;
+                return wd;
 
         if (d->wd < 0) {
                 r = hashmap_put(d->inotify_data->wd, INT_TO_PTR(wd), d);
index a4ed3804d8661aac82d03c3c04fb71cacaeae1e6..713cdcc0ec6323625fbde916131ba03f473089c5 100644 (file)
@@ -1973,7 +1973,7 @@ static void directory_watch(sd_journal *j, Directory *m, int fd, uint32_t mask)
 
         m->wd = inotify_add_watch_fd(j->inotify_fd, fd, mask);
         if (m->wd < 0) {
-                log_debug_errno(errno, "Failed to watch journal directory '%s', ignoring: %m", m->path);
+                log_debug_errno(m->wd, "Failed to watch journal directory '%s', ignoring: %m", m->path);
                 return;
         }