root/native_client_sdk/src/libraries/nacl_io/kernel_wrap_dummy.cc

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. _real_close
  2. _real_fstat
  3. _real_getdents
  4. _real_lseek
  5. _real_mkdir
  6. _real_mmap
  7. _real_munmap
  8. _real_open
  9. _real_open_resource
  10. _real_read
  11. _real_rmdir
  12. _real_write
  13. kernel_wrap_init
  14. kernel_wrap_uninit

// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// The Chromium build system defines __linux__ even for native client builds,
// so guard against __native_client__ being defined as well.
#if defined(WIN32) || (defined(__linux__) && !defined(__native_client__))

#include <errno.h>

#include "nacl_io/kernel_wrap.h"
#include "nacl_io/kernel_wrap_real.h"

// "real" functions, i.e. the unwrapped original functions. For Windows/Linux
// host builds we don't wrap, so the real functions aren't accessible. In most
// cases, we just fail.

int _real_close(int fd) {
  return ENOSYS;
}

int _real_fstat(int fd, struct stat *buf) {
  return 0;
}

int _real_getdents(int fd, void* nacl_buf, size_t nacl_count, size_t *nread) {
  return ENOSYS;
}

int _real_lseek(int fd, off_t offset, int whence, off_t* new_offset) {
  return ENOSYS;
}

int _real_mkdir(const char* pathname, mode_t mode) {
  return ENOSYS;
}

int _real_mmap(void** addr, size_t length, int prot, int flags, int fd,
               off_t offset) {
  return ENOSYS;
}

int _real_munmap(void* addr, size_t length) {
  return ENOSYS;
}

int _real_open(const char* pathname, int oflag, mode_t cmode, int* newfd) {
  return ENOSYS;
}

int _real_open_resource(const char* file, int* fd) {
  return ENOSYS;
}

int _real_read(int fd, void *buf, size_t count, size_t *nread) {
  *nread = count;
  return 0;
}

int _real_rmdir(const char* pathname) {
  return ENOSYS;
}

int _real_write(int fd, const void *buf, size_t count, size_t *nwrote) {
  int rtn = write(fd, buf, count);
  if (rtn < 0)
    return -1;

  *nwrote = rtn;
  return 0;
}

#endif

// The Chromium build system defines __linux__ even for native client builds,
// so guard against __native_client__ being defined as well.
#if defined(__linux__) && !defined(__native_client__)

void kernel_wrap_init() {
}

void kernel_wrap_uninit() {
}

#endif

/* [<][>][^][v][top][bottom][index][help] */