| Index: src/shared/platform/posix/nacl_host_desc.c
|
| diff --git a/src/shared/platform/posix/nacl_host_desc.c b/src/shared/platform/posix/nacl_host_desc.c
|
| index 26728ccc012a1f160a9f4284a59f8ab4e02c3ab2..feccc125075c314e326d148893d8a261eb2d16e9 100644
|
| --- a/src/shared/platform/posix/nacl_host_desc.c
|
| +++ b/src/shared/platform/posix/nacl_host_desc.c
|
| @@ -21,6 +21,7 @@
|
| #include <errno.h>
|
| #include <sys/mman.h>
|
| #include <unistd.h>
|
| +#include <utime.h>
|
|
|
| #include "native_client/src/include/build_config.h"
|
|
|
| @@ -719,3 +720,66 @@ int NaClHostDescReadlink(const char *path, char *buf, size_t bufsize) {
|
| return -NaClXlateErrno(errno);
|
| return retval;
|
| }
|
| +
|
| +int NaClHostDescUtimes(const char *filename,
|
| + const struct nacl_abi_timeval times[2]) {
|
| + struct timeval host_times[2];
|
| + if (times != NULL) {
|
| + host_times[0].tv_sec = times[0].nacl_abi_tv_sec;
|
| + host_times[0].tv_usec = times[0].nacl_abi_tv_usec;
|
| + host_times[1].tv_sec = times[1].nacl_abi_tv_sec;
|
| + host_times[1].tv_usec = times[1].nacl_abi_tv_usec;
|
| + }
|
| + if (-1 == utimes(filename, (times != NULL ? host_times : NULL))) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| +int NaClHostDescFchdir(struct NaClHostDesc *d) {
|
| + NaClHostDescCheckValidity("NaClHostDescFchdir", d);
|
| + if (-1 == fchdir(d->d)) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| +int NaClHostDescFchmod(struct NaClHostDesc *d, nacl_abi_mode_t mode) {
|
| + NaClHostDescCheckValidity("NaClHostDescFchmod", d);
|
| + if (-1 == fchmod(d->d, mode)) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| +int NaClHostDescFsync(struct NaClHostDesc *d) {
|
| + NaClHostDescCheckValidity("NaClHostDescFsync", d);
|
| + if (-1 == fsync(d->d)) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| +int NaClHostDescFdatasync(struct NaClHostDesc *d) {
|
| + NaClHostDescCheckValidity("NaClHostDescFdatasync", d);
|
| + if (-1 == fdatasync(d->d)) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| +int NaClHostDescFtruncate(struct NaClHostDesc *d, nacl_off64_t length) {
|
| + NaClHostDescCheckValidity("NaClHostDescFtruncate", d);
|
| +#if NACL_LINUX
|
| + if (-1 == ftruncate64(d->d, length)) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| +#elif NACL_OSX
|
| + if (-1 == ftruncate(d->d, length)) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| +#else
|
| +# error Unsupported platform
|
| +#endif
|
| + return 0;
|
| +}
|
|
|