fdopen.c (178921) | fdopen.c (243731) |
---|---|
1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Chris Torek. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 20 unchanged lines hidden (view full) --- 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#if defined(LIBC_SCCS) && !defined(lint) 34static char sccsid[] = "@(#)fdopen.c 8.1 (Berkeley) 6/4/93"; 35#endif /* LIBC_SCCS and not lint */ 36#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Chris Torek. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 20 unchanged lines hidden (view full) --- 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#if defined(LIBC_SCCS) && !defined(lint) 34static char sccsid[] = "@(#)fdopen.c 8.1 (Berkeley) 6/4/93"; 35#endif /* LIBC_SCCS and not lint */ 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: head/lib/libc/stdio/fdopen.c 178921 2008-05-10 18:39:20Z antoine $"); | 37__FBSDID("$FreeBSD: head/lib/libc/stdio/fdopen.c 243731 2012-11-30 23:51:33Z jilles $"); |
38 39#include "namespace.h" 40#include <sys/types.h> 41#include <fcntl.h> 42#include <unistd.h> 43#include <stdio.h> 44#include <errno.h> 45#include <limits.h> --- 29 unchanged lines hidden (view full) --- 75 tmp = fdflags & O_ACCMODE; 76 if (tmp != O_RDWR && (tmp != (oflags & O_ACCMODE))) { 77 errno = EINVAL; 78 return (NULL); 79 } 80 81 if ((fp = __sfp()) == NULL) 82 return (NULL); | 38 39#include "namespace.h" 40#include <sys/types.h> 41#include <fcntl.h> 42#include <unistd.h> 43#include <stdio.h> 44#include <errno.h> 45#include <limits.h> --- 29 unchanged lines hidden (view full) --- 75 tmp = fdflags & O_ACCMODE; 76 if (tmp != O_RDWR && (tmp != (oflags & O_ACCMODE))) { 77 errno = EINVAL; 78 return (NULL); 79 } 80 81 if ((fp = __sfp()) == NULL) 82 return (NULL); |
83 84 if ((oflags & O_CLOEXEC) && _fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) { 85 fp->_flags = 0; 86 return (NULL); 87 } 88 |
|
83 fp->_flags = flags; 84 /* 85 * If opened for appending, but underlying descriptor does not have 86 * O_APPEND bit set, assert __SAPP so that __swrite() caller 87 * will _sseek() to the end before write. 88 */ 89 if ((oflags & O_APPEND) && !(fdflags & O_APPEND)) 90 fp->_flags |= __SAPP; 91 fp->_file = fd; 92 fp->_cookie = fp; 93 fp->_read = __sread; 94 fp->_write = __swrite; 95 fp->_seek = __sseek; 96 fp->_close = __sclose; 97 return (fp); 98} | 89 fp->_flags = flags; 90 /* 91 * If opened for appending, but underlying descriptor does not have 92 * O_APPEND bit set, assert __SAPP so that __swrite() caller 93 * will _sseek() to the end before write. 94 */ 95 if ((oflags & O_APPEND) && !(fdflags & O_APPEND)) 96 fp->_flags |= __SAPP; 97 fp->_file = fd; 98 fp->_cookie = fp; 99 fp->_read = __sread; 100 fp->_write = __swrite; 101 fp->_seek = __sseek; 102 fp->_close = __sclose; 103 return (fp); 104} |