Mail Archives: cygwin-developers/1998/02/18/17:18:34
A while ago, Sergey, Ian, and I had some back and forth about an
alleged fdopen() bug. Following is the last mail on the subject.
I've appended the latest version of the patch for feedback.
Geoff
Sergey Okhapkin wrote:
>
> Geoffrey Noer wrote:
> > Ian suggests the following:
> >
> > if ((oflags & O_APPEND)
> > #ifdef F_GETFL
> > && !(fdflags & O_APPEND)
> > #endif
> > )
> > fp->_flags |= __SAPP;
> >
> > Look right?
>
> I'm not sure. When O_APPEND is set, we have to seek to end of file on
> fdopen() call. When __SAPP is set, _every_ write call seeks to eof before
> write! Is it a correct behavior for O_APPEND? BTW, where fdflags variable
> is defined?
-------------------------------- patch -----------------------------
Index: fdopen.c
===================================================================
RCS file: /cvs/cvsfiles/devo/newlib/libc/stdio/fdopen.c,v
retrieving revision 1.11
diff -c -p -r1.11 fdopen.c
*** fdopen.c 1993/11/04 01:24:25 1.11
--- fdopen.c 1998/02/19 01:04:06
*************** PORTABILITY
*** 38,43 ****
--- 38,44 ----
*/
#include <sys/types.h>
+ #include <sys/fcntl.h>
#include <stdio.h>
#include <errno.h>
*************** _DEFUN (_fdopen_r, (ptr, fd, mode),
*** 54,59 ****
--- 55,63 ----
{
register FILE *fp;
int flags, oflags;
+ #ifdef F_GETFL
+ int fdflags, fdmode;
+ #endif
if ((flags = __sflags (ptr, mode, &oflags)) == 0)
return 0;
*************** _DEFUN (_fdopen_r, (ptr, fd, mode),
*** 78,86 ****
* does not have O_APPEND bit set, assert __SAPP so that
* __swrite() will lseek to end before each write.
*/
#ifdef F_GETFL
! if ((oflags & O_APPEND) && !(fdflags & O_APPEND))
#endif
fp->_flags |= __SAPP;
fp->_file = fd;
fp->_cookie = (_PTR) fp;
--- 82,92 ----
* does not have O_APPEND bit set, assert __SAPP so that
* __swrite() will lseek to end before each write.
*/
+ if ((oflags & O_APPEND)
#ifdef F_GETFL
! && !(fdflags & O_APPEND)
#endif
+ )
fp->_flags |= __SAPP;
fp->_file = fd;
fp->_cookie = (_PTR) fp;
- Raw text -