Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / libraries / nacl_io / passthroughfs / passthrough_fs.cc
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "nacl_io/passthroughfs/passthrough_fs.h"
6
7 #include <errno.h>
8
9 #include "nacl_io/kernel_handle.h"
10 #include "nacl_io/kernel_wrap_real.h"
11 #include "nacl_io/passthroughfs/real_node.h"
12
13 namespace nacl_io {
14
15 PassthroughFs::PassthroughFs() {
16 }
17
18 Error PassthroughFs::Init(const FsInitArgs& args) {
19   return Filesystem::Init(args);
20 }
21
22 void PassthroughFs::Destroy() {
23 }
24
25 Error PassthroughFs::Access(const Path& path, int a_mode) {
26   // There is no underlying 'access' syscall in NaCl. It just returns ENOSYS.
27   return ENOSYS;
28 }
29
30 Error PassthroughFs::Open(const Path& path, int mode, ScopedNode* out_node) {
31   out_node->reset(NULL);
32   int real_fd;
33   int error = _real_open(path.Join().c_str(), mode, 0666, &real_fd);
34   if (error)
35     return error;
36
37   out_node->reset(new RealNode(this, real_fd, true));
38   return 0;
39 }
40
41 Error PassthroughFs::OpenResource(const Path& path, ScopedNode* out_node) {
42   int real_fd;
43   out_node->reset(NULL);
44   int error = _real_open_resource(path.Join().c_str(), &real_fd);
45   if (error)
46     return error;
47
48   out_node->reset(new RealNode(this, real_fd));
49   return 0;
50 }
51
52 Error PassthroughFs::Unlink(const Path& path) {
53   // Not implemented by NaCl.
54   return ENOSYS;
55 }
56
57 Error PassthroughFs::Mkdir(const Path& path, int perm) {
58   return _real_mkdir(path.Join().c_str(), perm);
59 }
60
61 Error PassthroughFs::Rmdir(const Path& path) {
62   return _real_rmdir(path.Join().c_str());
63 }
64
65 Error PassthroughFs::Remove(const Path& path) {
66   // Not implemented by NaCl.
67   return ENOSYS;
68 }
69
70 Error PassthroughFs::Rename(const Path& path, const Path& newpath) {
71   // Not implemented by NaCl.
72   return ENOSYS;
73 }
74
75 }  // namespace nacl_io