diff options
author | ache <ache@FreeBSD.org> | 2001-09-07 17:16:02 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2001-09-07 17:16:02 +0000 |
commit | 2612796329c5732ef459f6cabcb41b4e1ec0443f (patch) | |
tree | 240376cf6f062814d01e451fa3ae3034199762e0 /lib/libc/stdio | |
parent | 76a33d465bde247d40cc0bc242d635b18fed25e8 (diff) | |
download | FreeBSD-src-2612796329c5732ef459f6cabcb41b4e1ec0443f.zip FreeBSD-src-2612796329c5732ef459f6cabcb41b4e1ec0443f.tar.gz |
1) If __SAPP stream is not seekable, remove __SAPP flag on first call instead
of repeating unsuccessful lseek call on each write (original stdio bug).
2) Save errno accross _sseek call in _swrite to not touch it in case write
success (original stdio bug).
3) Add _sseek error checking back, but only for __SOPT mode now.
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r-- | lib/libc/stdio/stdio.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/libc/stdio/stdio.c b/lib/libc/stdio/stdio.c index 96cfcae..4bee608 100644 --- a/lib/libc/stdio/stdio.c +++ b/lib/libc/stdio/stdio.c @@ -126,9 +126,15 @@ _swrite(fp, buf, n) int n; { int ret; + int serrno; - if (fp->_flags & __SAPP) - (void)_sseek(fp, (fpos_t)0, SEEK_END); + if (fp->_flags & __SAPP) { + serrno = errno; + if (_sseek(fp, (fpos_t)0, SEEK_END) == -1 && + (fp->_flags & __SOPT)) + return (-1); + errno = serrno; + } ret = (*fp->_write)(fp->_cookie, buf, n); /* __SOFF removed even on success in case O_APPEND mode is set. */ if (ret >= 0) { @@ -167,7 +173,8 @@ _sseek(fp, offset, whence) if (errret == 0) { fp->_flags |= __SERR; errno = EINVAL; - } + } else if (errret == ESPIPE) + fp->_flags &= ~__SAPP; fp->_flags &= ~__SOFF; ret = -1; } else if (fp->_flags & __SOPT) { |