From owner-svn-src-head@FreeBSD.ORG Tue Dec 9 09:25:03 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B9189106564A; Tue, 9 Dec 2008 09:25:03 +0000 (UTC) (envelope-from phk@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A7DCD8FC28; Tue, 9 Dec 2008 09:25:03 +0000 (UTC) (envelope-from phk@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mB99P3Ix085971; Tue, 9 Dec 2008 09:25:03 GMT (envelope-from phk@svn.freebsd.org) Received: (from phk@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mB99P36A085969; Tue, 9 Dec 2008 09:25:03 GMT (envelope-from phk@svn.freebsd.org) Message-Id: <200812090925.mB99P36A085969@svn.freebsd.org> From: Poul-Henning Kamp Date: Tue, 9 Dec 2008 09:25:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r185790 - head/usr.sbin/fifolog/lib X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Dec 2008 09:25:03 -0000 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);