* Copyright (c) 1990 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* %sccs.include.redist.c%
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid
[] = "@(#)fdopen.c 5.4 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
int flags
, oflags
, fdflags
, tmp
;
nofile
= getdtablesize();
if ((flags
= __sflags(mode
, &oflags
)) == 0)
/* Make sure the mode the user wants is a subset of the actual mode. */
if ((fdflags
= fcntl(fd
, F_GETFL
, 0)) < 0)
tmp
= fdflags
& O_ACCMODE
;
if (tmp
!= O_RDWR
&& (tmp
!= (oflags
& O_ACCMODE
))) {
if ((fp
= __sfp()) == NULL
)
* If opened for appending, but underlying descriptor does not have
* O_APPEND bit set, assert __SAPP so that __swrite() will lseek to
if ((oflags
& O_APPEND
) && !(fdflags
& O_APPEND
))