Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / libraries / nacl_io / kernel_wrap_bionic.cc
index 2754beb..621e0bd 100644 (file)
@@ -264,8 +264,8 @@ int WRAP(munmap)(void* addr, size_t length) {
   return REAL(munmap)(addr, length);
 }
 
-int WRAP(open)(const char* pathname, int oflag, mode_t cmode, int* newfd) {
-  *newfd = ki_open(pathname, oflag);
+int WRAP(open)(const char* pathname, int oflag, mode_t mode, int* newfd) {
+  *newfd = ki_open(pathname, oflag, mode);
   ERRNO_RTN(*newfd);
 }
 
@@ -338,8 +338,11 @@ static void assign_real_pointers() {
 }
 
 #define CHECK_REAL(func) \
-  if (!REAL(func))       \
-    assign_real_pointers();
+  if (!REAL(func)) {          \
+    assign_real_pointers();   \
+    if (!REAL(func))          \
+      return ENOSYS;          \
+  }
 
 // "real" functions, i.e. the unwrapped original functions.
 
@@ -431,7 +434,7 @@ int _real_lseek(int fd, int64_t offset, int whence, int64_t* new_offset) {
 
 int _real_lstat(const char* path, struct stat* buf) {
   struct nacl_abi_stat st;
-  CHECK_REAL(fstat);
+  CHECK_REAL(lstat);
 
   int err = REAL(lstat)(path, (struct stat*)&st);
   if (err) {
@@ -463,9 +466,9 @@ int _real_munmap(void* addr, size_t length) {
   return REAL(munmap)(addr, length);
 }
 
-int _real_open(const char* pathname, int oflag, mode_t cmode, int* newfd) {
+int _real_open(const char* pathname, int oflag, mode_t mode, int* newfd) {
   CHECK_REAL(open);
-  return REAL(open)(pathname, oflag, cmode, newfd);
+  return REAL(open)(pathname, oflag, mode, newfd);
 }
 
 int _real_open_resource(const char* file, int* fd) {
@@ -498,7 +501,13 @@ int _real_write(int fd, const void* buf, size_t count, size_t* nwrote) {
   return REAL(write)(fd, buf, count, nwrote);
 }
 
+int _real_getcwd(char* pathname, size_t len) {
+  CHECK_REAL(getcwd);
+  return REAL(getcwd)(pathname, len);
+}
+
 static bool s_wrapped = false;
+
 void kernel_wrap_init() {
   if (!s_wrapped) {
     assign_real_pointers();
@@ -516,4 +525,4 @@ void kernel_wrap_uninit() {
 
 EXTERN_C_END
 
-#endif  // defined(__native_client__) && defined(__GLIBC__)
+#endif  // defined(__native_client__) && defined(__BIONIC__)