1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-19 10:53:58 +00:00
freebsd/lib/libstand
John Polstra 719077d1be 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
2001-08-29 23:33:22 +00:00
..
alpha
i386 Removed duplicate VCS ID tags, as per style(9). 2001-08-13 14:06:34 +00:00
ia64 Removed duplicate VCS ID tags, as per style(9). 2001-08-13 14:06:34 +00:00
powerpc Make setjmp work our way, as opposed to NetBSD's. 2000-11-10 06:10:28 +00:00
__main.c
arp.c
assert.c Make include file consistent with the rest of libstand. 2001-07-31 15:49:50 +00:00
bcd.c
bootp.c
bootp.h
bootparam.c
bootparam.h
bswap.c
cd9660.c Bail if we go beyond the directory size, not just if we hit it. 2001-08-23 17:08:26 +00:00
close.c
closeall.c
dev_net.c
dev_net.h
dev.c
dosfs.c
dosfs.h
environment.c
ether.c
ext2fs.c Fix typo: compatability -> compatibility. 2001-02-06 12:05:58 +00:00
fstat.c
getopt.c
gets.c
globals.c
gzipfs.c
if_ether.h
in_cksum.c
inet_ntoa.c
ioctl.c
iodesc.h
libstand.3 mdoc(7) police: s/BSD/.Bx/ where appropriate. 2001-08-14 10:01:54 +00:00
lseek.c Fix a bug in lseek which caused the loader to fail on some gzipped 2001-08-29 23:33:22 +00:00
Makefile MAN[1-9] -> MAN. 2001-03-27 17:27:19 +00:00
net.c
net.h
netif.c Compensate for header dethreading. 2001-05-01 09:37:01 +00:00
netif.h
nfs.c
nfsv2.h
nullfs.c
open.c
pager.c Silence -Wnon-const-format 2001-02-18 04:51:47 +00:00
printf.c
qdivrem.c
quad.h
random.c
rarp.c
read.c
readdir.c
rpc.c
rpc.h
rpcv2.h
saioctl.h
sbrk.c
stand.h Replace functional bugs of ctypish functions in libstand with style 2001-05-14 16:49:20 +00:00
stat.c
strcasecmp.c
strdup.c
strerror.c
strtol.c
tftp.c Reset errno so that subsequent TFTP requests don't fail after the 2001-06-30 21:39:09 +00:00
tftp.h
twiddle.c
udp.c Correct the returned UDP datagram length. See the PR for a more comprehensive 2001-05-28 22:27:06 +00:00
ufs.c
write.c
zalloc_defs.h A quick and dirty port of libstand to ia64. 2001-03-06 16:11:36 +00:00
zalloc_malloc.c
zalloc_mem.h
zalloc_protos.h
zalloc.c
zipfs.c