summaryrefslogtreecommitdiff
path: root/src/tail.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-03-04 14:31:29 +0000
committerJim Meyering <jim@meyering.net>2000-03-04 14:31:29 +0000
commit049ca98c745f88f384587cfa8c12392db2325193 (patch)
treeefc2ceb77958ba9f341b695e05387cd6cb6d037b /src/tail.c
parent7b2d50e3af769a53fdc098ef0e6f87b81f3430ed (diff)
downloadcoreutils-049ca98c745f88f384587cfa8c12392db2325193.tar.xz
Don't get failed assertion for `tail -f directory'.
Revert most of 1999-10-20 change. Instead, ... (IS_TAILABLE_FILE_TYPE): Define to produce similar result. (recheck): Use it here. (tail_file): Use it here.
Diffstat (limited to 'src/tail.c')
-rw-r--r--src/tail.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/tail.c b/src/tail.c
index a2a8979b1..aaf259314 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -1,5 +1,5 @@
/* tail -- output the last part of file(s)
- Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
+ Copyright (C) 89, 90, 91, 1995-2000 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -84,6 +84,10 @@ enum Follow_mode
Follow_descriptor = 2
};
+/* The types of files for which tail works. */
+#define IS_TAILABLE_FILE_TYPE(Mode) \
+ (S_ISREG (Mode) || S_ISFIFO (Mode) || S_ISCHR (Mode))
+
static char const *const follow_mode_string[] =
{
"descriptor", "name", 0
@@ -748,6 +752,13 @@ recheck (struct File_spec *f)
error (0, errno, "%s", pretty_name (f));
}
}
+ else if (!IS_TAILABLE_FILE_TYPE (new_stats.st_mode))
+ {
+ fail = 1;
+ f->errnum = -1;
+ error (0, 0, _("`%s' has been replaced with an untailable file"),
+ pretty_name (f));
+ }
else
{
f->errnum = 0;
@@ -1133,6 +1144,13 @@ tail_file (struct File_spec *f, off_t n_units)
f->errnum = errno;
error (0, errno, "%s", pretty_name (f));
}
+ else if (!IS_TAILABLE_FILE_TYPE (stats.st_mode))
+ {
+ error (0, 0, _("%s: cannot follow end of this type of file"),
+ pretty_name (f));
+ errors = 1;
+ f->errnum = -1;
+ }
if (errors)
{