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

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

Issue 15800004: [NaCl SDK] nacl_io: Added support for access() syscall. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to HEAD. Created 7 years, 6 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/mount_mem.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_mem.cc b/native_client_sdk/src/libraries/nacl_io/mount_mem.cc
index 356600b4ec07b9bc6f2f030266ae2ca1a5514b0f..290b5f8880c67d3c07bc87141b118c4f4fdde16f 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_mem.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_mem.cc
@@ -6,6 +6,8 @@
#include <errno.h>
#include <fcntl.h>
+#include <unistd.h>
+
#include <string>
#include "nacl_io/mount.h"
@@ -76,6 +78,24 @@ Error MountMem::FindNode(const Path& path, int type, MountNode** out_node) {
return 0;
}
+Error MountMem::Access(const Path& path, int a_mode) {
+ AutoLock lock(&lock_);
+ MountNode* node = NULL;
+ Error error = FindNode(path, 0, &node);
+
+ if (error)
+ return error;
+
+ int obj_mode = node->GetMode();
+ if (((a_mode & R_OK) && !(obj_mode & S_IREAD)) ||
+ ((a_mode & W_OK) && !(obj_mode & S_IWRITE)) ||
+ ((a_mode & X_OK) && !(obj_mode & S_IEXEC))) {
+ return EACCES;
+ }
+
+ return 0;
+}
+
Error MountMem::Open(const Path& path, int mode, MountNode** out_node) {
AutoLock lock(&lock_);
MountNode* node = NULL;
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/mount_mem.h ('k') | native_client_sdk/src/libraries/nacl_io/mount_passthrough.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698