aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/stdio
diff options
context:
space:
mode:
authorNate Williams <nate@FreeBSD.org>1994-11-05 18:49:34 +0000
committerNate Williams <nate@FreeBSD.org>1994-11-05 18:49:34 +0000
commit692a99c012514f7d592c8e60b66d9203e0a7a93d (patch)
tree7f3f4ff1eb4d79e62ac69689ad16a3d3369fab6d /lib/libc/stdio
parent01bb3d8e1860cb4481f7cebe3fd86ee93b58758c (diff)
downloadsrc-692a99c012514f7d592c8e60b66d9203e0a7a93d.tar.gz
src-692a99c012514f7d592c8e60b66d9203e0a7a93d.zip
Date: Wed, 26 Oct 1994 15:44:49 -0600
From: Chris Torek <torek@bsdi.com> Here is a semi-official patch (apply to /usr/src/lib/libc/stdio/fseek.c, rebuild libc, install). The current code fails when the seek: - is optimized, and - is to just past the end of the block currently in the buffer, and - is followed by another seek with no intervening read operation, and - the destination of subsequent seek is within the block left in the buffer (seeking to the beginning of a block does not force a read, so the buffer still contains the previous block) so it is indeed rather obscure. I may have a different `final' fix, as this one `loses' the buffer contents on a seek that goes just past the end of the current block. [Footnote: seeks are optimized only on read-only opens of regular files that are buffered by the file's optimal I/O size. This is what you get with fopen(path, "r") and no call to setvbuf().] Obtained from: [ BSDI mailing list ]
Notes
Notes: svn path=/head/; revision=4169
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r--lib/libc/stdio/fseek.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c
index 6b0cc8b41fa1..9cb04ad03787 100644
--- a/lib/libc/stdio/fseek.c
+++ b/lib/libc/stdio/fseek.c
@@ -213,6 +213,7 @@ fseek(fp, offset, whence)
if ((*seekfn)(fp->_cookie, curoff, SEEK_SET) == POS_ERR)
goto dumb;
fp->_r = 0;
+ fp->_p = fp->_bf._base;
if (HASUB(fp))
FREEUB(fp);
fp->_flags &= ~__SEOF;