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 | 848 if (rtn != 0) { |
849 Error error = AcquireFsAndRelPath(path, &fs, &rel); | 849 errno = rtn; |
binji
2014/09/08 18:48:26
stat above calls KernelProxy::stat, which already
Sam Clegg
2014/09/09 19:58:30
Done.
| |
850 if (error) { | |
851 errno = error; | |
852 return -1; | 850 return -1; |
853 } | 851 } |
854 | 852 |
855 error = fs->Access(rel, amode); | 853 if (((amode & R_OK) && !(buf.st_mode & S_IREAD)) || |
856 if (error) { | 854 ((amode & W_OK) && !(buf.st_mode & S_IWRITE)) || |
857 errno = error; | 855 ((amode & X_OK) && !(buf.st_mode & S_IEXEC))) { |
856 errno = EACCES; | |
858 return -1; | 857 return -1; |
859 } | 858 } |
859 | |
860 return 0; | 860 return 0; |
861 } | 861 } |
862 | 862 |
863 int KernelProxy::readlink(const char* path, char* buf, size_t count) { | 863 int KernelProxy::readlink(const char* path, char* buf, size_t count) { |
864 LOG_TRACE("readlink is not implemented."); | 864 LOG_TRACE("readlink is not implemented."); |
865 errno = EINVAL; | 865 errno = EINVAL; |
866 return -1; | 866 return -1; |
867 } | 867 } |
868 | 868 |
869 int KernelProxy::utimes(const char* filename, const struct timeval times[2]) { | 869 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; | 1719 errno = ENOTSOCK; |
1720 return -1; | 1720 return -1; |
1721 } | 1721 } |
1722 | 1722 |
1723 return 0; | 1723 return 0; |
1724 } | 1724 } |
1725 | 1725 |
1726 #endif // PROVIDES_SOCKET_API | 1726 #endif // PROVIDES_SOCKET_API |
1727 | 1727 |
1728 } // namespace_nacl_io | 1728 } // namespace_nacl_io |
OLD | NEW |