The tailf(1) never worked very well with block or character devices, sockets, fifos and such. Now after mmap() is used to find last lines even the little command used to work is broken, so test the tailf is asked to follow a file and when not fail. That said symlinks are OK, as long they point to a file. Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- text-utils/tailf.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/text-utils/tailf.c b/text-utils/tailf.c index d856203..7f053a4 100644 --- a/text-utils/tailf.c +++ b/text-utils/tailf.c @@ -233,6 +233,28 @@ static long old_style_option(int *argc, char **argv, unsigned long *lines) return ret; } +static int is_file(const char *filename, const struct stat sb) +{ + switch (sb.st_mode & S_IFMT) { + case S_IFREG: + return 0; + case S_IFLNK: + { + char *resolved_path = NULL; + struct stat follow; + int ret; + + if (realpath(filename, resolved_path)) { + stat(resolved_path, &follow); + ret = is_file(resolved_path, follow); + free(resolved_path); + return ret; + } + } + } + return 1; +} + int main(int argc, char **argv) { const char *filename; @@ -281,6 +303,8 @@ int main(int argc, char **argv) if (stat(filename, &old) != 0) err(EXIT_FAILURE, _("stat of %s failed"), filename); + if (is_file(filename, old)) + errx(EXIT_FAILURE, _("%s: is not a file"), filename); if (lines && old.st_size) tailf(filename, lines, &old); -- 2.3.0 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html