diff options
author | Jim Meyering <jim@meyering.net> | 2000-03-04 18:16:21 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-03-04 18:16:21 +0000 |
commit | 54d12f7eddbc01dc51de33d6fc97067b0a251f1d (patch) | |
tree | 27d9e2f6de617fd28bad6864d5113cd675773db6 | |
parent | f600c4d1446de3710b3265d8a7c3177b71ab7bcc (diff) | |
download | coreutils-54d12f7eddbc01dc51de33d6fc97067b0a251f1d.tar.xz |
Once we encounter a file that is not of IS_TAILABLE_FILE_TYPE,
marke it as such and ignore it forever after.
(struct File_spec): New member.
(recheck): Initialize new member.
(tail_file): Likewise.
(tail_forever): Skip the file if it's marked as ignorable.
-rw-r--r-- | src/tail.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/tail.c b/src/tail.c index aaf259314..642d5df22 100644 --- a/src/tail.c +++ b/src/tail.c @@ -113,14 +113,19 @@ struct File_spec dev_t dev; ino_t ino; + /* The specified name initially referred to a directory or some other + type for which tail isn't meaningful. Unlike for a permission problem + (tailable, below) once this is set, the name is not checked ever again. */ + int ignore; + /* See description of DEFAULT_MAX_N_... below. */ unsigned int n_unchanged_stats; /* See description of DEFAULT_MAX_N_... below. */ unsigned int n_consecutive_size_changes; - /* A file is tailable if it is a regular file or a fifo and it is - readable. */ + /* A file is tailable if it exists, is readable, and is of type + IS_TAILABLE_FILE_TYPE. */ int tailable; /* The value of errno seen last time we checked this file. */ @@ -756,8 +761,10 @@ recheck (struct File_spec *f) { fail = 1; f->errnum = -1; - error (0, 0, _("`%s' has been replaced with an untailable file"), + error (0, 0, _("`%s' has been replaced with an untailable file;\ + giving up on this name"), pretty_name (f)); + f->ignore = 1; } else { @@ -822,6 +829,7 @@ recheck (struct File_spec *f) f->ino = new_stats.st_ino; f->n_unchanged_stats = 0; f->n_consecutive_size_changes = 0; + f->ignore = 0; /* FIXME: check lseek return value */ lseek (f->fd, f->size, SEEK_SET); } @@ -868,6 +876,9 @@ tail_forever (struct File_spec *f, int nfiles) { struct stat stats; + if (f[i].ignore) + continue; + if (f[i].fd < 0) { recheck (&f[i]); @@ -1146,10 +1157,12 @@ tail_file (struct File_spec *f, off_t n_units) } else if (!IS_TAILABLE_FILE_TYPE (stats.st_mode)) { - error (0, 0, _("%s: cannot follow end of this type of file"), + error (0, 0, _("%s: cannot follow end of this type of file;\ + giving up on this name"), pretty_name (f)); errors = 1; f->errnum = -1; + f->ignore = 1; } if (errors) @@ -1165,6 +1178,7 @@ tail_file (struct File_spec *f, off_t n_units) f->ino = stats.st_ino; f->n_unchanged_stats = 0; f->n_consecutive_size_changes = 0; + f->ignore = 0; } } else |