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

Unified Diff: native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc

Issue 565343002: [NaCl SDK] nacl_io: Plumb through {,f}utime{,s} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
Index: native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
index 20d78f21dc653c0bc7d5b7e2024728d09ffd4d9a..cf6cf07cf0517bc3dfd4cf09c2e29ede0b8ccf3d 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
@@ -324,7 +324,7 @@ char* KernelProxy::getwd(char* buf) {
}
int KernelProxy::chmod(const char* path, mode_t mode) {
- int fd = KernelProxy::open(path, O_RDONLY, mode);
+ int fd = open(path, O_RDONLY, mode);
if (-1 == fd)
return -1;
@@ -345,10 +345,6 @@ int KernelProxy::lchown(const char* path, uid_t owner, gid_t group) {
return 0;
}
-int KernelProxy::utime(const char* filename, const struct utimbuf* times) {
- return 0;
-}
-
int KernelProxy::mkdir(const char* path, mode_t mode) {
ScopedFilesystem fs;
Path rel;
@@ -680,6 +676,23 @@ int KernelProxy::ioctl(int fd, int request, va_list args) {
return 0;
}
+int KernelProxy::futimens(int fd, const struct timespec times[2]) {
+ ScopedKernelHandle handle;
+ Error error = AcquireHandle(fd, &handle);
+ if (error) {
+ errno = error;
+ return -1;
+ }
+
+ error = handle->node()->Futimens(times);
+ if (error) {
+ errno = error;
+ return -1;
+ }
+
+ return 0;
+}
+
off_t KernelProxy::lseek(int fd, off_t offset, int whence) {
ScopedKernelHandle handle;
Error error = AcquireHandle(fd, &handle);
@@ -718,7 +731,7 @@ int KernelProxy::unlink(const char* path) {
}
int KernelProxy::truncate(const char* path, off_t len) {
- int fd = KernelProxy::open(path, O_WRONLY, 0);
+ int fd = open(path, O_WRONLY, 0);
if (-1 == fd)
return -1;
@@ -864,10 +877,14 @@ int KernelProxy::readlink(const char* path, char* buf, size_t count) {
return -1;
}
-int KernelProxy::utimes(const char* filename, const struct timeval times[2]) {
- LOG_TRACE("utimes is not implemented.");
- errno = EINVAL;
- return -1;
+int KernelProxy::utimens(const char* path, const struct timespec times[2]) {
+ int fd = open(path, O_RDONLY, 0);
+ if (-1 == fd)
+ return -1;
+
+ int result = futimens(fd, times);
Sam Clegg 2014/09/12 21:36:27 Add explicit KernelProxy:: here to avoid confusion
binji 2014/09/12 21:50:07 We don't do that for open, close, stat, fstat, etc
+ close(fd);
+ return result;
}
// TODO(noelallen): Needs implementation.

Powered by Google App Engine
This is Rietveld 408576698