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_intercept.h" | 5 #include "nacl_io/kernel_intercept.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
11 #include "nacl_io/kernel_proxy.h" | 11 #include "nacl_io/kernel_proxy.h" |
12 #include "nacl_io/kernel_wrap.h" | 12 #include "nacl_io/kernel_wrap.h" |
13 #include "nacl_io/kernel_wrap_real.h" | 13 #include "nacl_io/kernel_wrap_real.h" |
14 #include "nacl_io/log.h" | 14 #include "nacl_io/log.h" |
15 #include "nacl_io/osmman.h" | 15 #include "nacl_io/osmman.h" |
16 #include "nacl_io/ossocket.h" | 16 #include "nacl_io/ossocket.h" |
| 17 #include "nacl_io/ostime.h" |
17 #include "nacl_io/pepper_interface.h" | 18 #include "nacl_io/pepper_interface.h" |
18 #include "nacl_io/real_pepper_interface.h" | 19 #include "nacl_io/real_pepper_interface.h" |
19 | 20 |
20 using namespace nacl_io; | 21 using namespace nacl_io; |
21 | 22 |
22 #define ON_NOSYS_RETURN(x) \ | 23 #define ON_NOSYS_RETURN(x) \ |
23 if (!ki_is_initialized()) { \ | 24 if (!ki_is_initialized()) { \ |
24 errno = ENOSYS; \ | 25 errno = ENOSYS; \ |
25 return x; \ | 26 return x; \ |
26 } | 27 } |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 return s_state.kp->access(path, amode); | 322 return s_state.kp->access(path, amode); |
322 } | 323 } |
323 | 324 |
324 int ki_readlink(const char* path, char* buf, size_t count) { | 325 int ki_readlink(const char* path, char* buf, size_t count) { |
325 ON_NOSYS_RETURN(-1); | 326 ON_NOSYS_RETURN(-1); |
326 return s_state.kp->readlink(path, buf, count); | 327 return s_state.kp->readlink(path, buf, count); |
327 } | 328 } |
328 | 329 |
329 int ki_utimes(const char* path, const struct timeval times[2]) { | 330 int ki_utimes(const char* path, const struct timeval times[2]) { |
330 ON_NOSYS_RETURN(-1); | 331 ON_NOSYS_RETURN(-1); |
331 return s_state.kp->utimes(path, times); | 332 // Implement in terms of utimens. |
| 333 struct timespec ts[2]; |
| 334 ts[0].tv_sec = times[0].tv_sec; |
| 335 ts[0].tv_nsec = times[0].tv_usec * 1000; |
| 336 ts[1].tv_sec = times[1].tv_sec; |
| 337 ts[1].tv_nsec = times[1].tv_usec * 1000; |
| 338 return s_state.kp->utimens(path, ts); |
| 339 } |
| 340 |
| 341 int ki_futimes(int fd, const struct timeval times[2]) { |
| 342 ON_NOSYS_RETURN(-1); |
| 343 // Implement in terms of futimens. |
| 344 struct timespec ts[2]; |
| 345 ts[0].tv_sec = times[0].tv_sec; |
| 346 ts[0].tv_nsec = times[0].tv_usec * 1000; |
| 347 ts[1].tv_sec = times[1].tv_sec; |
| 348 ts[1].tv_nsec = times[1].tv_usec * 1000; |
| 349 return s_state.kp->futimens(fd, ts); |
332 } | 350 } |
333 | 351 |
334 void* ki_mmap(void* addr, | 352 void* ki_mmap(void* addr, |
335 size_t length, | 353 size_t length, |
336 int prot, | 354 int prot, |
337 int flags, | 355 int flags, |
338 int fd, | 356 int fd, |
339 off_t offset) { | 357 off_t offset) { |
340 ON_NOSYS_RETURN(MAP_FAILED); | 358 ON_NOSYS_RETURN(MAP_FAILED); |
341 return s_state.kp->mmap(addr, length, prot, flags, fd, offset); | 359 return s_state.kp->mmap(addr, length, prot, flags, fd, offset); |
(...skipping 29 matching lines...) Expand all Loading... |
371 return s_state.kp->fchown(fd, owner, group); | 389 return s_state.kp->fchown(fd, owner, group); |
372 } | 390 } |
373 | 391 |
374 int ki_lchown(const char* path, uid_t owner, gid_t group) { | 392 int ki_lchown(const char* path, uid_t owner, gid_t group) { |
375 ON_NOSYS_RETURN(-1); | 393 ON_NOSYS_RETURN(-1); |
376 return s_state.kp->lchown(path, owner, group); | 394 return s_state.kp->lchown(path, owner, group); |
377 } | 395 } |
378 | 396 |
379 int ki_utime(const char* filename, const struct utimbuf* times) { | 397 int ki_utime(const char* filename, const struct utimbuf* times) { |
380 ON_NOSYS_RETURN(-1); | 398 ON_NOSYS_RETURN(-1); |
381 return s_state.kp->utime(filename, times); | 399 // Implement in terms of utimens. |
| 400 struct timespec ts[2]; |
| 401 ts[0].tv_sec = times->actime; |
| 402 ts[0].tv_nsec = 0; |
| 403 ts[1].tv_sec = times->modtime; |
| 404 ts[1].tv_nsec = 0; |
| 405 return s_state.kp->utimens(filename, ts); |
| 406 } |
| 407 |
| 408 int ki_futimens(int fd, const struct timespec times[2]) { |
| 409 ON_NOSYS_RETURN(-1); |
| 410 return s_state.kp->futimens(fd, times); |
382 } | 411 } |
383 | 412 |
384 int ki_poll(struct pollfd* fds, nfds_t nfds, int timeout) { | 413 int ki_poll(struct pollfd* fds, nfds_t nfds, int timeout) { |
385 return s_state.kp->poll(fds, nfds, timeout); | 414 return s_state.kp->poll(fds, nfds, timeout); |
386 } | 415 } |
387 | 416 |
388 int ki_select(int nfds, | 417 int ki_select(int nfds, |
389 fd_set* readfds, | 418 fd_set* readfds, |
390 fd_set* writefds, | 419 fd_set* writefds, |
391 fd_set* exceptfds, | 420 fd_set* exceptfds, |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 int ki_socket(int domain, int type, int protocol) { | 612 int ki_socket(int domain, int type, int protocol) { |
584 ON_NOSYS_RETURN(-1); | 613 ON_NOSYS_RETURN(-1); |
585 return s_state.kp->socket(domain, type, protocol); | 614 return s_state.kp->socket(domain, type, protocol); |
586 } | 615 } |
587 | 616 |
588 int ki_socketpair(int domain, int type, int protocol, int* sv) { | 617 int ki_socketpair(int domain, int type, int protocol, int* sv) { |
589 ON_NOSYS_RETURN(-1); | 618 ON_NOSYS_RETURN(-1); |
590 return s_state.kp->socketpair(domain, type, protocol, sv); | 619 return s_state.kp->socketpair(domain, type, protocol, sv); |
591 } | 620 } |
592 #endif // PROVIDES_SOCKET_API | 621 #endif // PROVIDES_SOCKET_API |
OLD | NEW |