From: Jim Meyering Date: Sat, 4 Mar 2000 18:16:21 +0000 (+0000) Subject: Once we encounter a file that is not of IS_TAILABLE_FILE_TYPE, X-Git-Tag: TEXTUTILS-2_0e~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=54d12f7eddbc01dc51de33d6fc97067b0a251f1d;p=thirdparty%2Fcoreutils.git 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. --- diff --git a/src/tail.c b/src/tail.c index aaf2593140..642d5df22e 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