From owner-cvs-all Wed Aug 29 16:33:47 2001 Delivered-To: cvs-all@freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id B472437B403; Wed, 29 Aug 2001 16:33:41 -0700 (PDT) (envelope-from jdp@FreeBSD.org) Received: (from jdp@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f7TNXOi23662; Wed, 29 Aug 2001 16:33:24 -0700 (PDT) (envelope-from jdp) Message-Id: <200108292333.f7TNXOi23662@freefall.freebsd.org> From: John Polstra Date: Wed, 29 Aug 2001 16:33:23 -0700 (PDT) To: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: cvs commit: src/lib/libstand lseek.c X-FreeBSD-CVS-Branch: HEAD Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG jdp 2001/08/29 16:33:23 PDT Modified files: lib/libstand lseek.c Log: Fix a bug in lseek which caused the loader to fail on some gzipped kernels. The error message was "elf_loadexec: cannot seek". Libstand maintains a read-ahead buffer for each open file, so that it can read in chunks of 512 bytes for greater efficiency. When the loader tries to lseek forward in a file by a small amount, it sometimes happens that the target file offset is already in the read-ahead buffer. But the lseek code simply discarded the contents of that buffer and performed a seek directly on the underlying file. This resulted in an attempt to seek backwards in the file, since some of the data has already been read into the read-ahead buffer. Gzipped data streams cannot seek backwards, so an error was returned. This commit adds code which checks to see if the desired file offset is already in the read-ahead buffer. If it is, the code simply adjusts the buffer pointer and length, thereby avoiding a reverse seek on the gzipped data stream. I incorporated a suggestion from Matt Dillon which saved a little bit of code in this fix. Reviewed by: dillon, gallatin, jhb Revision Changes Path 1.3 +32 -1 src/lib/libstand/lseek.c To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message