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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 #include "nacl_io/mount_http.h" 6 #include "nacl_io/mount_http.h"
7 7
8 #include <assert.h> 8 #include <assert.h>
9 #include <ctype.h> 9 #include <ctype.h>
10 #include <errno.h> 10 #include <errno.h>
11 #include <fcntl.h> 11 #include <fcntl.h>
12 #include <stdio.h> 12 #include <stdio.h>
13 #include <string.h> 13 #include <string.h>
14 #include <sys/stat.h> 14 #include <sys/stat.h>
15 #include <sys/types.h> 15 #include <sys/types.h>
16 #include <unistd.h>
16 17
17 #include <vector> 18 #include <vector>
18 19
19 #include <ppapi/c/pp_errors.h> 20 #include <ppapi/c/pp_errors.h>
20 21
21 #include "nacl_io/mount_node_dir.h" 22 #include "nacl_io/mount_node_dir.h"
22 #include "nacl_io/mount_node_http.h" 23 #include "nacl_io/mount_node_http.h"
23 #include "nacl_io/osinttypes.h" 24 #include "nacl_io/osinttypes.h"
24 #include "sdk_util/auto_lock.h" 25 #include "sdk_util/auto_lock.h"
25 26
(...skipping 21 matching lines...) Expand all
47 bool upper = true; 48 bool upper = true;
48 for (size_t i = 0; i < s.length(); ++i) { 49 for (size_t i = 0; i < s.length(); ++i) {
49 char c = s[i]; 50 char c = s[i];
50 result += upper ? toupper(c) : tolower(c); 51 result += upper ? toupper(c) : tolower(c);
51 upper = c == '-'; 52 upper = c == '-';
52 } 53 }
53 54
54 return result; 55 return result;
55 } 56 }
56 57
58 Error MountHttp::Access(const Path& path, int a_mode) {
59 assert(url_root_.empty() || url_root_[url_root_.length() - 1] == '/');
60
61 NodeMap_t::iterator iter = node_cache_.find(path.Join());
62 if (iter == node_cache_.end()) {
63 // If we can't find the node in the cache, fetch it
64 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.
65 (path.IsAbsolute() ? path.Range(1, path.Size())
66 : path.Join());
67
68 MountNodeHttp* node = new MountNodeHttp(this, url, cache_content_);
69 Error error = node->Init(O_RDONLY);
70 if (error) {
71 node->Release();
72 return error;
73 }
74
75 error = node->GetStat(NULL);
76 if (error) {
77 node->Release();
78 return error;
79 }
binji 2013/06/19 16:46:28 release the node here
Matt Giuca 2013/06/20 01:43:14 Done.
80 }
81
82 // Don't allow write or execute access.
83 if (a_mode & (W_OK | X_OK))
84 return EACCES;
85
86 return 0;
87 }
88
57 Error MountHttp::Open(const Path& path, int mode, MountNode** out_node) { 89 Error MountHttp::Open(const Path& path, int mode, MountNode** out_node) {
58 *out_node = NULL; 90 *out_node = NULL;
59 91
60 assert(url_root_.empty() || url_root_[url_root_.length() - 1] == '/'); 92 assert(url_root_.empty() || url_root_[url_root_.length() - 1] == '/');
61 93
62 NodeMap_t::iterator iter = node_cache_.find(path.Join()); 94 NodeMap_t::iterator iter = node_cache_.find(path.Join());
63 if (iter != node_cache_.end()) { 95 if (iter != node_cache_.end()) {
64 *out_node = iter->second; 96 *out_node = iter->second;
65 return 0; 97 return 0;
66 } 98 }
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 manifest_node->Release(); 427 manifest_node->Release();
396 return error; 428 return error;
397 } 429 }
398 430
399 manifest_node->Release(); 431 manifest_node->Release();
400 text[len] = 0; 432 text[len] = 0;
401 433
402 *out_manifest = text; 434 *out_manifest = text;
403 return 0; 435 return 0;
404 } 436 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698