diff options
author | Poul-Henning Kamp <phk@FreeBSD.org> | 2008-12-09 09:25:03 +0000 |
---|---|---|
committer | Poul-Henning Kamp <phk@FreeBSD.org> | 2008-12-09 09:25:03 +0000 |
commit | ba2b54296f0d0b8070e6b9792822c95d8c693ebf (patch) | |
tree | b16a241f5261afe600eaf32c78b256b02dcc7a78 /usr.sbin/fifolog | |
parent | 9435575dbe5f7e8a2b87f7f3d07076541d3f441e (diff) | |
download | src-test2-ba2b54296f0d0b8070e6b9792822c95d8c693ebf.tar.gz src-test2-ba2b54296f0d0b8070e6b9792822c95d8c693ebf.zip |
Notes
Diffstat (limited to 'usr.sbin/fifolog')
-rw-r--r-- | usr.sbin/fifolog/lib/fifolog_int.c | 4 | ||||
-rw-r--r-- | usr.sbin/fifolog/lib/fifolog_reader.c | 12 |
2 files changed, 9 insertions, 7 deletions
diff --git a/usr.sbin/fifolog/lib/fifolog_int.c b/usr.sbin/fifolog/lib/fifolog_int.c index 158c613d266f..f87fd8204533 100644 --- a/usr.sbin/fifolog/lib/fifolog_int.c +++ b/usr.sbin/fifolog/lib/fifolog_int.c @@ -221,9 +221,9 @@ fifolog_int_read(const struct fifolog_file *ff, off_t recno) recno++; /* label sector */ i = pread(ff->fd, ff->recbuf, ff->recsize, recno * ff->recsize); if (i < 0) - return (-1); + return (-2); if (i != (int)ff->recsize) - return (-1); + return (-3); return (0); } diff --git a/usr.sbin/fifolog/lib/fifolog_reader.c b/usr.sbin/fifolog/lib/fifolog_reader.c index 37a03b7782e4..fde2a0773829 100644 --- a/usr.sbin/fifolog/lib/fifolog_reader.c +++ b/usr.sbin/fifolog/lib/fifolog_reader.c @@ -98,7 +98,7 @@ fifolog_reader_findsync(const struct fifolog_file *ff, off_t *o) assert(*o < ff->logsize); e = fifolog_int_read(ff, *o); if (e) - err(1, "Read error while looking for SYNC"); + err(1, "Read error (%d) while looking for SYNC", e); seq = be32dec(ff->recbuf); if (*o == 0 && seq == 0) return (0); @@ -113,7 +113,7 @@ fifolog_reader_findsync(const struct fifolog_file *ff, off_t *o) return (2); /* wraparound */ e = fifolog_int_read(ff, *o); if (e) - err(1, "Read error while looking for SYNC"); + err(1, "Read error (%d) while looking for SYNC", e); seqs = be32dec(ff->recbuf); if (seqs != seq) return (3); /* End of log */ @@ -174,8 +174,10 @@ fifolog_reader_seek(const struct fifolog_reader *fr, time_t t0) continue; } e = fifolog_int_read(fr->ff, o + st); - if (e) - err(1, "Read error, duing binary search"); + if (e) { + s = st = s / 2; + continue; + } /* If not in same part, sequence won't match */ seqs = be32dec(fr->ff->recbuf); if (seqs != seq + st) { @@ -254,7 +256,7 @@ fifolog_reader_process(struct fifolog_reader *fr, off_t from, fifolog_reader_ren while (1) { e = fifolog_int_read(fr->ff, o); if (e) - err(1, "Read error"); + err(1, "Read error (%d)", e); if (++o >= fr->ff->logsize) o = 0; seq = be32dec(fr->ff->recbuf); |