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. */
12 #if defined(__native_client__) && defined(__GLIBC__)
14 static ssize_t fdopen_read(void *cookie, char *buf, size_t size) {
15 return read((int) cookie, buf, size);
18 static ssize_t fdopen_write(void *cookie, const char *buf, size_t size) {
19 return write((int) cookie, buf, size);
22 static int fdopen_seek(void *cookie, off_t *offset, int whence) {
23 off_t ret = lseek((int) cookie, *offset, whence);
31 static int fdopen_close(void *cookie) {
32 return close((int) cookie);
35 static cookie_io_functions_t fdopen_functions = {
43 * TODO(bradnelson): Remove this glibc is fixed.
44 * See: https://code.google.com/p/nativeclient/issues/detail?id=3362
45 * Workaround fdopen in glibc failing due to it vetting the provided file
46 * handles with fcntl which is not currently interceptable.
48 FILE *fdopen(int fildes, const char *mode) {
49 return fopencookie((void *) fildes, mode, fdopen_functions);
52 #endif /* defined(__native_client__) && defined(__GLIBC__) */