Date: Tue, 9 Dec 2008 09:25:03 +0000 (UTC) From: Poul-Henning Kamp <phk@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r185790 - head/usr.sbin/fifolog/lib Message-ID: <200812090925.mB99P36A085969@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: phk Date: Tue Dec 9 09:25:03 2008 New Revision: 185790 URL: http://svn.freebsd.org/changeset/base/185790 Log: Fix a cornercase during search Modified: head/usr.sbin/fifolog/lib/fifolog_int.c head/usr.sbin/fifolog/lib/fifolog_reader.c Modified: head/usr.sbin/fifolog/lib/fifolog_int.c ============================================================================== --- head/usr.sbin/fifolog/lib/fifolog_int.c Tue Dec 9 09:24:25 2008 (r185789) +++ head/usr.sbin/fifolog/lib/fifolog_int.c Tue Dec 9 09:25:03 2008 (r185790) @@ -221,9 +221,9 @@ fifolog_int_read(const struct fifolog_fi 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); } Modified: head/usr.sbin/fifolog/lib/fifolog_reader.c ============================================================================== --- head/usr.sbin/fifolog/lib/fifolog_reader.c Tue Dec 9 09:24:25 2008 (r185789) +++ head/usr.sbin/fifolog/lib/fifolog_reader.c Tue Dec 9 09:25:03 2008 (r185790) @@ -98,7 +98,7 @@ fifolog_reader_findsync(const struct fif 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 fif 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 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_re 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812090925.mB99P36A085969>