| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "nacl_io/kernel_proxy.h" | 5 #include "nacl_io/kernel_proxy.h" |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <limits.h> | 10 #include <limits.h> |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 error = handle->VFcntl(request, &rtn, args); | 836 error = handle->VFcntl(request, &rtn, args); |
| 837 if (error) { | 837 if (error) { |
| 838 errno = error; | 838 errno = error; |
| 839 return -1; | 839 return -1; |
| 840 } | 840 } |
| 841 | 841 |
| 842 return rtn; | 842 return rtn; |
| 843 } | 843 } |
| 844 | 844 |
| 845 int KernelProxy::access(const char* path, int amode) { | 845 int KernelProxy::access(const char* path, int amode) { |
| 846 ScopedFilesystem fs; | 846 struct stat buf; |
| 847 Path rel; | 847 int rtn = stat(path, &buf); |
| 848 if (rtn != 0) |
| 849 return rtn; |
| 848 | 850 |
| 849 Error error = AcquireFsAndRelPath(path, &fs, &rel); | 851 if (((amode & R_OK) && !(buf.st_mode & S_IREAD)) || |
| 850 if (error) { | 852 ((amode & W_OK) && !(buf.st_mode & S_IWRITE)) || |
| 851 errno = error; | 853 ((amode & X_OK) && !(buf.st_mode & S_IEXEC))) { |
| 854 errno = EACCES; |
| 852 return -1; | 855 return -1; |
| 853 } | 856 } |
| 854 | 857 |
| 855 error = fs->Access(rel, amode); | |
| 856 if (error) { | |
| 857 errno = error; | |
| 858 return -1; | |
| 859 } | |
| 860 return 0; | 858 return 0; |
| 861 } | 859 } |
| 862 | 860 |
| 863 int KernelProxy::readlink(const char* path, char* buf, size_t count) { | 861 int KernelProxy::readlink(const char* path, char* buf, size_t count) { |
| 864 LOG_TRACE("readlink is not implemented."); | 862 LOG_TRACE("readlink is not implemented."); |
| 865 errno = EINVAL; | 863 errno = EINVAL; |
| 866 return -1; | 864 return -1; |
| 867 } | 865 } |
| 868 | 866 |
| 869 int KernelProxy::utimes(const char* filename, const struct timeval times[2]) { | 867 int KernelProxy::utimes(const char* filename, const struct timeval times[2]) { |
| (...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1719 errno = ENOTSOCK; | 1717 errno = ENOTSOCK; |
| 1720 return -1; | 1718 return -1; |
| 1721 } | 1719 } |
| 1722 | 1720 |
| 1723 return 0; | 1721 return 0; |
| 1724 } | 1722 } |
| 1725 | 1723 |
| 1726 #endif // PROVIDES_SOCKET_API | 1724 #endif // PROVIDES_SOCKET_API |
| 1727 | 1725 |
| 1728 } // namespace_nacl_io | 1726 } // namespace_nacl_io |
| OLD | NEW |