Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: libio/iofdopen.c

Issue 338613003: Disable use of fcntl in fdopen for nacl. (Closed) Base URL: http://git.chromium.org/native_client/nacl-glibc.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (C) 1993,1994,1997,1998,1999,2000,2002,2003 1 /* Copyright (C) 1993,1994,1997,1998,1999,2000,2002,2003
2 Free Software Foundation, Inc. 2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 The GNU C Library is free software; you can redistribute it and/or 5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version. 8 version 2.1 of the License, or (at your option) any later version.
9 9
10 The GNU C Library is distributed in the hope that it will be useful, 10 The GNU C Library is distributed in the hope that it will be useful,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 int read_write; 52 int read_write;
53 int posix_mode = 0; 53 int posix_mode = 0;
54 struct locked_FILE 54 struct locked_FILE
55 { 55 {
56 struct _IO_FILE_plus fp; 56 struct _IO_FILE_plus fp;
57 #ifdef _IO_MTSAFE_IO 57 #ifdef _IO_MTSAFE_IO
58 _IO_lock_t lock; 58 _IO_lock_t lock;
59 #endif 59 #endif
60 struct _IO_wide_data wd; 60 struct _IO_wide_data wd;
61 } *new_f; 61 } *new_f;
62 #if !defined(__native_client__)
62 int fd_flags; 63 int fd_flags;
64 #endif /* !defined(__native_client__) */
63 int i; 65 int i;
64 int use_mmap = 0; 66 int use_mmap = 0;
65 67
66 switch (*mode) 68 switch (*mode)
67 { 69 {
68 case 'r': 70 case 'r':
69 read_write = _IO_NO_WRITES; 71 read_write = _IO_NO_WRITES;
70 break; 72 break;
71 case 'w': 73 case 'w':
72 read_write = _IO_NO_READS; 74 read_write = _IO_NO_READS;
(...skipping 19 matching lines...) Expand all
92 use_mmap = 1; 94 use_mmap = 1;
93 continue; 95 continue;
94 case 'x': 96 case 'x':
95 case 'b': 97 case 'b':
96 default: 98 default:
97 /* Ignore */ 99 /* Ignore */
98 continue; 100 continue;
99 } 101 }
100 break; 102 break;
101 } 103 }
104 /*
105 * Don't attempt to verify fd mode under Native Client,
106 * as fcntl is not implemented.
107 */
108 #if !defined(__native_client__)
102 #ifdef F_GETFL 109 #ifdef F_GETFL
103 fd_flags = _IO_fcntl (fd, F_GETFL); 110 fd_flags = _IO_fcntl (fd, F_GETFL);
104 #ifndef O_ACCMODE 111 #ifndef O_ACCMODE
105 #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) 112 #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
106 #endif 113 #endif
107 if (fd_flags == -1) 114 if (fd_flags == -1)
108 return NULL; 115 return NULL;
109 116
110 if (((fd_flags & O_ACCMODE) == O_RDONLY && !(read_write & _IO_NO_WRITES)) 117 if (((fd_flags & O_ACCMODE) == O_RDONLY && !(read_write & _IO_NO_WRITES))
111 || ((fd_flags & O_ACCMODE) == O_WRONLY && !(read_write & _IO_NO_READS))) 118 || ((fd_flags & O_ACCMODE) == O_WRONLY && !(read_write & _IO_NO_READS)))
(...skipping 19 matching lines...) Expand all
131 likely to break historical programs. 138 likely to break historical programs.
132 */ 139 */
133 if ((posix_mode & O_APPEND) && !(fd_flags & O_APPEND)) 140 if ((posix_mode & O_APPEND) && !(fd_flags & O_APPEND))
134 { 141 {
135 #ifdef F_SETFL 142 #ifdef F_SETFL
136 if (_IO_fcntl (fd, F_SETFL, fd_flags | O_APPEND) == -1) 143 if (_IO_fcntl (fd, F_SETFL, fd_flags | O_APPEND) == -1)
137 #endif 144 #endif
138 return NULL; 145 return NULL;
139 } 146 }
140 #endif 147 #endif
148 #endif /* !defined(__native_client__) */
141 149
142 new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE)); 150 new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE));
143 if (new_f == NULL) 151 if (new_f == NULL)
144 return NULL; 152 return NULL;
145 #ifdef _IO_MTSAFE_IO 153 #ifdef _IO_MTSAFE_IO
146 new_f->fp.file._lock = &new_f->lock; 154 new_f->fp.file._lock = &new_f->lock;
147 #endif 155 #endif
148 /* Set up initially to use the `maybe_mmap' jump tables rather than using 156 /* Set up initially to use the `maybe_mmap' jump tables rather than using
149 __fopen_maybe_mmap to do it, because we need them in place before we 157 __fopen_maybe_mmap to do it, because we need them in place before we
150 call _IO_file_attach or else it will allocate a buffer immediately. */ 158 call _IO_file_attach or else it will allocate a buffer immediately. */
(...skipping 25 matching lines...) Expand all
176 _IO_mask_flags (&new_f->fp.file, read_write, 184 _IO_mask_flags (&new_f->fp.file, read_write,
177 _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING); 185 _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);
178 186
179 return &new_f->fp.file; 187 return &new_f->fp.file;
180 } 188 }
181 INTDEF2(_IO_new_fdopen, _IO_fdopen) 189 INTDEF2(_IO_new_fdopen, _IO_fdopen)
182 190
183 strong_alias (_IO_new_fdopen, __new_fdopen) 191 strong_alias (_IO_new_fdopen, __new_fdopen)
184 versioned_symbol (libc, _IO_new_fdopen, _IO_fdopen, GLIBC_2_1); 192 versioned_symbol (libc, _IO_new_fdopen, _IO_fdopen, GLIBC_2_1);
185 versioned_symbol (libc, __new_fdopen, fdopen, GLIBC_2_1); 193 versioned_symbol (libc, __new_fdopen, fdopen, GLIBC_2_1);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698