On Sun, Feb 22, 2015 at 02:41:44PM +0000, Sami Kerola wrote: > 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; > + } > + } but you use stat() and no lstat(), so you don't have to care about symlinks, right? :-) > if (stat(filename, &old) != 0) > err(EXIT_FAILURE, _("stat of %s failed"), filename); if (IS_REG(old.st_mode)) errx(EXIT_FAILURE, _("%s: is not a file"), filename); > + if (is_file(filename, old)) > + errx(EXIT_FAILURE, _("%s: is not a file"), filename); > if (lines && old.st_size) > tailf(filename, lines, &old); Karel -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com -- 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