summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-12-03 20:37:18 +0000
committerJim Meyering <jim@meyering.net>2000-12-03 20:37:18 +0000
commit2eed25f2edd0c6bb7cd56b71ee4e223987d29464 (patch)
tree05cf93f0fd30e5c60bdda9b124c4787d67ac4171
parent1be9e19c7da988a9937b357f62aad72cf1764fbb (diff)
downloadcoreutils-2eed25f2edd0c6bb7cd56b71ee4e223987d29464.tar.xz
add instrumentation to detect some UMRs
-rw-r--r--src/tail.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/tail.c b/src/tail.c
index 1ab9a8f3a..9952850e9 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -44,6 +44,21 @@
#define AUTHORS \
"Paul Rubin, David MacKenzie, Ian Lance Taylor, and Jim Meyering"
+#define MAGIC_BYTE 0xfa
+
+#define IS_MAGIC(x) \
+ ({ \
+ int _result = 0; \
+ unsigned char *_p = (unsigned char *) &(x); \
+ int _i; \
+ for (_i = 0; _i < sizeof(x); _i++) \
+ { \
+ if (_p[_i] == MAGIC_BYTE) \
+ _result = 1; \
+ } \
+ _result; \
+ })
+
#ifndef ENOSYS
/* Some systems don't have ENOSYS -- this should be a big enough
value that no valid errno value will match it. */
@@ -725,6 +740,8 @@ recheck (struct File_spec *f)
int prev_errnum = f->errnum;
int new_file;
+ assert (! IS_MAGIC (f->errnum));
+
assert (valid_file_spec (f));
fd = (is_stdin ? STDIN_FILENO : open (f->name, O_RDONLY));
@@ -785,7 +802,8 @@ recheck (struct File_spec *f)
assert (f->fd == -1);
error (0, 0, _("`%s' has become accessible"), pretty_name (f));
}
- else if (f->ino != new_stats.st_ino || f->dev != new_stats.st_dev)
+ else if ((assert (!IS_MAGIC (f->ino) && ! IS_MAGIC (f->dev)), 0)
+ || f->ino != new_stats.st_ino || f->dev != new_stats.st_dev) /* UMR */
{
new_file = 1;
if (f->fd == -1)
@@ -877,7 +895,8 @@ tail_forever (struct File_spec *f, int nfiles)
{
struct stat stats;
- if (f[i].ignore)
+ assert (! IS_MAGIC (f[i].ignore));
+ if (f[i].ignore) /* UMR */
continue;
if (f[i].fd < 0)
@@ -1554,6 +1573,7 @@ main (int argc, char **argv)
}
F = (struct File_spec *) xmalloc (n_files * sizeof (F[0]));
+ memset (F, MAGIC_BYTE, n_files * sizeof (F[0]));
for (i = 0; i < n_files; i++)
F[i].name = file[i];