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

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

Issue 660353003: [NaCl SDK] nacl_io: Fix utime() on directories. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 89c8e36db7c341a23eb96d91b6443092d7851d67..db6f42baa2a9a82961bba9116b94bb52cfeaa7fe 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
@@ -209,7 +209,7 @@ int KernelProxy::open_resource(const char* path) {
int KernelProxy::open(const char* path, int open_flags, mode_t mode) {
ScopedFilesystem fs;
ScopedNode node;
- mode_t mask = ~GetUmask();
+ mode_t mask = ~GetUmask() & 0777;
Error error = AcquireFsAndNode(path, open_flags, mode & mask, &fs, &node);
if (error) {
@@ -372,7 +372,8 @@ int KernelProxy::mkdir(const char* path, mode_t mode) {
return -1;
}
- error = fs->Mkdir(rel, mode & ~GetUmask());
+ mode_t mask = ~GetUmask() & 0777;
+ error = fs->Mkdir(rel, mode & mask);
if (error) {
errno = error;
return -1;
@@ -792,6 +793,11 @@ int KernelProxy::truncate(const char* path, off_t len) {
return -1;
}
+ // Directories cannot be truncated.
+ if (node->IsaDir()) {
+ return EISDIR;
+ }
+
if (!node->CanOpen(O_WRONLY)) {
errno = EACCES;
return -1;
@@ -873,7 +879,7 @@ int KernelProxy::fchmod(int fd, mode_t mode) {
return -1;
}
- error = handle->node()->Fchmod(mode);
+ error = handle->node()->Fchmod(mode & 0777);
if (error) {
errno = error;
return -1;
@@ -1184,7 +1190,7 @@ int KernelProxy::sigaction(int signum,
}
mode_t KernelProxy::umask(mode_t mask) {
- return SetUmask(mask);
+ return SetUmask(mask & 0777);
}
#ifdef PROVIDES_SOCKET_API

Powered by Google App Engine
This is Rietveld 408576698