| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 errno = error; | 202 errno = error; |
| 203 return -1; | 203 return -1; |
| 204 } | 204 } |
| 205 | 205 |
| 206 return AllocateFD(handle, path); | 206 return AllocateFD(handle, path); |
| 207 } | 207 } |
| 208 | 208 |
| 209 int KernelProxy::open(const char* path, int open_flags, mode_t mode) { | 209 int KernelProxy::open(const char* path, int open_flags, mode_t mode) { |
| 210 ScopedFilesystem fs; | 210 ScopedFilesystem fs; |
| 211 ScopedNode node; | 211 ScopedNode node; |
| 212 mode_t mask = ~GetUmask(); | 212 mode_t mask = ~GetUmask() & S_MODEBITS; |
| 213 | 213 |
| 214 Error error = AcquireFsAndNode(path, open_flags, mode & mask, &fs, &node); | 214 Error error = AcquireFsAndNode(path, open_flags, mode & mask, &fs, &node); |
| 215 if (error) { | 215 if (error) { |
| 216 errno = error; | 216 errno = error; |
| 217 return -1; | 217 return -1; |
| 218 } | 218 } |
| 219 | 219 |
| 220 ScopedKernelHandle handle(new KernelHandle(fs, node)); | 220 ScopedKernelHandle handle(new KernelHandle(fs, node)); |
| 221 error = handle->Init(open_flags); | 221 error = handle->Init(open_flags); |
| 222 if (error) { | 222 if (error) { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 int KernelProxy::mkdir(const char* path, mode_t mode) { | 365 int KernelProxy::mkdir(const char* path, mode_t mode) { |
| 366 ScopedFilesystem fs; | 366 ScopedFilesystem fs; |
| 367 Path rel; | 367 Path rel; |
| 368 | 368 |
| 369 Error error = AcquireFsAndRelPath(path, &fs, &rel); | 369 Error error = AcquireFsAndRelPath(path, &fs, &rel); |
| 370 if (error) { | 370 if (error) { |
| 371 errno = error; | 371 errno = error; |
| 372 return -1; | 372 return -1; |
| 373 } | 373 } |
| 374 | 374 |
| 375 error = fs->Mkdir(rel, mode & ~GetUmask()); | 375 mode_t mask = ~GetUmask() & S_MODEBITS; |
| 376 error = fs->Mkdir(rel, mode & mask); |
| 376 if (error) { | 377 if (error) { |
| 377 errno = error; | 378 errno = error; |
| 378 return -1; | 379 return -1; |
| 379 } | 380 } |
| 380 | 381 |
| 381 return 0; | 382 return 0; |
| 382 } | 383 } |
| 383 | 384 |
| 384 int KernelProxy::rmdir(const char* path) { | 385 int KernelProxy::rmdir(const char* path) { |
| 385 ScopedFilesystem fs; | 386 ScopedFilesystem fs; |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 } | 872 } |
| 872 | 873 |
| 873 int KernelProxy::fchmod(int fd, mode_t mode) { | 874 int KernelProxy::fchmod(int fd, mode_t mode) { |
| 874 ScopedKernelHandle handle; | 875 ScopedKernelHandle handle; |
| 875 Error error = AcquireHandle(fd, &handle); | 876 Error error = AcquireHandle(fd, &handle); |
| 876 if (error) { | 877 if (error) { |
| 877 errno = error; | 878 errno = error; |
| 878 return -1; | 879 return -1; |
| 879 } | 880 } |
| 880 | 881 |
| 881 error = handle->node()->Fchmod(mode); | 882 error = handle->node()->Fchmod(mode & S_MODEBITS); |
| 882 if (error) { | 883 if (error) { |
| 883 errno = error; | 884 errno = error; |
| 884 return -1; | 885 return -1; |
| 885 } | 886 } |
| 886 | 887 |
| 887 return 0; | 888 return 0; |
| 888 } | 889 } |
| 889 | 890 |
| 890 int KernelProxy::fcntl(int fd, int request, va_list args) { | 891 int KernelProxy::fcntl(int fd, int request, va_list args) { |
| 891 Error error = 0; | 892 Error error = 0; |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 errno = EINVAL; | 1183 errno = EINVAL; |
| 1183 return -1; | 1184 return -1; |
| 1184 } | 1185 } |
| 1185 | 1186 |
| 1186 // Unknown signum | 1187 // Unknown signum |
| 1187 errno = EINVAL; | 1188 errno = EINVAL; |
| 1188 return -1; | 1189 return -1; |
| 1189 } | 1190 } |
| 1190 | 1191 |
| 1191 mode_t KernelProxy::umask(mode_t mask) { | 1192 mode_t KernelProxy::umask(mode_t mask) { |
| 1192 return SetUmask(mask); | 1193 return SetUmask(mask & S_MODEBITS); |
| 1193 } | 1194 } |
| 1194 | 1195 |
| 1195 #ifdef PROVIDES_SOCKET_API | 1196 #ifdef PROVIDES_SOCKET_API |
| 1196 | 1197 |
| 1197 int KernelProxy::select(int nfds, | 1198 int KernelProxy::select(int nfds, |
| 1198 fd_set* readfds, | 1199 fd_set* readfds, |
| 1199 fd_set* writefds, | 1200 fd_set* writefds, |
| 1200 fd_set* exceptfds, | 1201 fd_set* exceptfds, |
| 1201 struct timeval* timeout) { | 1202 struct timeval* timeout) { |
| 1202 std::vector<pollfd> pollfds; | 1203 std::vector<pollfd> pollfds; |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1817 errno = ENOTSOCK; | 1818 errno = ENOTSOCK; |
| 1818 return -1; | 1819 return -1; |
| 1819 } | 1820 } |
| 1820 | 1821 |
| 1821 return 0; | 1822 return 0; |
| 1822 } | 1823 } |
| 1823 | 1824 |
| 1824 #endif // PROVIDES_SOCKET_API | 1825 #endif // PROVIDES_SOCKET_API |
| 1825 | 1826 |
| 1826 } // namespace_nacl_io | 1827 } // namespace_nacl_io |
| OLD | NEW |