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

Unified Diff: native_client_sdk/src/libraries/nacl_io/mount_http.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: Fixes, implement httpfs, and write tests. 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_http.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_http.cc b/native_client_sdk/src/libraries/nacl_io/mount_http.cc
index 15c32e623106b3b3132a28038bce3b11652b5b49..5aa06b07b956292a60ec503c371a302fe0af4c6b 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_http.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_http.cc
@@ -13,6 +13,7 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <unistd.h>
#include <vector>
@@ -54,6 +55,37 @@ std::string NormalizeHeaderKey(const std::string& s) {
return result;
}
+Error MountHttp::Access(const Path& path, int a_mode) {
+ assert(url_root_.empty() || url_root_[url_root_.length() - 1] == '/');
+
+ NodeMap_t::iterator iter = node_cache_.find(path.Join());
+ if (iter == node_cache_.end()) {
+ // If we can't find the node in the cache, fetch it
+ std::string url = url_root_ +
binji 2013/06/19 16:46:28 might be nice to refactor this into a MakeURL func
Matt Giuca 2013/06/20 01:43:14 Done.
+ (path.IsAbsolute() ? path.Range(1, path.Size())
+ : path.Join());
+
+ MountNodeHttp* node = new MountNodeHttp(this, url, cache_content_);
+ Error error = node->Init(O_RDONLY);
+ if (error) {
+ node->Release();
+ return error;
+ }
+
+ error = node->GetStat(NULL);
+ if (error) {
+ node->Release();
+ return error;
+ }
binji 2013/06/19 16:46:28 release the node here
Matt Giuca 2013/06/20 01:43:14 Done.
+ }
+
+ // Don't allow write or execute access.
+ if (a_mode & (W_OK | X_OK))
+ return EACCES;
+
+ return 0;
+}
+
Error MountHttp::Open(const Path& path, int mode, MountNode** out_node) {
*out_node = NULL;

Powered by Google App Engine
This is Rietveld 408576698