OLD | NEW |
---|---|
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 #if defined(WIN32) | 5 #if defined(WIN32) |
6 #define _CRT_RAND_S | 6 #define _CRT_RAND_S |
7 #endif | 7 #endif |
8 | 8 |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <fcntl.h> | 10 #include <fcntl.h> |
11 #include <string.h> | 11 #include <string.h> |
12 #include <unistd.h> | |
12 #include "nacl_io/kernel_wrap_real.h" | 13 #include "nacl_io/kernel_wrap_real.h" |
13 #include "nacl_io/mount_dev.h" | 14 #include "nacl_io/mount_dev.h" |
14 #include "nacl_io/mount_node.h" | 15 #include "nacl_io/mount_node.h" |
15 #include "nacl_io/mount_node_dir.h" | 16 #include "nacl_io/mount_node_dir.h" |
16 #include "nacl_io/pepper_interface.h" | 17 #include "nacl_io/pepper_interface.h" |
17 #include "sdk_util/auto_lock.h" | 18 #include "sdk_util/auto_lock.h" |
18 | 19 |
19 #if defined(__native_client__) | 20 #if defined(__native_client__) |
20 #include <irt.h> | 21 #include <irt.h> |
21 #elif defined(WIN32) | 22 #elif defined(WIN32) |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 Error UrandomNode::Write(size_t offs, | 263 Error UrandomNode::Write(size_t offs, |
263 const void* buf, | 264 const void* buf, |
264 size_t count, | 265 size_t count, |
265 int* out_bytes) { | 266 int* out_bytes) { |
266 *out_bytes = count; | 267 *out_bytes = count; |
267 return 0; | 268 return 0; |
268 } | 269 } |
269 | 270 |
270 } // namespace | 271 } // namespace |
271 | 272 |
273 Error MountDev::Access(const Path& path, int a_mode) { | |
274 MountNode* node = NULL; | |
binji
2013/06/19 16:46:28
probably OK not to, but I would AutoLock the mount
Matt Giuca
2013/06/20 01:43:14
Done.
| |
275 int error = root_->FindChild(path.Join(), &node); | |
276 if (error) | |
277 return error; | |
278 | |
279 // Don't allow execute access. | |
280 if (a_mode & X_OK) | |
281 return EACCES; | |
282 | |
283 return 0; | |
284 } | |
285 | |
272 Error MountDev::Open(const Path& path, int mode, MountNode** out_node) { | 286 Error MountDev::Open(const Path& path, int mode, MountNode** out_node) { |
273 *out_node = NULL; | 287 *out_node = NULL; |
274 | 288 |
275 AutoLock lock(&lock_); | 289 AutoLock lock(&lock_); |
276 | 290 |
277 // Don't allow creating any files. | 291 // Don't allow creating any files. |
278 if (mode & O_CREAT) | 292 if (mode & O_CREAT) |
279 return EINVAL; | 293 return EINVAL; |
280 | 294 |
281 MountNode* node = NULL; | 295 MountNode* node = NULL; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 INITIALIZE_DEV_NODE_1("/stderr", RealNode, 2); | 342 INITIALIZE_DEV_NODE_1("/stderr", RealNode, 2); |
329 | 343 |
330 return 0; | 344 return 0; |
331 } | 345 } |
332 | 346 |
333 void MountDev::Destroy() { | 347 void MountDev::Destroy() { |
334 if (root_) | 348 if (root_) |
335 root_->Release(); | 349 root_->Release(); |
336 root_ = NULL; | 350 root_ = NULL; |
337 } | 351 } |
OLD | NEW |