summaryrefslogtreecommitdiffstats
path: root/usr.bin/tail/reverse.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2009-06-05 09:08:53 +0000
committerbrian <brian@FreeBSD.org>2009-06-05 09:08:53 +0000
commit330bc8582df629e9fa4dccb68bbab181520d98a9 (patch)
treee543b101f94f862f5071b48f0a4c466e2afa6f25 /usr.bin/tail/reverse.c
parentc284a3411ae19dfa5dbf2a027bbbd7aa24ff1191 (diff)
downloadFreeBSD-src-330bc8582df629e9fa4dccb68bbab181520d98a9.zip
FreeBSD-src-330bc8582df629e9fa4dccb68bbab181520d98a9.tar.gz
Change the behaviour of -F slightly; it now persists (forever) in
trying to open files rather than giving up when it encounters an error. ENOENT errors are not reported. As a result, files that are moved away then recreated are not at risk of being 'lost' to tail. Files that are recreated and temporarily have unreadable permissions will be shown when they are fixed. This behaviour is consistent with the GNU version of tail but without the verbiage that goes with the GNU version. This change also fixes error messages accompanying -f and -F. They no longer report problems with (null)! MFC after: 3 weeks
Diffstat (limited to 'usr.bin/tail/reverse.c')
-rw-r--r--usr.bin/tail/reverse.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/usr.bin/tail/reverse.c b/usr.bin/tail/reverse.c
index 462b392..d86c46b 100644
--- a/usr.bin/tail/reverse.c
+++ b/usr.bin/tail/reverse.c
@@ -58,8 +58,8 @@ __FBSDID("$FreeBSD$");
#include "extern.h"
-static void r_buf(FILE *);
-static void r_reg(FILE *, enum STYLE, off_t, struct stat *);
+static void r_buf(FILE *, const char *);
+static void r_reg(FILE *, const char *, enum STYLE, off_t, struct stat *);
/*
* reverse -- display input in reverse order by line.
@@ -80,25 +80,25 @@ static void r_reg(FILE *, enum STYLE, off_t, struct stat *);
* NOREG cyclically read input into a linked list of buffers
*/
void
-reverse(FILE *fp, enum STYLE style, off_t off, struct stat *sbp)
+reverse(FILE *fp, const char *fn, enum STYLE style, off_t off, struct stat *sbp)
{
if (style != REVERSE && off == 0)
return;
if (S_ISREG(sbp->st_mode))
- r_reg(fp, style, off, sbp);
+ r_reg(fp, fn, style, off, sbp);
else
switch(style) {
case FBYTES:
case RBYTES:
- bytes(fp, off);
+ bytes(fp, fn, off);
break;
case FLINES:
case RLINES:
- lines(fp, off);
+ lines(fp, fn, off);
break;
case REVERSE:
- r_buf(fp);
+ r_buf(fp, fn);
break;
default:
break;
@@ -109,7 +109,7 @@ reverse(FILE *fp, enum STYLE style, off_t off, struct stat *sbp)
* r_reg -- display a regular file in reverse order by line.
*/
static void
-r_reg(FILE *fp, enum STYLE style, off_t off, struct stat *sbp)
+r_reg(FILE *fp, const char *fn, enum STYLE style, off_t off, struct stat *sbp)
{
struct mapinfo map;
off_t curoff, size, lineend;
@@ -132,7 +132,7 @@ r_reg(FILE *fp, enum STYLE style, off_t off, struct stat *sbp)
if (curoff < map.mapoff ||
curoff >= map.mapoff + (off_t)map.maplen) {
if (maparound(&map, curoff) != 0) {
- ierr();
+ ierr(fn);
return;
}
}
@@ -149,7 +149,7 @@ r_reg(FILE *fp, enum STYLE style, off_t off, struct stat *sbp)
/* Print the line and update offsets. */
if (mapprint(&map, curoff + 1, lineend - curoff - 1) != 0) {
- ierr();
+ ierr(fn);
return;
}
lineend = curoff + 1;
@@ -165,11 +165,11 @@ r_reg(FILE *fp, enum STYLE style, off_t off, struct stat *sbp)
}
}
if (curoff < 0 && mapprint(&map, 0, lineend) != 0) {
- ierr();
+ ierr(fn);
return;
}
if (map.start != NULL && munmap(map.start, map.maplen))
- ierr();
+ ierr(fn);
}
typedef struct bf {
@@ -190,7 +190,7 @@ typedef struct bf {
* user warned).
*/
static void
-r_buf(FILE *fp)
+r_buf(FILE *fp, const char *fn)
{
BF *mark, *tl, *tr;
int ch, len, llen;
@@ -227,7 +227,7 @@ r_buf(FILE *fp)
*p++ = ch;
if (ferror(fp)) {
- ierr();
+ ierr(fn);
return;
}
OpenPOWER on IntegriCloud