Index: native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc |
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc |
index a35e1822110b8874539578f079b5edd46414f13a..6d52cafcab8ec6bb08b2762607e26390432c4468 100644 |
--- a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc |
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc |
@@ -843,20 +843,18 @@ int KernelProxy::fcntl(int fd, int request, va_list args) { |
} |
int KernelProxy::access(const char* path, int amode) { |
- ScopedFilesystem fs; |
- Path rel; |
+ struct stat buf; |
+ int rtn = stat(path, &buf); |
+ if (rtn != 0) |
+ return rtn; |
- Error error = AcquireFsAndRelPath(path, &fs, &rel); |
- if (error) { |
- errno = error; |
+ if (((amode & R_OK) && !(buf.st_mode & S_IREAD)) || |
+ ((amode & W_OK) && !(buf.st_mode & S_IWRITE)) || |
+ ((amode & X_OK) && !(buf.st_mode & S_IEXEC))) { |
+ errno = EACCES; |
return -1; |
} |
- error = fs->Access(rel, amode); |
- if (error) { |
- errno = error; |
- return -1; |
- } |
return 0; |
} |