| 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 4a051ff3441793bc4c60edb8ed1280e41e690925..b924dcf86633c6919ea4826fc1c8668f25ebe41c 100644
|
| --- a/src/shared/platform/posix/nacl_host_desc.c
|
| +++ b/src/shared/platform/posix/nacl_host_desc.c
|
| @@ -14,6 +14,7 @@
|
| */
|
|
|
| #include <stdint.h>
|
| +#include <stdio.h>
|
| #include <sys/types.h>
|
| #include <sys/stat.h>
|
| #include <fcntl.h>
|
| @@ -559,3 +560,142 @@ int NaClHostDescUnlink(const char *path) {
|
| return -errno;
|
| return 0;
|
| }
|
| +
|
| +int NaClHostDescTruncate(const char *path, nacl_off64_t length) {
|
| +#if NACL_LINUX
|
| + if (-1 == truncate64(path, length)) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| +#elif NACL_OSX
|
| + if (-1 == truncate(path, length)) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| +#else
|
| +# error Unsupported platform
|
| +#endif
|
| + return 0;
|
| +}
|
| +
|
| +int NaClHostDescLstat(char const *host_os_pathname, nacl_host_stat_t *nhsp) {
|
| +#if NACL_LINUX
|
| + if (-1 == lstat64(host_os_pathname, nhsp)) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| +#elif NACL_OSX
|
| + if (-1 == lstat(host_os_pathname, nhsp)) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| +#else
|
| +# error Unsupported platform
|
| +#endif
|
| + return 0;
|
| +}
|
| +
|
| +int NaClHostDescLink(const char *oldpath, const char *newpath) {
|
| + if (-1 == link(oldpath, newpath)) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| +int NaClHostDescChmod(const char *path, int mode) {
|
| + if (-1 == chmod(path, mode)) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| +int NaClHostDescAccess(const char *pathname, int mode) {
|
| + if (-1 == access(pathname, mode)) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| +int NaClHostDescRename(const char *oldpath, const char *newpath) {
|
| + if (-1 == rename(oldpath, newpath)) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| +int NaClHostDescReadlink(const char *path, char *buf, size_t bufsiz) {
|
| + if (-1 == readlink(path, buf, bufsiz)) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| +int NaClHostDescSymlink(const char *oldpath, const char *newpath) {
|
| + if (-1 == symlink(oldpath, newpath)) {
|
| + return -NaClXlateErrno(errno);
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| +int NaClHostDescUtimes(const char *filename,
|
| + const struct nacl_abi_timeval times[2]) {
|
| + struct timeval host_times[2] = {
|
| + {
|
| + .tv_sec = times[0].nacl_abi_tv_sec,
|
| + .tv_usec = times[0].nacl_abi_tv_usec
|
| + },
|
| + {
|
| + .tv_sec = times[1].nacl_abi_tv_sec,
|
| + .tv_usec = times[1].nacl_abi_tv_usec
|
| + },
|
| + };
|
| +
|
| + if (-1 == utimes(filename, host_times)) {
|
| + 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, int 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;
|
| +}
|
|
|