thr_open.c (13546) | thr_open.c (17706) |
---|---|
1/* 2 * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 */ 33#include <stdarg.h> | 1/* 2 * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 */ 33#include <stdarg.h> |
34#include <unistd.h> |
|
34#include <fcntl.h> 35#include <dirent.h> 36#ifdef _THREAD_SAFE 37#include <pthread.h> 38#include "pthread_private.h" 39 40int 41open(const char *path, int flags,...) --- 8 unchanged lines hidden (view full) --- 50 51 /* Check if the file is being created: */ 52 if (flags & O_CREAT) { 53 /* Get the creation mode: */ 54 va_start(ap, flags); 55 mode = va_arg(ap, int); 56 va_end(ap); 57 } | 35#include <fcntl.h> 36#include <dirent.h> 37#ifdef _THREAD_SAFE 38#include <pthread.h> 39#include "pthread_private.h" 40 41int 42open(const char *path, int flags,...) --- 8 unchanged lines hidden (view full) --- 51 52 /* Check if the file is being created: */ 53 if (flags & O_CREAT) { 54 /* Get the creation mode: */ 55 va_start(ap, flags); 56 mode = va_arg(ap, int); 57 va_end(ap); 58 } |
58 /* Open the file, forcing it to use non-blocking I/O operations: */ 59 if ((fd = _thread_sys_open(path, flags | O_NONBLOCK, mode)) < 0) { | 59 /* Open the file: */ 60 if ((fd = _thread_sys_open(path, flags, mode)) < 0) { |
60 } 61 /* Initialise the file descriptor table entry: */ 62 else if (_thread_fd_table_init(fd) != 0) { 63 /* Quietly close the file: */ 64 _thread_sys_close(fd); 65 66 /* Reset the file descriptor: */ 67 fd = -1; | 61 } 62 /* Initialise the file descriptor table entry: */ 63 else if (_thread_fd_table_init(fd) != 0) { 64 /* Quietly close the file: */ 65 _thread_sys_close(fd); 66 67 /* Reset the file descriptor: */ 68 fd = -1; |
68 } else { 69 /* 70 * Save the file open flags so that they can be checked 71 * later: 72 */ 73 _thread_fd_table[fd]->flags = flags; | |
74 } 75 76 /* Unblock signals: */ 77 _thread_kern_sig_unblock(status); 78 79 /* Return the file descriptor or -1 on error: */ 80 return (fd); 81} 82#endif | 69 } 70 71 /* Unblock signals: */ 72 _thread_kern_sig_unblock(status); 73 74 /* Return the file descriptor or -1 on error: */ 75 return (fd); 76} 77#endif |