Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Aug 2001 16:33:23 -0700 (PDT)
From:      John Polstra <jdp@FreeBSD.org>
To:        cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   cvs commit: src/lib/libstand lseek.c
Message-ID:  <200108292333.f7TNXOi23662@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200108292333.f7TNXOi23662>