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; |
| 275 |
| 276 AutoLock lock(&lock_); |
| 277 |
| 278 int error = root_->FindChild(path.Join(), &node); |
| 279 if (error) |
| 280 return error; |
| 281 |
| 282 // Don't allow execute access. |
| 283 if (a_mode & X_OK) |
| 284 return EACCES; |
| 285 |
| 286 return 0; |
| 287 } |
| 288 |
272 Error MountDev::Open(const Path& path, int mode, MountNode** out_node) { | 289 Error MountDev::Open(const Path& path, int mode, MountNode** out_node) { |
273 *out_node = NULL; | 290 *out_node = NULL; |
274 | 291 |
275 AutoLock lock(&lock_); | 292 AutoLock lock(&lock_); |
276 | 293 |
277 // Don't allow creating any files. | 294 // Don't allow creating any files. |
278 if (mode & O_CREAT) | 295 if (mode & O_CREAT) |
279 return EINVAL; | 296 return EINVAL; |
280 | 297 |
281 MountNode* node = NULL; | 298 MountNode* node = NULL; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 INITIALIZE_DEV_NODE_1("/stderr", RealNode, 2); | 345 INITIALIZE_DEV_NODE_1("/stderr", RealNode, 2); |
329 | 346 |
330 return 0; | 347 return 0; |
331 } | 348 } |
332 | 349 |
333 void MountDev::Destroy() { | 350 void MountDev::Destroy() { |
334 if (root_) | 351 if (root_) |
335 root_->Release(); | 352 root_->Release(); |
336 root_ = NULL; | 353 root_ = NULL; |
337 } | 354 } |
OLD | NEW |