diff options
author | adam <adam@FreeBSD.org> | 1996-07-30 13:11:43 +0000 |
---|---|---|
committer | adam <adam@FreeBSD.org> | 1996-07-30 13:11:43 +0000 |
commit | e46b4385753721db1041745487f7d8b57e3162cf (patch) | |
tree | b6ca9a0d0964a44c50564db82f2f4288e3907a16 /usr.bin/tail | |
parent | 84d237928927613ef8052cc504b40894a8f01f4d (diff) | |
download | FreeBSD-src-e46b4385753721db1041745487f7d8b57e3162cf.zip FreeBSD-src-e46b4385753721db1041745487f7d8b57e3162cf.tar.gz |
when file can be opened for read but cannot be read from:
fail once (was twice) in forward case
fail once (was no times) in reverse case
this can happen when file is a directory on an NFS or procfs mount.
Diffstat (limited to 'usr.bin/tail')
-rw-r--r-- | usr.bin/tail/extern.h | 4 | ||||
-rw-r--r-- | usr.bin/tail/read.c | 8 | ||||
-rw-r--r-- | usr.bin/tail/reverse.c | 5 |
3 files changed, 11 insertions, 6 deletions
diff --git a/usr.bin/tail/extern.h b/usr.bin/tail/extern.h index 65efc14..f1daa9b 100644 --- a/usr.bin/tail/extern.h +++ b/usr.bin/tail/extern.h @@ -42,8 +42,8 @@ enum STYLE { NOTSET = 0, FBYTES, FLINES, RBYTES, RLINES, REVERSE }; void forward __P((FILE *, enum STYLE, long, struct stat *)); void reverse __P((FILE *, enum STYLE, long, struct stat *)); -void bytes __P((FILE *, off_t)); -void lines __P((FILE *, off_t)); +int bytes __P((FILE *, off_t)); +int lines __P((FILE *, off_t)); void err __P((int fatal, const char *fmt, ...)); void ierr __P((void)); diff --git a/usr.bin/tail/read.c b/usr.bin/tail/read.c index ad29dbd..94f3f0b 100644 --- a/usr.bin/tail/read.c +++ b/usr.bin/tail/read.c @@ -58,7 +58,7 @@ static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/6/93"; * it is displayed from the character closest to the beginning of the input to * the end. */ -void +int bytes(fp, off) register FILE *fp; off_t off; @@ -80,7 +80,7 @@ bytes(fp, off) } if (ferror(fp)) { ierr(); - return; + return 1; } if (rflag) { @@ -125,7 +125,7 @@ bytes(fp, off) * it is displayed from the line closest to the beginning of the input to * the end. */ -void +int lines(fp, off) register FILE *fp; off_t off; @@ -171,7 +171,7 @@ lines(fp, off) } if (ferror(fp)) { ierr(); - return; + return 1; } if (cnt) { lines[recno].l = sp; diff --git a/usr.bin/tail/reverse.c b/usr.bin/tail/reverse.c index 34cd980..4557064 100644 --- a/usr.bin/tail/reverse.c +++ b/usr.bin/tail/reverse.c @@ -200,6 +200,11 @@ r_buf(fp) len < BSZ && (ch = getc(fp)) != EOF; ++len) *p++ = ch; + if (ferror(fp)) { + ierr(); + return; + } + /* * If no input data for this block and we tossed some data, * recover it. |