1 /* Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. */
10 #if defined(__native_client__) && defined(__GLIBC__)
12 static ssize_t fdopen_read(void *cookie, char *buf, size_t size) {
13 return read((int) cookie, buf, size);
16 static ssize_t fdopen_write(void *cookie, const char *buf, size_t size) {
17 return write((int) cookie, buf, size);
20 static int fdopen_seek(void *cookie, off_t *offset, int whence) {
21 off_t ret = lseek((int) cookie, *offset, whence);
29 static int fdopen_close(void *cookie) {
30 return close((int) cookie);
33 static cookie_io_functions_t fdopen_functions = {
41 * TODO(bradnelson): Remove this glibc is fixed.
42 * See: https://code.google.com/p/nativeclient/issues/detail?id=3362
43 * Workaround fdopen in glibc failing due to it vetting the provided file
44 * handles with fcntl which is not currently interceptable.
46 FILE *fdopen(int fildes, const char *mode) {
47 return fopencookie((void *) fildes, mode, fdopen_functions);
50 #endif /* defined(__native_client__) && defined(__GLIBC__) */