Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / libraries / nacl_io / kernel_wrap_glibc.cc
index 5e43c6c..ed2ab0c 100644 (file)
@@ -157,7 +157,17 @@ EXTERN_C_BEGIN
   OP(getsockopt);                        \
   OP(setsockopt);                        \
   OP(socketpair);                        \
-  OP(shutdown);
+  OP(shutdown);                          \
+                                         \
+  OP(access);                            \
+  OP(unlink);                            \
+  OP(fchdir);                            \
+  OP(fchmod);                            \
+  OP(fsync);                             \
+  OP(fdatasync);                         \
+  OP(lstat);                             \
+  OP(readlink);                          \
+  OP(utimes);
 
 // TODO(bradnelson): Add these as well.
 // OP(epoll_create);
@@ -166,18 +176,15 @@ EXTERN_C_BEGIN
 // OP(epoll_pwait);
 // OP(ppoll);
 // OP(pselect);
-//
 
 EXPAND_SYMBOL_LIST_OPERATION(DECLARE_REAL_PTR);
 
 int WRAP(chdir)(const char* pathname) {
-  RTN_ERRNO_IF(ki_chdir(pathname) < 0);
-  return 0;
+  ERRNO_RTN(ki_chdir(pathname));
 }
 
 int WRAP(close)(int fd) {
-  RTN_ERRNO_IF(ki_close(fd) < 0);
-  return 0;
+  ERRNO_RTN(ki_close(fd));
 }
 
 int WRAP(dup)(int fd, int* newfd) NOTHROW {
@@ -187,8 +194,7 @@ int WRAP(dup)(int fd, int* newfd) NOTHROW {
 }
 
 int WRAP(dup2)(int fd, int newfd) NOTHROW {
-  RTN_ERRNO_IF(ki_dup2(fd, newfd) < 0);
-  return 0;
+  ERRNO_RTN(ki_dup2(fd, newfd));
 }
 
 void WRAP(exit)(int status) {
@@ -320,6 +326,53 @@ int WRAP(stat)(const char* pathname, struct nacl_abi_stat* nacl_buf) {
   return 0;
 }
 
+int WRAP(lstat)(const char* pathname, struct nacl_abi_stat* nacl_buf) {
+  struct stat buf;
+  memset(&buf, 0, sizeof(struct stat));
+  int res = ki_lstat(pathname, &buf);
+  RTN_ERRNO_IF(res < 0);
+  stat_to_nacl_stat(&buf, nacl_buf);
+  return 0;
+}
+
+int WRAP(readlink)(const char* pathname,
+                   char* buf,
+                   size_t count,
+                   size_t* nread) {
+  int rtn = ki_readlink(pathname, buf, count);
+  RTN_ERRNO_IF(rtn < 0);
+  *nread = rtn;
+  return 0;
+}
+
+int WRAP(utimes)(const char *filename, const struct timeval *times) {
+  ERRNO_RTN(ki_utimes(filename, times));
+}
+
+int WRAP(access)(const char* pathname, int amode) {
+  ERRNO_RTN(ki_access(pathname, amode));
+}
+
+int WRAP(unlink)(const char* pathname) {
+  ERRNO_RTN(ki_unlink(pathname));
+}
+
+int WRAP(fchdir)(int fd) {
+  ERRNO_RTN(ki_fchdir(fd));
+}
+
+int WRAP(fchmod)(int fd, mode_t mode) {
+  ERRNO_RTN(ki_fchmod(fd, mode));
+}
+
+int WRAP(fsync)(int fd) {
+  ERRNO_RTN(ki_fsync(fd));
+}
+
+int WRAP(fdatasync)(int fd) {
+  ERRNO_RTN(ki_fdatasync(fd));
+}
+
 int WRAP(write)(int fd, const void* buf, size_t count, size_t* nwrote) {
   ssize_t signed_nwrote = ki_write(fd, buf, count);
   *nwrote = static_cast<size_t>(signed_nwrote);
@@ -337,23 +390,19 @@ int WRAP(accept)(int sockfd,
 }
 
 int WRAP(bind)(int sockfd, const struct sockaddr* addr, socklen_t addrlen) {
-  RTN_ERRNO_IF(ki_bind(sockfd, addr, addrlen) < 0);
-  return 0;
+  ERRNO_RTN(ki_bind(sockfd, addr, addrlen));
 }
 
 int WRAP(connect)(int sockfd, const struct sockaddr* addr, socklen_t addrlen) {
-  RTN_ERRNO_IF(ki_connect(sockfd, addr, addrlen) < 0);
-  return 0;
+  ERRNO_RTN(ki_connect(sockfd, addr, addrlen));
 }
 
 int WRAP(getpeername)(int sockfd, struct sockaddr* addr, socklen_t* addrlen) {
-  RTN_ERRNO_IF(ki_getpeername(sockfd, addr, addrlen) < 0);
-  return 0;
+  ERRNO_RTN(ki_getpeername(sockfd, addr, addrlen));
 }
 
 int WRAP(getsockname)(int sockfd, struct sockaddr* addr, socklen_t* addrlen) {
-  RTN_ERRNO_IF(ki_getsockname(sockfd, addr, addrlen) < 0);
-  return 0;
+  ERRNO_RTN(ki_getsockname(sockfd, addr, addrlen));
 }
 
 int WRAP(getsockopt)(int sockfd,
@@ -361,8 +410,7 @@ int WRAP(getsockopt)(int sockfd,
                      int optname,
                      void* optval,
                      socklen_t* optlen) {
-  RTN_ERRNO_IF(ki_getsockopt(sockfd, level, optname, optval, optlen) < 0);
-  return 0;
+  ERRNO_RTN(ki_getsockopt(sockfd, level, optname, optval, optlen));
 }
 
 int WRAP(setsockopt)(int sockfd,
@@ -370,13 +418,11 @@ int WRAP(setsockopt)(int sockfd,
                      int optname,
                      const void* optval,
                      socklen_t optlen) {
-  RTN_ERRNO_IF(ki_setsockopt(sockfd, level, optname, optval, optlen) < 0);
-  return 0;
+  ERRNO_RTN(ki_setsockopt(sockfd, level, optname, optval, optlen));
 }
 
 int WRAP(listen)(int sockfd, int backlog) {
-  RTN_ERRNO_IF(ki_listen(sockfd, backlog) < 0);
-  return 0;
+  ERRNO_RTN(ki_listen(sockfd, backlog));
 }
 
 int WRAP(recv)(int sockfd, void* buf, size_t len, int flags, int* count) {