Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(509)

Unified Diff: src/shared/platform/posix/nacl_host_desc.c

Issue 24889002: Provides some of the missing POSIX file syscalls Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/shared/platform/osx/nacl_host_dir.c ('k') | src/shared/platform/win/nacl_host_desc.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+}
« no previous file with comments | « src/shared/platform/osx/nacl_host_dir.c ('k') | src/shared/platform/win/nacl_host_desc.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698