From: Karel Zak Date: Tue, 11 Aug 2009 13:22:35 +0000 (+0200) Subject: tailf: report inotify_add_watch() problems X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8733a8867805e83890469f591025f396d77e20e;p=util-linux tailf: report inotify_add_watch() problems Signed-off-by: Karel Zak --- diff --git a/text-utils/tailf.c b/text-utils/tailf.c index e44fc098..6a76ef45 100644 --- a/text-utils/tailf.c +++ b/text-utils/tailf.c @@ -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];