]> err.no Git - util-linux/commitdiff
tailf: report inotify_add_watch() problems
authorKarel Zak <kzak@redhat.com>
Tue, 11 Aug 2009 13:22:35 +0000 (15:22 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 11 Aug 2009 13:22:35 +0000 (15:22 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
text-utils/tailf.c

index e44fc098261d66df7e92d46c7c5130f6273d48da..6a76ef4539cb7dd939b7177faf6aaa5f398e4cc1 100644 (file)
@@ -141,12 +141,22 @@ watch_file_inotify(const char *filename, off_t *size)
                return 0;
 
        ffd = inotify_add_watch(fd, filename, EVENTS);
+       if (ffd == -1) {
+               if (errno == ENOSPC)
+                       errx(EXIT_FAILURE, _("%s: cannot add inotify watch "
+                               "(limit of inotify watches was reached)."),
+                               filename);
+
+               err(EXIT_FAILURE, _("%s: cannot add inotify watch."), filename);
+       }
+
        while (ffd >= 0) {
                len = read(fd, buf, sizeof(buf));
                if (len < 0 && (errno == EINTR || errno == EAGAIN))
                        continue;
                if (len < 0)
-                       err(EXIT_FAILURE, "%s: cannot read inotify events", filename);
+                       err(EXIT_FAILURE,
+                               _("%s: cannot read inotify events"), filename);
 
                for (e = 0; e < len; ) {
                        struct inotify_event *ev = (struct inotify_event *) &buf[e];