Searched hist:82526 (Results 1 - 1 of 1) sorted by relevance

/freebsd-11-stable/stand/libsa/
H A Dlseek.cdiff 82526 Wed Aug 29 23:33:22 MDT 2001 jdp 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

Completed in 64 milliseconds