summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbinji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-13 23:34:25 +0000
committerbinji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-13 23:34:25 +0000
commit7b6ccea224b94d050f0d36b8a473cb7492f76c21 (patch)
treed5016813308ad25a41be2a4fc1c205eb21e26856
parentfd2afc24f952a795acfe81906b02ef1e7330d17d (diff)
downloadchromium_src-7b6ccea224b94d050f0d36b8a473cb7492f76c21.zip
chromium_src-7b6ccea224b94d050f0d36b8a473cb7492f76c21.tar.gz
chromium_src-7b6ccea224b94d050f0d36b8a473cb7492f76c21.tar.bz2
[NaCl SDK] nacl_io: Rename Mount -> Filesystem, MountNode -> Node.
(This basically renames everything...) BUG=none R=noelallen@chromium.org, sbc@chromium.org Review URL: https://codereview.chromium.org/113123003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240799 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--native_client_sdk/src/libraries/nacl_io/char_node.h21
-rw-r--r--native_client_sdk/src/libraries/nacl_io/devfs/dev_fs.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount_dev.cc)88
-rw-r--r--native_client_sdk/src/libraries/nacl_io/devfs/dev_fs.h (renamed from native_client_sdk/src/libraries/nacl_io/mount_dev.h)28
-rw-r--r--native_client_sdk/src/libraries/nacl_io/devfs/tty_event_emitter.cc (renamed from native_client_sdk/src/libraries/nacl_io/event_emitter_pipe.cc)12
-rw-r--r--native_client_sdk/src/libraries/nacl_io/devfs/tty_event_emitter.h (renamed from native_client_sdk/src/libraries/nacl_io/event_emitter_tty.h)19
-rw-r--r--native_client_sdk/src/libraries/nacl_io/devfs/tty_node.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount_node_tty.cc)67
-rw-r--r--native_client_sdk/src/libraries/nacl_io/devfs/tty_node.h (renamed from native_client_sdk/src/libraries/nacl_io/mount_node_tty.h)17
-rw-r--r--native_client_sdk/src/libraries/nacl_io/dir_node.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount_node_dir.cc)42
-rw-r--r--native_client_sdk/src/libraries/nacl_io/dir_node.h70
-rw-r--r--native_client_sdk/src/libraries/nacl_io/filesystem.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount.cc)22
-rw-r--r--native_client_sdk/src/libraries/nacl_io/filesystem.h (renamed from native_client_sdk/src/libraries/nacl_io/mount.h)58
-rw-r--r--native_client_sdk/src/libraries/nacl_io/fs_factory.h29
-rw-r--r--native_client_sdk/src/libraries/nacl_io/fuse.h13
-rw-r--r--native_client_sdk/src/libraries/nacl_io/fuse_mount_factory.cc28
-rw-r--r--native_client_sdk/src/libraries/nacl_io/fuse_mount_factory.h27
-rw-r--r--native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount_fuse.cc)145
-rw-r--r--native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.h (renamed from native_client_sdk/src/libraries/nacl_io/mount_fuse.h)69
-rw-r--r--native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs_factory.cc27
-rw-r--r--native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs_factory.h27
-rw-r--r--native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount_html5fs.cc)68
-rw-r--r--native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.h (renamed from native_client_sdk/src/libraries/nacl_io/mount_html5fs.h)22
-rw-r--r--native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount_node_html5fs.cc)137
-rw-r--r--native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.h (renamed from native_client_sdk/src/libraries/nacl_io/mount_node_html5fs.h)20
-rw-r--r--native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount_http.cc)88
-rw-r--r--native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.h (renamed from native_client_sdk/src/libraries/nacl_io/mount_http.h)29
-rw-r--r--native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount_node_http.cc)140
-rw-r--r--native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.h (renamed from native_client_sdk/src/libraries/nacl_io/mount_node_http.h)16
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_handle.cc34
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_handle.h24
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc8
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_intercept.h4
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_object.cc73
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_object.h44
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc144
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_proxy.h62
-rw-r--r--native_client_sdk/src/libraries/nacl_io/library.dsc114
-rw-r--r--native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount_mem.cc)78
-rw-r--r--native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.h (renamed from native_client_sdk/src/libraries/nacl_io/mount_mem.h)32
-rw-r--r--native_client_sdk/src/libraries/nacl_io/memfs/mem_fs_node.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount_node_mem.cc)27
-rw-r--r--native_client_sdk/src/libraries/nacl_io/memfs/mem_fs_node.h (renamed from native_client_sdk/src/libraries/nacl_io/mount_node_mem.h)16
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_factory.h29
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_char.h21
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_dir.h66
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_pipe.cc62
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_pipe.h36
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_stream.cc58
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_passthrough.h37
-rw-r--r--native_client_sdk/src/libraries/nacl_io/nacl_io.cc8
-rw-r--r--native_client_sdk/src/libraries/nacl_io/nacl_io.h42
-rw-r--r--native_client_sdk/src/libraries/nacl_io/node.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount_node.cc)88
-rw-r--r--native_client_sdk/src/libraries/nacl_io/node.h (renamed from native_client_sdk/src/libraries/nacl_io/mount_node.h)52
-rw-r--r--native_client_sdk/src/libraries/nacl_io/passthroughfs/passthrough_fs.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount_passthrough.cc)41
-rw-r--r--native_client_sdk/src/libraries/nacl_io/passthroughfs/passthrough_fs.h38
-rw-r--r--native_client_sdk/src/libraries/nacl_io/pipe/pipe_event_emitter.cc (renamed from native_client_sdk/src/libraries/nacl_io/event_emitter_tty.cc)12
-rw-r--r--native_client_sdk/src/libraries/nacl_io/pipe/pipe_event_emitter.h (renamed from native_client_sdk/src/libraries/nacl_io/event_emitter_pipe.h)19
-rw-r--r--native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.cc58
-rw-r--r--native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.h39
-rw-r--r--native_client_sdk/src/libraries/nacl_io/socket/fifo_packet.cc (renamed from native_client_sdk/src/libraries/nacl_io/fifo_packet.cc)4
-rw-r--r--native_client_sdk/src/libraries/nacl_io/socket/fifo_packet.h (renamed from native_client_sdk/src/libraries/nacl_io/fifo_packet.h)0
-rw-r--r--native_client_sdk/src/libraries/nacl_io/socket/packet.cc (renamed from native_client_sdk/src/libraries/nacl_io/packet.cc)2
-rw-r--r--native_client_sdk/src/libraries/nacl_io/socket/packet.h (renamed from native_client_sdk/src/libraries/nacl_io/packet.h)6
-rw-r--r--native_client_sdk/src/libraries/nacl_io/socket/socket_node.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc)222
-rw-r--r--native_client_sdk/src/libraries/nacl_io/socket/socket_node.h (renamed from native_client_sdk/src/libraries/nacl_io/mount_node_socket.h)28
-rw-r--r--native_client_sdk/src/libraries/nacl_io/socket/tcp_event_emitter.cc (renamed from native_client_sdk/src/libraries/nacl_io/event_emitter_tcp.cc)33
-rw-r--r--native_client_sdk/src/libraries/nacl_io/socket/tcp_event_emitter.h (renamed from native_client_sdk/src/libraries/nacl_io/event_emitter_tcp.h)22
-rw-r--r--native_client_sdk/src/libraries/nacl_io/socket/tcp_node.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount_node_tcp.cc)231
-rw-r--r--native_client_sdk/src/libraries/nacl_io/socket/tcp_node.h (renamed from native_client_sdk/src/libraries/nacl_io/mount_node_tcp.h)26
-rw-r--r--native_client_sdk/src/libraries/nacl_io/socket/udp_event_emitter.cc (renamed from native_client_sdk/src/libraries/nacl_io/event_emitter_udp.cc)16
-rw-r--r--native_client_sdk/src/libraries/nacl_io/socket/udp_event_emitter.h (renamed from native_client_sdk/src/libraries/nacl_io/event_emitter_udp.h)21
-rw-r--r--native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount_node_udp.cc)138
-rw-r--r--native_client_sdk/src/libraries/nacl_io/socket/udp_node.h (renamed from native_client_sdk/src/libraries/nacl_io/mount_node_udp.h)20
-rw-r--r--native_client_sdk/src/libraries/nacl_io/stream/stream_event_emitter.cc (renamed from native_client_sdk/src/libraries/nacl_io/event_emitter_stream.cc)14
-rw-r--r--native_client_sdk/src/libraries/nacl_io/stream/stream_event_emitter.h (renamed from native_client_sdk/src/libraries/nacl_io/event_emitter_stream.h)25
-rw-r--r--native_client_sdk/src/libraries/nacl_io/stream/stream_fs.cc (renamed from native_client_sdk/src/libraries/nacl_io/mount_stream.cc)47
-rw-r--r--native_client_sdk/src/libraries/nacl_io/stream/stream_fs.h (renamed from native_client_sdk/src/libraries/nacl_io/mount_stream.h)41
-rw-r--r--native_client_sdk/src/libraries/nacl_io/stream/stream_node.cc51
-rw-r--r--native_client_sdk/src/libraries/nacl_io/stream/stream_node.h (renamed from native_client_sdk/src/libraries/nacl_io/mount_node_stream.h)23
-rw-r--r--native_client_sdk/src/libraries/nacl_io/typed_fs_factory.h30
-rw-r--r--native_client_sdk/src/libraries/nacl_io/typed_mount_factory.h30
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/dev_fs_for_testing.h23
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/event_test.cc56
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/example.dsc30
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.cc (renamed from native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5fs.cc)2
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.h (renamed from native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5fs.h)6
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/fifo_test.cc4
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/filesystem_test.cc (renamed from native_client_sdk/src/tests/nacl_io_test/mount_test.cc)273
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/fuse_fs_test.cc (renamed from native_client_sdk/src/tests/nacl_io_test/mount_fuse_test.cc)54
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc (renamed from native_client_sdk/src/tests/nacl_io_test/mount_html5fs_test.cc)174
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/http_fs_test.cc (renamed from native_client_sdk/src/tests/nacl_io_test/mount_http_test.cc)155
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/kernel_object_test.cc77
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc139
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc4
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mem_fs_node_test.cc (renamed from native_client_sdk/src/tests/nacl_io_test/mount_node_test.cc)106
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mock_fs.cc (renamed from native_client_sdk/src/tests/nacl_io_test/mount_mock.cc)7
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mock_fs.h (renamed from native_client_sdk/src/tests/nacl_io_test/mount_mock.h)24
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mock_kernel_proxy.cc (renamed from native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.cc)6
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mock_kernel_proxy.h (renamed from native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.h)12
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mock_node.cc (renamed from native_client_sdk/src/tests/nacl_io_test/mount_node_mock.cc)6
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mock_node.h (renamed from native_client_sdk/src/tests/nacl_io_test/mount_node_mock.h)20
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mount_dev_mock.h23
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/tty_test.cc (renamed from native_client_sdk/src/tests/nacl_io_test/mount_node_tty_test.cc)17
101 files changed, 2404 insertions, 2539 deletions
diff --git a/native_client_sdk/src/libraries/nacl_io/char_node.h b/native_client_sdk/src/libraries/nacl_io/char_node.h
new file mode 100644
index 0000000..9b996a4
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/char_node.h
@@ -0,0 +1,21 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIBRARIES_NACL_IO_CHAR_NODE_H_
+#define LIBRARIES_NACL_IO_CHAR_NODE_H_
+
+#include "nacl_io/node.h"
+
+namespace nacl_io {
+
+class CharNode : public Node {
+ public:
+ explicit CharNode(Filesystem* filesystem) : Node(filesystem) {
+ SetType(S_IFCHR);
+ }
+};
+
+}
+
+#endif // LIBRARIES_NACL_IO_CHAR_NODE_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_dev.cc b/native_client_sdk/src/libraries/nacl_io/devfs/dev_fs.cc
index 38eb86b..8bde062 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_dev.cc
+++ b/native_client_sdk/src/libraries/nacl_io/devfs/dev_fs.cc
@@ -6,16 +6,17 @@
#define _CRT_RAND_S
#endif
+#include "nacl_io/devfs/dev_fs.h"
+
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <string.h>
+#include "nacl_io/devfs/tty_node.h"
+#include "nacl_io/dir_node.h"
#include "nacl_io/kernel_wrap_real.h"
-#include "nacl_io/mount_dev.h"
-#include "nacl_io/mount_node.h"
-#include "nacl_io/mount_node_dir.h"
-#include "nacl_io/mount_node_tty.h"
+#include "nacl_io/node.h"
#include "nacl_io/osunistd.h"
#include "nacl_io/pepper_interface.h"
#include "sdk_util/auto_lock.h"
@@ -30,9 +31,9 @@ namespace nacl_io {
namespace {
-class RealNode : public MountNode {
+class RealNode : public Node {
public:
- RealNode(Mount* mount, int fd);
+ RealNode(Filesystem* filesystem, int fd);
virtual Error Read(const HandleAttr& attr,
void* buf,
@@ -48,9 +49,9 @@ class RealNode : public MountNode {
int fd_;
};
-class NullNode : public MountNodeCharDevice {
+class NullNode : public CharNode {
public:
- explicit NullNode(Mount* mount) : MountNodeCharDevice(mount) {}
+ explicit NullNode(Filesystem* filesystem) : CharNode(filesystem) {}
virtual Error Read(const HandleAttr& attr,
void* buf,
@@ -62,9 +63,9 @@ class NullNode : public MountNodeCharDevice {
int* out_bytes);
};
-class ConsoleNode : public MountNodeCharDevice {
+class ConsoleNode : public CharNode {
public:
- ConsoleNode(Mount* mount, PP_LogLevel level);
+ ConsoleNode(Filesystem* filesystem, PP_LogLevel level);
virtual Error Write(const HandleAttr& attr,
const void* buf,
@@ -75,9 +76,9 @@ class ConsoleNode : public MountNodeCharDevice {
PP_LogLevel level_;
};
-class ZeroNode : public MountNode {
+class ZeroNode : public Node {
public:
- explicit ZeroNode(Mount* mount);
+ explicit ZeroNode(Filesystem* filesystem);
virtual Error Read(const HandleAttr& attr,
void* buf,
@@ -89,9 +90,9 @@ class ZeroNode : public MountNode {
int* out_bytes);
};
-class UrandomNode : public MountNode {
+class UrandomNode : public Node {
public:
- explicit UrandomNode(Mount* mount);
+ explicit UrandomNode(Filesystem* filesystem);
virtual Error Read(const HandleAttr& attr,
void* buf,
@@ -109,7 +110,7 @@ class UrandomNode : public MountNode {
#endif
};
-RealNode::RealNode(Mount* mount, int fd) : MountNode(mount), fd_(fd) {
+RealNode::RealNode(Filesystem* filesystem, int fd) : Node(filesystem), fd_(fd) {
SetType(S_IFCHR);
}
@@ -161,9 +162,8 @@ Error NullNode::Write(const HandleAttr& attr,
return 0;
}
-ConsoleNode::ConsoleNode(Mount* mount, PP_LogLevel level)
- : MountNodeCharDevice(mount), level_(level) {
-}
+ConsoleNode::ConsoleNode(Filesystem* filesystem, PP_LogLevel level)
+ : CharNode(filesystem), level_(level) {}
Error ConsoleNode::Write(const HandleAttr& attr,
const void* buf,
@@ -171,8 +171,8 @@ Error ConsoleNode::Write(const HandleAttr& attr,
int* out_bytes) {
*out_bytes = 0;
- ConsoleInterface* con_intr = mount_->ppapi()->GetConsoleInterface();
- VarInterface* var_intr = mount_->ppapi()->GetVarInterface();
+ ConsoleInterface* con_intr = filesystem_->ppapi()->GetConsoleInterface();
+ VarInterface* var_intr = filesystem_->ppapi()->GetVarInterface();
if (!(var_intr && con_intr))
return ENOSYS;
@@ -180,13 +180,15 @@ Error ConsoleNode::Write(const HandleAttr& attr,
const char* var_data = static_cast<const char*>(buf);
uint32_t len = static_cast<uint32_t>(count);
struct PP_Var val = var_intr->VarFromUtf8(var_data, len);
- con_intr->Log(mount_->ppapi()->GetInstance(), level_, val);
+ con_intr->Log(filesystem_->ppapi()->GetInstance(), level_, val);
*out_bytes = count;
return 0;
}
-ZeroNode::ZeroNode(Mount* mount) : MountNode(mount) { SetType(S_IFCHR); }
+ZeroNode::ZeroNode(Filesystem* filesystem) : Node(filesystem) {
+ SetType(S_IFCHR);
+}
Error ZeroNode::Read(const HandleAttr& attr,
void* buf,
@@ -205,7 +207,7 @@ Error ZeroNode::Write(const HandleAttr& attr,
return 0;
}
-UrandomNode::UrandomNode(Mount* mount) : MountNode(mount) {
+UrandomNode::UrandomNode(Filesystem* filesystem) : Node(filesystem) {
SetType(S_IFCHR);
#if defined(__native_client__)
size_t result = nacl_interface_query(
@@ -260,8 +262,8 @@ Error UrandomNode::Write(const HandleAttr& attr,
} // namespace
-Error MountDev::Access(const Path& path, int a_mode) {
- ScopedMountNode node;
+Error DevFs::Access(const Path& path, int a_mode) {
+ ScopedNode node;
int error = root_->FindChild(path.Join(), &node);
if (error)
return error;
@@ -273,9 +275,7 @@ Error MountDev::Access(const Path& path, int a_mode) {
return 0;
}
-Error MountDev::Open(const Path& path,
- int open_flags,
- ScopedMountNode* out_node) {
+Error DevFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
out_node->reset(NULL);
// Don't allow creating any files.
@@ -285,34 +285,34 @@ Error MountDev::Open(const Path& path,
return root_->FindChild(path.Join(), out_node);
}
-Error MountDev::Unlink(const Path& path) { return EPERM; }
+Error DevFs::Unlink(const Path& path) { return EPERM; }
-Error MountDev::Mkdir(const Path& path, int permissions) { return EPERM; }
+Error DevFs::Mkdir(const Path& path, int permissions) { return EPERM; }
-Error MountDev::Rmdir(const Path& path) { return EPERM; }
+Error DevFs::Rmdir(const Path& path) { return EPERM; }
-Error MountDev::Remove(const Path& path) { return EPERM; }
+Error DevFs::Remove(const Path& path) { return EPERM; }
-Error MountDev::Rename(const Path& path, const Path& newpath) { return EPERM; }
+Error DevFs::Rename(const Path& path, const Path& newpath) { return EPERM; }
-MountDev::MountDev() {}
+DevFs::DevFs() {}
-#define INITIALIZE_DEV_NODE(path, klass) \
- error = root_->AddChild(path, ScopedMountNode(new klass(this))); \
- if (error) \
+#define INITIALIZE_DEV_NODE(path, klass) \
+ error = root_->AddChild(path, ScopedNode(new klass(this))); \
+ if (error) \
return error;
-#define INITIALIZE_DEV_NODE_1(path, klass, arg) \
- error = root_->AddChild(path, ScopedMountNode(new klass(this, arg))); \
- if (error) \
+#define INITIALIZE_DEV_NODE_1(path, klass, arg) \
+ error = root_->AddChild(path, ScopedNode(new klass(this, arg))); \
+ if (error) \
return error;
-Error MountDev::Init(const MountInitArgs& args) {
- Error error = Mount::Init(args);
+Error DevFs::Init(const FsInitArgs& args) {
+ Error error = Filesystem::Init(args);
if (error)
return error;
- root_.reset(new MountNodeDir(this));
+ root_.reset(new DirNode(this));
INITIALIZE_DEV_NODE("/null", NullNode);
INITIALIZE_DEV_NODE("/zero", ZeroNode);
@@ -321,7 +321,7 @@ Error MountDev::Init(const MountInitArgs& args) {
INITIALIZE_DEV_NODE_1("/console1", ConsoleNode, PP_LOGLEVEL_LOG);
INITIALIZE_DEV_NODE_1("/console2", ConsoleNode, PP_LOGLEVEL_WARNING);
INITIALIZE_DEV_NODE_1("/console3", ConsoleNode, PP_LOGLEVEL_ERROR);
- INITIALIZE_DEV_NODE("/tty", MountNodeTty);
+ INITIALIZE_DEV_NODE("/tty", TtyNode);
INITIALIZE_DEV_NODE_1("/stdin", RealNode, 0);
INITIALIZE_DEV_NODE_1("/stdout", RealNode, 1);
INITIALIZE_DEV_NODE_1("/stderr", RealNode, 2);
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_dev.h b/native_client_sdk/src/libraries/nacl_io/devfs/dev_fs.h
index 110c8fd..c446109 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_dev.h
+++ b/native_client_sdk/src/libraries/nacl_io/devfs/dev_fs.h
@@ -2,22 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_MOUNT_DEV_H_
-#define LIBRARIES_NACL_IO_MOUNT_DEV_H_
+#ifndef LIBRARIES_NACL_IO_DEVFS_DEV_FS_H_
+#define LIBRARIES_NACL_IO_DEVFS_DEV_FS_H_
-#include "nacl_io/mount.h"
-#include "nacl_io/typed_mount_factory.h"
+#include "nacl_io/filesystem.h"
+#include "nacl_io/typed_fs_factory.h"
namespace nacl_io {
-class MountNode;
+class Node;
-class MountDev : public Mount {
+class DevFs : public Filesystem {
public:
virtual Error Access(const Path& path, int a_mode);
- virtual Error Open(const Path& path,
- int open_flags,
- ScopedMountNode* out_node);
+ virtual Error Open(const Path& path, int open_flags, ScopedNode* out_node);
virtual Error Unlink(const Path& path);
virtual Error Mkdir(const Path& path, int permissions);
virtual Error Rmdir(const Path& path);
@@ -25,17 +23,17 @@ class MountDev : public Mount {
virtual Error Rename(const Path& path, const Path& newpath);
protected:
- MountDev();
+ DevFs();
- virtual Error Init(const MountInitArgs& args);
+ virtual Error Init(const FsInitArgs& args);
private:
- ScopedMountNode root_;
+ ScopedNode root_;
- friend class TypedMountFactory<MountDev>;
- DISALLOW_COPY_AND_ASSIGN(MountDev);
+ friend class TypedFsFactory<DevFs>;
+ DISALLOW_COPY_AND_ASSIGN(DevFs);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_MOUNT_DEV_H_
+#endif // LIBRARIES_NACL_IO_DEVFS_DEV_FS_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/event_emitter_pipe.cc b/native_client_sdk/src/libraries/nacl_io/devfs/tty_event_emitter.cc
index 2c5308e..5ebc36f 100644
--- a/native_client_sdk/src/libraries/nacl_io/event_emitter_pipe.cc
+++ b/native_client_sdk/src/libraries/nacl_io/devfs/tty_event_emitter.cc
@@ -2,27 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <poll.h>
-#include <stdint.h>
-#include <stdlib.h>
+#include "nacl_io/devfs/tty_event_emitter.h"
-#include "nacl_io/event_emitter_pipe.h"
+#include <algorithm>
namespace nacl_io {
-EventEmitterPipe::EventEmitterPipe(size_t size)
+TtyEventEmitter::TtyEventEmitter(size_t size)
: fifo_(std::max<size_t>(1, size)) {
UpdateStatus_Locked();
}
-size_t EventEmitterPipe::Read_Locked(char* data, size_t len) {
+size_t TtyEventEmitter::Read_Locked(char* data, size_t len) {
size_t out_len = fifo_.Read(data, len);
UpdateStatus_Locked();
return out_len;
}
-size_t EventEmitterPipe::Write_Locked(const char* data, size_t len) {
+size_t TtyEventEmitter::Write_Locked(const char* data, size_t len) {
size_t out_len = fifo_.Write(data, len);
UpdateStatus_Locked();
diff --git a/native_client_sdk/src/libraries/nacl_io/event_emitter_tty.h b/native_client_sdk/src/libraries/nacl_io/devfs/tty_event_emitter.h
index d3fbd89..c42f7c4 100644
--- a/native_client_sdk/src/libraries/nacl_io/event_emitter_tty.h
+++ b/native_client_sdk/src/libraries/nacl_io/devfs/tty_event_emitter.h
@@ -2,28 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_EVENT_EMITTER_TTY_H_
-#define LIBRARIES_NACL_IO_EVENT_EMITTER_TTY_H_
+#ifndef LIBRARIES_NACL_IO_DEVFS_TTY_EVENT_EMITTER_H_
+#define LIBRARIES_NACL_IO_DEVFS_TTY_EVENT_EMITTER_H_
#include <poll.h>
#include <stdint.h>
#include <stdlib.h>
-#include "nacl_io/event_emitter_stream.h"
#include "nacl_io/fifo_char.h"
#include "nacl_io/fifo_null.h"
+#include "nacl_io/stream/stream_event_emitter.h"
#include "sdk_util/auto_lock.h"
#include "sdk_util/macros.h"
namespace nacl_io {
-class EventEmitterTTY;
-typedef sdk_util::ScopedRef<EventEmitterTTY> ScopedEventEmitterTTY;
+class TtyEventEmitter;
+typedef sdk_util::ScopedRef<TtyEventEmitter> ScopedTtyEventEmitter;
-class EventEmitterTTY : public EventEmitterStream {
+class TtyEventEmitter : public StreamEventEmitter {
public:
- explicit EventEmitterTTY(size_t size);
+ explicit TtyEventEmitter(size_t size);
size_t Read_Locked(char* data, size_t len);
size_t Write_Locked(const char* data, size_t len);
@@ -35,10 +35,9 @@ class EventEmitterTTY : public EventEmitterStream {
private:
FIFOChar fifo_;
FIFONull null_;
- DISALLOW_COPY_AND_ASSIGN(EventEmitterTTY);
+ DISALLOW_COPY_AND_ASSIGN(TtyEventEmitter);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_EVENT_EMITTER_PIPE_H_
-
+#endif // LIBRARIES_NACL_IO_DEVFS_TTY_EVENT_EMITTER_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_tty.cc b/native_client_sdk/src/libraries/nacl_io/devfs/tty_node.cc
index 48581c46..9173f12 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_tty.cc
+++ b/native_client_sdk/src/libraries/nacl_io/devfs/tty_node.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/mount_node_tty.h"
+#include "nacl_io/devfs/tty_node.h"
#include <assert.h>
#include <errno.h>
@@ -14,14 +14,14 @@
#include <algorithm>
+#include "nacl_io/filesystem.h"
#include "nacl_io/ioctl.h"
#include "nacl_io/kernel_handle.h"
#include "nacl_io/kernel_intercept.h"
-#include "nacl_io/mount.h"
#include "nacl_io/pepper_interface.h"
#include "sdk_util/auto_lock.h"
-#define CHECK_LFLAG(TERMIOS, FLAG) (TERMIOS .c_lflag & FLAG)
+#define CHECK_LFLAG(TERMIOS, FLAG) (TERMIOS.c_lflag & FLAG)
#define IS_ECHO CHECK_LFLAG(termios_, ECHO)
#define IS_ECHOE CHECK_LFLAG(termios_, ECHOE)
@@ -34,8 +34,8 @@
namespace nacl_io {
-MountNodeTty::MountNodeTty(Mount* mount)
- : MountNodeCharDevice(mount),
+TtyNode::TtyNode(Filesystem* filesystem)
+ : CharNode(filesystem),
emitter_(new EventEmitter),
rows_(DEFAULT_TTY_ROWS),
cols_(DEFAULT_TTY_COLS) {
@@ -46,7 +46,7 @@ MountNodeTty::MountNodeTty(Mount* mount)
emitter_->RaiseEvents_Locked(POLLOUT);
}
-void MountNodeTty::InitTermios() {
+void TtyNode::InitTermios() {
// Some sane values that produce good result.
termios_.c_iflag = ICRNL | IXON | IXOFF | IUTF8;
termios_.c_oflag = OPOST | ONLCR;
@@ -74,14 +74,12 @@ void MountNodeTty::InitTermios() {
termios_.c_cc[VEOL2] = 0;
}
-EventEmitter* MountNodeTty::GetEventEmitter() {
- return emitter_.get();
-}
+EventEmitter* TtyNode::GetEventEmitter() { return emitter_.get(); }
-Error MountNodeTty::Write(const HandleAttr& attr,
- const void* buf,
- size_t count,
- int* out_bytes) {
+Error TtyNode::Write(const HandleAttr& attr,
+ const void* buf,
+ size_t count,
+ int* out_bytes) {
AUTO_LOCK(output_lock_);
*out_bytes = 0;
@@ -89,9 +87,8 @@ Error MountNodeTty::Write(const HandleAttr& attr,
if (output_handler_.handler == NULL)
return EIO;
- int rtn = output_handler_.handler(static_cast<const char*>(buf),
- count,
- output_handler_.user_data);
+ int rtn = output_handler_.handler(
+ static_cast<const char*>(buf), count, output_handler_.user_data);
// Negative return value means an error occured and the return
// value is a negated errno value.
@@ -102,11 +99,10 @@ Error MountNodeTty::Write(const HandleAttr& attr,
return 0;
}
-
-Error MountNodeTty::Read(const HandleAttr& attr,
- void* buf,
- size_t count,
- int* out_bytes) {
+Error TtyNode::Read(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes) {
EventListenerLock wait(GetEventEmitter());
*out_bytes = 0;
@@ -118,9 +114,8 @@ Error MountNodeTty::Read(const HandleAttr& attr,
size_t bytes_to_copy = std::min(count, input_buffer_.size());
if (IS_ICANON) {
// Only read up to (and including) the first newline
- std::deque<char>::iterator nl = std::find(input_buffer_.begin(),
- input_buffer_.end(),
- '\n');
+ std::deque<char>::iterator nl =
+ std::find(input_buffer_.begin(), input_buffer_.end(), '\n');
if (nl != input_buffer_.end()) {
// We found a newline in the buffer, adjust bytes_to_copy accordingly
@@ -129,9 +124,9 @@ Error MountNodeTty::Read(const HandleAttr& attr,
}
}
-
// Copies data from the input buffer into buf.
- std::copy(input_buffer_.begin(), input_buffer_.begin() + bytes_to_copy,
+ std::copy(input_buffer_.begin(),
+ input_buffer_.begin() + bytes_to_copy,
static_cast<char*>(buf));
*out_bytes = bytes_to_copy;
input_buffer_.erase(input_buffer_.begin(),
@@ -142,8 +137,8 @@ Error MountNodeTty::Read(const HandleAttr& attr,
// we consumed the final \n char.
bool avail;
if (IS_ICANON)
- avail = std::find(input_buffer_.begin(),
- input_buffer_.end(), '\n') != input_buffer_.end();
+ avail = std::find(input_buffer_.begin(), input_buffer_.end(), '\n') !=
+ input_buffer_.end();
else
avail = input_buffer_.size() > 0;
@@ -153,7 +148,7 @@ Error MountNodeTty::Read(const HandleAttr& attr,
return 0;
}
-Error MountNodeTty::Echo(const char* string, int count) {
+Error TtyNode::Echo(const char* string, int count) {
int wrote;
HandleAttr data;
Error error = Write(data, string, count, &wrote);
@@ -166,7 +161,7 @@ Error MountNodeTty::Echo(const char* string, int count) {
return 0;
}
-Error MountNodeTty::ProcessInput(struct tioc_nacl_input_string* message) {
+Error TtyNode::ProcessInput(struct tioc_nacl_input_string* message) {
AUTO_LOCK(emitter_->GetLock())
const char* buffer = message->buffer;
@@ -233,7 +228,7 @@ Error MountNodeTty::ProcessInput(struct tioc_nacl_input_string* message) {
return 0;
}
-Error MountNodeTty::VIoctl(int request, va_list args) {
+Error TtyNode::VIoctl(int request, va_list args) {
switch (request) {
case TIOCNACLOUTPUT: {
struct tioc_nacl_output* arg = va_arg(args, struct tioc_nacl_output*);
@@ -251,7 +246,7 @@ Error MountNodeTty::VIoctl(int request, va_list args) {
// This ioctl is used to deliver data from the user to this tty node's
// input buffer.
struct tioc_nacl_input_string* message =
- va_arg(args, struct tioc_nacl_input_string*);
+ va_arg(args, struct tioc_nacl_input_string*);
return ProcessInput(message);
}
case TIOCSWINSZ: {
@@ -284,17 +279,17 @@ Error MountNodeTty::VIoctl(int request, va_list args) {
return EINVAL;
}
-Error MountNodeTty::Tcgetattr(struct termios* termios_p) {
+Error TtyNode::Tcgetattr(struct termios* termios_p) {
AUTO_LOCK(node_lock_);
*termios_p = termios_;
return 0;
}
-Error MountNodeTty::Tcsetattr(int optional_actions,
- const struct termios *termios_p) {
+Error TtyNode::Tcsetattr(int optional_actions,
+ const struct termios* termios_p) {
AUTO_LOCK(node_lock_);
termios_ = *termios_p;
return 0;
}
-}
+} // namespace nacl_io
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_tty.h b/native_client_sdk/src/libraries/nacl_io/devfs/tty_node.h
index b47396f..72045e8 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_tty.h
+++ b/native_client_sdk/src/libraries/nacl_io/devfs/tty_node.h
@@ -2,24 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_TTY_H_
-#define LIBRARIES_NACL_IO_MOUNT_NODE_TTY_H_
+#ifndef LIBRARIES_NACL_IO_DEVFS_TTY_NODE_H_
+#define LIBRARIES_NACL_IO_DEVFS_TTY_NODE_H_
#include <poll.h>
#include <pthread.h>
#include <deque>
+#include "nacl_io/char_node.h"
#include "nacl_io/ioctl.h"
-#include "nacl_io/mount_node_char.h"
#include "nacl_io/ostermios.h"
-
namespace nacl_io {
-class MountNodeTty : public MountNodeCharDevice {
+class TtyNode : public CharNode {
public:
- explicit MountNodeTty(Mount* mount);
+ explicit TtyNode(Filesystem* filesystem);
virtual EventEmitter* GetEventEmitter();
@@ -37,7 +36,7 @@ class MountNodeTty : public MountNodeCharDevice {
virtual Error Tcgetattr(struct termios* termios_p);
virtual Error Tcsetattr(int optional_actions,
- const struct termios *termios_p);
+ const struct termios* termios_p);
private:
ScopedEventEmitter emitter_;
@@ -61,6 +60,6 @@ class MountNodeTty : public MountNodeCharDevice {
sdk_util::SimpleLock output_lock_;
};
-}
+} // namespace nacl_io
-#endif
+#endif // LIBRARIES_NACL_IO_DEVFS_TTY_NODE_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_dir.cc b/native_client_sdk/src/libraries/nacl_io/dir_node.cc
index 5a71de8..91ef0d8 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_dir.cc
+++ b/native_client_sdk/src/libraries/nacl_io/dir_node.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/mount_node_dir.h"
+#include "nacl_io/dir_node.h"
#include <errno.h>
#include <string.h>
@@ -21,8 +21,8 @@ const ino_t kParentDirIno = -1;
}
-MountNodeDir::MountNodeDir(Mount* mount)
- : MountNode(mount),
+DirNode::DirNode(Filesystem* filesystem)
+ : Node(filesystem),
cache_(stat_.st_ino, kParentDirIno),
cache_built_(false) {
SetType(S_IFDIR);
@@ -30,13 +30,13 @@ MountNodeDir::MountNodeDir(Mount* mount)
stat_.st_mode |= S_IRALL | S_IWALL | S_IXALL;
}
-MountNodeDir::~MountNodeDir() {
- for (MountNodeMap_t::iterator it = map_.begin(); it != map_.end(); ++it) {
+DirNode::~DirNode() {
+ for (NodeMap_t::iterator it = map_.begin(); it != map_.end(); ++it) {
it->second->Unlink();
}
}
-Error MountNodeDir::Read(const HandleAttr& attr,
+Error DirNode::Read(const HandleAttr& attr,
void* buf,
size_t count,
int* out_bytes) {
@@ -44,9 +44,9 @@ Error MountNodeDir::Read(const HandleAttr& attr,
return EISDIR;
}
-Error MountNodeDir::FTruncate(off_t size) { return EISDIR; }
+Error DirNode::FTruncate(off_t size) { return EISDIR; }
-Error MountNodeDir::Write(const HandleAttr& attr,
+Error DirNode::Write(const HandleAttr& attr,
const void* buf,
size_t count,
int* out_bytes) {
@@ -54,7 +54,7 @@ Error MountNodeDir::Write(const HandleAttr& attr,
return EISDIR;
}
-Error MountNodeDir::GetDents(size_t offs,
+Error DirNode::GetDents(size_t offs,
dirent* pdir,
size_t size,
int* out_bytes) {
@@ -63,8 +63,8 @@ Error MountNodeDir::GetDents(size_t offs,
return cache_.GetDents(offs, pdir, size, out_bytes);
}
-Error MountNodeDir::AddChild(const std::string& name,
- const ScopedMountNode& node) {
+Error DirNode::AddChild(const std::string& name,
+ const ScopedNode& node) {
AUTO_LOCK(node_lock_);
if (name.empty())
@@ -73,7 +73,7 @@ Error MountNodeDir::AddChild(const std::string& name,
if (name.length() >= MEMBER_SIZE(dirent, d_name))
return ENAMETOOLONG;
- MountNodeMap_t::iterator it = map_.find(name);
+ NodeMap_t::iterator it = map_.find(name);
if (it != map_.end())
return EEXIST;
@@ -83,9 +83,9 @@ Error MountNodeDir::AddChild(const std::string& name,
return 0;
}
-Error MountNodeDir::RemoveChild(const std::string& name) {
+Error DirNode::RemoveChild(const std::string& name) {
AUTO_LOCK(node_lock_);
- MountNodeMap_t::iterator it = map_.find(name);
+ NodeMap_t::iterator it = map_.find(name);
if (it != map_.end()) {
it->second->Unlink();
map_.erase(it);
@@ -95,12 +95,12 @@ Error MountNodeDir::RemoveChild(const std::string& name) {
return ENOENT;
}
-Error MountNodeDir::FindChild(const std::string& name,
- ScopedMountNode* out_node) {
+Error DirNode::FindChild(const std::string& name,
+ ScopedNode* out_node) {
out_node->reset(NULL);
AUTO_LOCK(node_lock_);
- MountNodeMap_t::iterator it = map_.find(name);
+ NodeMap_t::iterator it = map_.find(name);
if (it == map_.end())
return ENOENT;
@@ -108,16 +108,16 @@ Error MountNodeDir::FindChild(const std::string& name,
return 0;
}
-int MountNodeDir::ChildCount() {
+int DirNode::ChildCount() {
AUTO_LOCK(node_lock_);
return map_.size();
}
-void MountNodeDir::BuildCache_Locked() {
+void DirNode::BuildCache_Locked() {
if (cache_built_)
return;
- for (MountNodeMap_t::iterator it = map_.begin(), end = map_.end();
+ for (NodeMap_t::iterator it = map_.begin(), end = map_.end();
it != end; ++it) {
const std::string& name = it->first;
ino_t ino = it->second->stat_.st_ino;
@@ -127,7 +127,7 @@ void MountNodeDir::BuildCache_Locked() {
cache_built_ = true;
}
-void MountNodeDir::ClearCache_Locked() {
+void DirNode::ClearCache_Locked() {
cache_built_ = false;
cache_.Reset();
}
diff --git a/native_client_sdk/src/libraries/nacl_io/dir_node.h b/native_client_sdk/src/libraries/nacl_io/dir_node.h
new file mode 100644
index 0000000..ff7cc81
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/dir_node.h
@@ -0,0 +1,70 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIBRARIES_NACL_IO_DIR_NODE_H_
+#define LIBRARIES_NACL_IO_DIR_NODE_H_
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "nacl_io/getdents_helper.h"
+#include "nacl_io/node.h"
+
+namespace nacl_io {
+
+class DevFs;
+class Html5Fs;
+class HttpFs;
+class MemFs;
+class DirNode;
+
+typedef sdk_util::ScopedRef<DirNode> ScopedDirNode;
+
+class DirNode : public Node {
+ protected:
+ explicit DirNode(Filesystem* fs);
+ virtual ~DirNode();
+
+ public:
+ typedef std::map<std::string, ScopedNode> NodeMap_t;
+
+ virtual Error FTruncate(off_t size);
+ virtual Error GetDents(size_t offs,
+ struct dirent* pdir,
+ size_t count,
+ int* out_bytes);
+ virtual Error Read(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes);
+ virtual Error Write(const HandleAttr& attr,
+ const void* buf,
+ size_t count,
+ int* out_bytes);
+
+ // Adds a finds or adds a directory entry as an INO, updating the refcount
+ virtual Error AddChild(const std::string& name, const ScopedNode& node);
+ virtual Error RemoveChild(const std::string& name);
+ virtual Error FindChild(const std::string& name, ScopedNode* out_node);
+ virtual int ChildCount();
+
+ protected:
+ void BuildCache_Locked();
+ void ClearCache_Locked();
+
+ private:
+ GetDentsHelper cache_;
+ NodeMap_t map_;
+ bool cache_built_;
+
+ friend class DevFs;
+ friend class Html5Fs;
+ friend class HttpFs;
+ friend class MemFs;
+};
+
+} // namespace nacl_io
+
+#endif // LIBRARIES_NACL_IO_DIR_NODE_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount.cc b/native_client_sdk/src/libraries/nacl_io/filesystem.cc
index 3c0d7a2..f7a5c8c 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount.cc
+++ b/native_client_sdk/src/libraries/nacl_io/filesystem.cc
@@ -2,15 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/mount.h"
+#include "nacl_io/filesystem.h"
#include <errno.h>
#include <fcntl.h>
#include <string>
-#include "nacl_io/mount_node.h"
-#include "nacl_io/mount_node_dir.h"
-#include "nacl_io/mount_node_mem.h"
+#include "nacl_io/dir_node.h"
+#include "nacl_io/node.h"
#include "nacl_io/osstat.h"
#include "nacl_io/path.h"
#include "sdk_util/auto_lock.h"
@@ -22,32 +21,31 @@
namespace nacl_io {
-Mount::Mount() : dev_(0) {}
+Filesystem::Filesystem() : dev_(0) {}
-Mount::~Mount() {}
+Filesystem::~Filesystem() {}
-Error Mount::Init(const MountInitArgs& args) {
+Error Filesystem::Init(const FsInitArgs& args) {
dev_ = args.dev;
ppapi_ = args.ppapi;
return 0;
}
-void Mount::Destroy() {}
+void Filesystem::Destroy() {}
-Error Mount::OpenResource(const Path& path, ScopedMountNode* out_node) {
+Error Filesystem::OpenResource(const Path& path, ScopedNode* out_node) {
out_node->reset(NULL);
return EINVAL;
}
-void Mount::OnNodeCreated(MountNode* node) {
+void Filesystem::OnNodeCreated(Node* node) {
node->stat_.st_ino = inode_pool_.Acquire();
node->stat_.st_dev = dev_;
}
-void Mount::OnNodeDestroyed(MountNode* node) {
+void Filesystem::OnNodeDestroyed(Node* node) {
if (node->stat_.st_ino)
inode_pool_.Release(node->stat_.st_ino);
}
} // namespace nacl_io
-
diff --git a/native_client_sdk/src/libraries/nacl_io/mount.h b/native_client_sdk/src/libraries/nacl_io/filesystem.h
index a99c1fa..6be2c73 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount.h
+++ b/native_client_sdk/src/libraries/nacl_io/filesystem.h
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_MOUNT_H_
-#define LIBRARIES_NACL_IO_MOUNT_H_
+#ifndef LIBRARIES_NACL_IO_FILESYSTEM_H_
+#define LIBRARIES_NACL_IO_FILESYSTEM_H_
#include <map>
#include <string>
#include "nacl_io/error.h"
#include "nacl_io/inode_pool.h"
-#include "nacl_io/mount_node.h"
+#include "nacl_io/node.h"
#include "nacl_io/path.h"
#include "sdk_util/macros.h"
@@ -21,19 +21,19 @@ struct fuse_operations;
namespace nacl_io {
-class Mount;
-class MountNode;
+class Filesystem;
+class Node;
class PepperInterface;
-typedef sdk_util::ScopedRef<Mount> ScopedMount;
+typedef sdk_util::ScopedRef<Filesystem> ScopedFilesystem;
typedef std::map<std::string, std::string> StringMap_t;
-// This structure is passed to all mounts via the Mount::Init virtual function.
-// With it, we can add or remove initialization values without changing the
-// function signature.
-struct MountInitArgs {
- MountInitArgs() : dev(0), ppapi(NULL), fuse_ops(NULL) {}
- explicit MountInitArgs(int dev) : dev(dev), ppapi(NULL), fuse_ops(NULL) {}
+// This structure is passed to all filesystems via the Filesystem::Init virtual
+// function. With it, we can add or remove initialization values without
+// changing the function signature.
+struct FsInitArgs {
+ FsInitArgs() : dev(0), ppapi(NULL), fuse_ops(NULL) {}
+ explicit FsInitArgs(int dev) : dev(dev), ppapi(NULL), fuse_ops(NULL) {}
// Device number of the new filesystem.
int dev;
@@ -44,16 +44,16 @@ struct MountInitArgs {
// NOTE: The KernelProxy is the only class that should be setting errno. All
// other classes should return Error (as defined by nacl_io/error.h).
-class Mount : public sdk_util::RefObject {
+class Filesystem : public sdk_util::RefObject {
protected:
// The protected functions are only used internally and will not
- // acquire or release the mount's lock.
- Mount();
- virtual ~Mount();
+ // acquire or release the filesystem's lock.
+ Filesystem();
+ virtual ~Filesystem();
- // Init must be called by the factory before the mount is used.
- // |ppapi| can be NULL. If so, this mount cannot make any pepper calls.
- virtual Error Init(const MountInitArgs& args);
+ // Init must be called by the factory before the filesystem is used.
+ // |ppapi| can be NULL. If so, this filesystem cannot make any pepper calls.
+ virtual Error Init(const FsInitArgs& args);
virtual void Destroy();
public:
@@ -66,16 +66,16 @@ class Mount : public sdk_util::RefObject {
virtual Error Access(const Path& path, int a_mode) = 0;
// Open a node at |path| with the specified open flags. The resulting
- // MountNode is created with a ref count of 1.
+ // Node is created with a ref count of 1.
// Assumes that |out_node| is non-NULL.
virtual Error Open(const Path& path,
int open_flags,
- ScopedMountNode* out_node) = 0;
+ ScopedNode* out_node) = 0;
- // OpenResource is only used to read files from the NaCl NMF file. No mount
- // except MountPassthrough should implement it.
+ // OpenResource is only used to read files from the NaCl NMF file. No
+ // filesystem except PassthroughFs should implement it.
// Assumes that |out_node| is non-NULL.
- virtual Error OpenResource(const Path& path, ScopedMountNode* out_node);
+ virtual Error OpenResource(const Path& path, ScopedNode* out_node);
// Unlink, Mkdir, Rmdir will affect the both the RefCount
// and the nlink number in the stat object.
@@ -86,13 +86,13 @@ class Mount : public sdk_util::RefObject {
virtual Error Rename(const Path& path, const Path& newpath) = 0;
// Assumes that |node| is non-NULL.
- void OnNodeCreated(MountNode* node);
+ void OnNodeCreated(Node* node);
// Assumes that |node| is non-NULL.
- void OnNodeDestroyed(MountNode* node);
+ void OnNodeDestroyed(Node* node);
protected:
- // Device number for the mount.
+ // Device number for the filesystem.
int dev_;
PepperInterface* ppapi_; // Weak reference.
INodePool inode_pool_;
@@ -102,9 +102,9 @@ class Mount : public sdk_util::RefObject {
// lock is held, so we make it private.
friend class KernelObject;
friend class KernelProxy;
- DISALLOW_COPY_AND_ASSIGN(Mount);
+ DISALLOW_COPY_AND_ASSIGN(Filesystem);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_MOUNT_H_
+#endif // LIBRARIES_NACL_IO_FILESYSTEM_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/fs_factory.h b/native_client_sdk/src/libraries/nacl_io/fs_factory.h
new file mode 100644
index 0000000..cc9bbaa
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/fs_factory.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIBRARIES_NACL_IO_FS_FACTORY_H_
+#define LIBRARIES_NACL_IO_FS_FACTORY_H_
+
+#include <errno.h>
+
+#include "nacl_io/error.h"
+#include "sdk_util/scoped_ref.h"
+
+namespace nacl_io {
+
+class Filesystem;
+class PepperInterface;
+struct FsInitArgs;
+
+class FsFactory {
+ public:
+ virtual ~FsFactory() {}
+ virtual Error CreateFilesystem(
+ const FsInitArgs& args,
+ sdk_util::ScopedRef<Filesystem>* out_fs) = 0;
+};
+
+} // namespace nacl_io
+
+#endif // LIBRARIES_NACL_IO_FS_FACTORY_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/fuse.h b/native_client_sdk/src/libraries/nacl_io/fuse.h
index b7f52d4..feb90cd 100644
--- a/native_client_sdk/src/libraries/nacl_io/fuse.h
+++ b/native_client_sdk/src/libraries/nacl_io/fuse.h
@@ -56,16 +56,17 @@ typedef int (*fuse_fill_dir_t)(void* buf,
const struct stat* stbuf,
off_t off);
-// This structure defines the interface to create a user mount. Pass this to
-// nacl_io_register_mount_type(). (see nacl_io.h)
+// This structure defines the interface to create a user filesystem. Pass this
+// to
+// nacl_io_register_fs_type(). (see nacl_io.h)
//
// Example:
//
// struct fuse_operations g_my_fuse_operations = { ... };
// ...
-// nacl_io_register_mount_type("myfusefs", &g_my_fuse_operations);
+// nacl_io_register_fs_type("myfusefs", &g_my_fuse_operations);
// ...
-// mount("", "/mnt/fuse", "myfusefs", 0, NULL);
+// mount("", "/fs/fuse", "myfusefs", 0, NULL);
//
// It is not necessary to implement every function -- nacl_io will first check
// if the function pointer is NULL before calling it. If it is NULL and
@@ -86,9 +87,9 @@ struct fuse_operations {
unsigned int flag_nopath : 1;
unsigned int flag_reserved : 31;
- // Called when a mount of this type is initialized.
+ // Called when a filesystem of this type is initialized.
void* (*init)(struct fuse_conn_info* conn);
- // Called when a mount of this type is unmounted.
+ // Called when a filesystem of this type is unmounted.
void (*destroy)(void*);
// Called by access()
int (*access)(const char* path, int mode);
diff --git a/native_client_sdk/src/libraries/nacl_io/fuse_mount_factory.cc b/native_client_sdk/src/libraries/nacl_io/fuse_mount_factory.cc
deleted file mode 100644
index c527883..0000000
--- a/native_client_sdk/src/libraries/nacl_io/fuse_mount_factory.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "nacl_io/fuse_mount_factory.h"
-
-#include "nacl_io/mount_fuse.h"
-
-namespace nacl_io {
-
-FuseMountFactory::FuseMountFactory(fuse_operations* fuse_ops)
- : fuse_ops_(fuse_ops) {}
-
-Error FuseMountFactory::CreateMount(const MountInitArgs& args,
- ScopedMount* out_mount) {
- MountInitArgs args_copy(args);
- args_copy.fuse_ops = fuse_ops_;
-
- sdk_util::ScopedRef<MountFuse> mnt(new MountFuse());
- Error error = mnt->Init(args_copy);
- if (error)
- return error;
-
- *out_mount = mnt;
- return 0;
-}
-
-} // namespace nacl_io
diff --git a/native_client_sdk/src/libraries/nacl_io/fuse_mount_factory.h b/native_client_sdk/src/libraries/nacl_io/fuse_mount_factory.h
deleted file mode 100644
index 24ab4e4..0000000
--- a/native_client_sdk/src/libraries/nacl_io/fuse_mount_factory.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIBRARIES_NACL_IO_FUSE_MOUNT_FACTORY_H_
-#define LIBRARIES_NACL_IO_FUSE_MOUNT_FACTORY_H_
-
-#include "nacl_io/mount.h"
-#include "nacl_io/mount_factory.h"
-
-struct fuse_operations;
-
-namespace nacl_io {
-
-class FuseMountFactory : public MountFactory {
- public:
- explicit FuseMountFactory(fuse_operations* fuse_ops);
- virtual Error CreateMount(const MountInitArgs& args,
- ScopedMount* out_mount);
-
- private:
- fuse_operations* fuse_ops_;
-};
-
-} // namespace nacl_io
-
-#endif // LIBRARIES_NACL_IO_FUSE_MOUNT_FACTORY_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_fuse.cc b/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.cc
index 8bf7664..d84895d 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_fuse.cc
+++ b/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/mount_fuse.h"
+#include "nacl_io/fusefs/fuse_fs.h"
#include <errno.h>
#include <fcntl.h>
@@ -14,7 +14,6 @@
#include "nacl_io/kernel_handle.h"
#include "sdk_util/macros.h"
-
namespace nacl_io {
namespace {
@@ -30,10 +29,10 @@ struct FillDirInfo {
} // namespace
-MountFuse::MountFuse() : fuse_ops_(NULL), fuse_user_data_(NULL) {}
+FuseFs::FuseFs() : fuse_ops_(NULL), fuse_user_data_(NULL) {}
-Error MountFuse::Init(const MountInitArgs& args) {
- Error error = Mount::Init(args);
+Error FuseFs::Init(const FsInitArgs& args) {
+ Error error = Filesystem::Init(args);
if (error)
return error;
@@ -49,12 +48,12 @@ Error MountFuse::Init(const MountInitArgs& args) {
return 0;
}
-void MountFuse::Destroy() {
+void FuseFs::Destroy() {
if (fuse_ops_ && fuse_ops_->destroy)
fuse_ops_->destroy(fuse_user_data_);
}
-Error MountFuse::Access(const Path& path, int a_mode) {
+Error FuseFs::Access(const Path& path, int a_mode) {
if (!fuse_ops_->access)
return ENOSYS;
@@ -65,9 +64,7 @@ Error MountFuse::Access(const Path& path, int a_mode) {
return 0;
}
-Error MountFuse::Open(const Path& path,
- int open_flags,
- ScopedMountNode* out_node) {
+Error FuseFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
std::string path_str = path.Join();
const char* path_cstr = path_str.c_str();
int result = 0;
@@ -102,8 +99,7 @@ Error MountFuse::Open(const Path& path,
if ((statbuf.st_mode & S_IFMT) == S_IFDIR) {
// This is a directory. Don't try to open, just create a new node with
// this path.
- ScopedMountNode node(
- new MountNodeFuseDir(this, fuse_ops_, fi, path_cstr));
+ ScopedNode node(new DirFuseFsNode(this, fuse_ops_, fi, path_cstr));
Error error = node->Init(open_flags);
if (error)
return error;
@@ -125,13 +121,13 @@ Error MountFuse::Open(const Path& path,
}
if (!fuse_ops_->open)
- return ENOSYS;
+ return ENOSYS;
result = fuse_ops_->open(path_cstr, &fi);
if (result < 0)
return -result;
}
- ScopedMountNode node(new MountNodeFuseFile(this, fuse_ops_, fi, path_cstr));
+ ScopedNode node(new FileFuseFsNode(this, fuse_ops_, fi, path_cstr));
Error error = node->Init(open_flags);
if (error)
return error;
@@ -140,7 +136,7 @@ Error MountFuse::Open(const Path& path,
return 0;
}
-Error MountFuse::Unlink(const Path& path) {
+Error FuseFs::Unlink(const Path& path) {
if (!fuse_ops_->unlink)
return ENOSYS;
@@ -151,7 +147,7 @@ Error MountFuse::Unlink(const Path& path) {
return 0;
}
-Error MountFuse::Mkdir(const Path& path, int perm) {
+Error FuseFs::Mkdir(const Path& path, int perm) {
if (!fuse_ops_->mkdir)
return ENOSYS;
@@ -162,7 +158,7 @@ Error MountFuse::Mkdir(const Path& path, int perm) {
return 0;
}
-Error MountFuse::Rmdir(const Path& path) {
+Error FuseFs::Rmdir(const Path& path) {
if (!fuse_ops_->rmdir)
return ENOSYS;
@@ -173,8 +169,8 @@ Error MountFuse::Rmdir(const Path& path) {
return 0;
}
-Error MountFuse::Remove(const Path& path) {
- ScopedMountNode node;
+Error FuseFs::Remove(const Path& path) {
+ ScopedNode node;
Error error = Open(path, O_RDONLY, &node);
if (error)
return error;
@@ -193,7 +189,7 @@ Error MountFuse::Remove(const Path& path) {
}
}
-Error MountFuse::Rename(const Path& path, const Path& newpath) {
+Error FuseFs::Rename(const Path& path, const Path& newpath) {
if (!fuse_ops_->rename)
return ENOSYS;
@@ -204,27 +200,24 @@ Error MountFuse::Rename(const Path& path, const Path& newpath) {
return 0;
}
-MountNodeFuse::MountNodeFuse(Mount* mount,
- struct fuse_operations* fuse_ops,
- struct fuse_file_info& info,
- const std::string& path)
- : MountNode(mount),
- fuse_ops_(fuse_ops),
- info_(info),
- path_(path) {}
+FuseFsNode::FuseFsNode(Filesystem* filesystem,
+ struct fuse_operations* fuse_ops,
+ struct fuse_file_info& info,
+ const std::string& path)
+ : Node(filesystem), fuse_ops_(fuse_ops), info_(info), path_(path) {}
-bool MountNodeFuse::CanOpen(int open_flags) {
+bool FuseFsNode::CanOpen(int open_flags) {
struct stat statbuf;
Error error = GetStat(&statbuf);
if (error)
return false;
- // GetStat cached the mode in stat_.st_mode. Forward to MountNode::CanOpen,
+ // GetStat cached the mode in stat_.st_mode. Forward to Node::CanOpen,
// which will check this mode against open_flags.
- return MountNode::CanOpen(open_flags);
+ return Node::CanOpen(open_flags);
}
-Error MountNodeFuse::GetStat(struct stat* stat) {
+Error FuseFsNode::GetStat(struct stat* stat) {
int result;
if (fuse_ops_->fgetattr) {
result = fuse_ops_->fgetattr(path_.c_str(), stat, &info_);
@@ -243,28 +236,28 @@ Error MountNodeFuse::GetStat(struct stat* stat) {
return 0;
}
-Error MountNodeFuse::VIoctl(int request, va_list args) {
+Error FuseFsNode::VIoctl(int request, va_list args) {
// TODO(binji): implement
return ENOSYS;
}
-Error MountNodeFuse::Tcflush(int queue_selector) {
+Error FuseFsNode::Tcflush(int queue_selector) {
// TODO(binji): use ioctl for this?
return ENOSYS;
}
-Error MountNodeFuse::Tcgetattr(struct termios* termios_p) {
+Error FuseFsNode::Tcgetattr(struct termios* termios_p) {
// TODO(binji): use ioctl for this?
return ENOSYS;
}
-Error MountNodeFuse::Tcsetattr(int optional_actions,
- const struct termios* termios_p) {
+Error FuseFsNode::Tcsetattr(int optional_actions,
+ const struct termios* termios_p) {
// TODO(binji): use ioctl for this?
return ENOSYS;
}
-Error MountNodeFuse::GetSize(size_t* out_size) {
+Error FuseFsNode::GetSize(size_t* out_size) {
struct stat statbuf;
Error error = GetStat(&statbuf);
if (error)
@@ -274,19 +267,19 @@ Error MountNodeFuse::GetSize(size_t* out_size) {
return 0;
}
-MountNodeFuseFile::MountNodeFuseFile(Mount* mount,
- struct fuse_operations* fuse_ops,
- struct fuse_file_info& info,
- const std::string& path)
- : MountNodeFuse(mount, fuse_ops, info, path) {}
+FileFuseFsNode::FileFuseFsNode(Filesystem* filesystem,
+ struct fuse_operations* fuse_ops,
+ struct fuse_file_info& info,
+ const std::string& path)
+ : FuseFsNode(filesystem, fuse_ops, info, path) {}
-void MountNodeFuseFile::Destroy() {
+void FileFuseFsNode::Destroy() {
if (!fuse_ops_->release)
return;
fuse_ops_->release(path_.c_str(), &info_);
}
-Error MountNodeFuseFile::FSync() {
+Error FileFuseFsNode::FSync() {
if (!fuse_ops_->fsync)
return ENOSYS;
@@ -297,7 +290,7 @@ Error MountNodeFuseFile::FSync() {
return 0;
}
-Error MountNodeFuseFile::FTruncate(off_t length) {
+Error FileFuseFsNode::FTruncate(off_t length) {
if (!fuse_ops_->ftruncate)
return ENOSYS;
@@ -307,10 +300,10 @@ Error MountNodeFuseFile::FTruncate(off_t length) {
return 0;
}
-Error MountNodeFuseFile::Read(const HandleAttr& attr,
- void* buf,
- size_t count,
- int* out_bytes) {
+Error FileFuseFsNode::Read(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes) {
if (!fuse_ops_->read)
return ENOSYS;
@@ -321,7 +314,7 @@ Error MountNodeFuseFile::Read(const HandleAttr& attr,
return -result;
// Fuse docs say that a read() call will always completely fill the buffer
- // (padding with zeroes) unless the direct_io mount flag is set.
+ // (padding with zeroes) unless the direct_io filesystem flag is set.
// TODO(binji): support the direct_io flag
if (static_cast<size_t>(result) < count)
memset(&cbuf[result], 0, count - result);
@@ -330,10 +323,10 @@ Error MountNodeFuseFile::Read(const HandleAttr& attr,
return 0;
}
-Error MountNodeFuseFile::Write(const HandleAttr& attr,
- const void* buf,
- size_t count,
- int* out_bytes) {
+Error FileFuseFsNode::Write(const HandleAttr& attr,
+ const void* buf,
+ size_t count,
+ int* out_bytes) {
if (!fuse_ops_->write)
return ENOSYS;
@@ -343,26 +336,26 @@ Error MountNodeFuseFile::Write(const HandleAttr& attr,
return -result;
// Fuse docs say that a write() call will always write the entire buffer
- // unless the direct_io mount flag is set.
+ // unless the direct_io filesystem flag is set.
// TODO(binji): What should we do if the user breaks this contract? Warn?
// TODO(binji): support the direct_io flag
*out_bytes = result;
return 0;
}
-MountNodeFuseDir::MountNodeFuseDir(Mount* mount,
- struct fuse_operations* fuse_ops,
- struct fuse_file_info& info,
- const std::string& path)
- : MountNodeFuse(mount, fuse_ops, info, path) {}
+DirFuseFsNode::DirFuseFsNode(Filesystem* filesystem,
+ struct fuse_operations* fuse_ops,
+ struct fuse_file_info& info,
+ const std::string& path)
+ : FuseFsNode(filesystem, fuse_ops, info, path) {}
-void MountNodeFuseDir::Destroy() {
+void DirFuseFsNode::Destroy() {
if (!fuse_ops_->releasedir)
return;
fuse_ops_->releasedir(path_.c_str(), &info_);
}
-Error MountNodeFuseDir::FSync() {
+Error DirFuseFsNode::FSync() {
if (!fuse_ops_->fsyncdir)
return ENOSYS;
@@ -373,10 +366,10 @@ Error MountNodeFuseDir::FSync() {
return 0;
}
-Error MountNodeFuseDir::GetDents(size_t offs,
- struct dirent* pdir,
- size_t count,
- int* out_bytes) {
+Error DirFuseFsNode::GetDents(size_t offs,
+ struct dirent* pdir,
+ size_t count,
+ int* out_bytes) {
if (!fuse_ops_->readdir)
return ENOSYS;
@@ -395,11 +388,8 @@ Error MountNodeFuseDir::GetDents(size_t offs,
Error error = 0;
GetDentsHelper getdents;
FillDirInfo fill_info(&getdents, count);
- result = fuse_ops_->readdir(path_.c_str(),
- &fill_info,
- &MountNodeFuseDir::FillDirCallback,
- offs,
- &info_);
+ result = fuse_ops_->readdir(
+ path_.c_str(), &fill_info, &DirFuseFsNode::FillDirCallback, offs, &info_);
if (result < 0)
goto fail;
@@ -427,10 +417,10 @@ fail:
return -result;
}
-int MountNodeFuseDir::FillDirCallback(void* buf,
- const char* name,
- const struct stat* stbuf,
- off_t off) {
+int DirFuseFsNode::FillDirCallback(void* buf,
+ const char* name,
+ const struct stat* stbuf,
+ off_t off) {
FillDirInfo* fill_info = static_cast<FillDirInfo*>(buf);
// It is OK for the FUSE filesystem to pass a NULL stbuf. In that case, just
@@ -458,5 +448,4 @@ int MountNodeFuseDir::FillDirCallback(void* buf,
}
}
-
} // namespace nacl_io
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_fuse.h b/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.h
index 28e4c3f..0e1f90d 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_fuse.h
+++ b/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.h
@@ -1,50 +1,49 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_MOUNT_FUSE_H_
-#define LIBRARIES_NACL_IO_MOUNT_FUSE_H_
+#ifndef LIBRARIES_NACL_IO_FUSEFS_FUSE_FS_H_
+#define LIBRARIES_NACL_IO_FUSEFS_FUSE_FS_H_
#include <map>
+#include "nacl_io/filesystem.h"
#include "nacl_io/fuse.h"
-#include "nacl_io/mount.h"
-#include "nacl_io/mount_node.h"
-#include "nacl_io/typed_mount_factory.h"
+#include "nacl_io/node.h"
namespace nacl_io {
-class MountFuse : public Mount {
+class FuseFs : public Filesystem {
protected:
- MountFuse();
+ FuseFs();
- virtual Error Init(const MountInitArgs& args);
+ virtual Error Init(const FsInitArgs& args);
virtual void Destroy();
public:
virtual Error Access(const Path& path, int a_mode);
- virtual Error Open(const Path& path, int mode, ScopedMountNode* out_node);
+ virtual Error Open(const Path& path, int mode, ScopedNode* out_node);
virtual Error Unlink(const Path& path);
virtual Error Mkdir(const Path& path, int perm);
virtual Error Rmdir(const Path& path);
virtual Error Remove(const Path& path);
virtual Error Rename(const Path& path, const Path& newpath);
-private:
+ private:
struct fuse_operations* fuse_ops_;
void* fuse_user_data_;
- friend class MountNodeFuse;
- friend class FuseMountFactory;
- DISALLOW_COPY_AND_ASSIGN(MountFuse);
+ friend class FuseFsNode;
+ friend class FuseFsFactory;
+ DISALLOW_COPY_AND_ASSIGN(FuseFs);
};
-class MountNodeFuse : public MountNode {
+class FuseFsNode : public Node {
protected:
- MountNodeFuse(Mount* mount,
- struct fuse_operations* fuse_ops,
- struct fuse_file_info& info,
- const std::string& path);
+ FuseFsNode(Filesystem* filesystem,
+ struct fuse_operations* fuse_ops,
+ struct fuse_file_info& info,
+ const std::string& path);
public:
virtual bool CanOpen(int open_flags);
@@ -53,7 +52,7 @@ class MountNodeFuse : public MountNode {
virtual Error Tcflush(int queue_selector);
virtual Error Tcgetattr(struct termios* termios_p);
virtual Error Tcsetattr(int optional_actions,
- const struct termios *termios_p);
+ const struct termios* termios_p);
virtual Error GetSize(size_t* out_size);
protected:
@@ -62,12 +61,12 @@ class MountNodeFuse : public MountNode {
std::string path_;
};
-class MountNodeFuseFile : public MountNodeFuse {
+class FileFuseFsNode : public FuseFsNode {
public:
- MountNodeFuseFile(Mount* mount,
- struct fuse_operations* fuse_ops,
- struct fuse_file_info& info,
- const std::string& path);
+ FileFuseFsNode(Filesystem* filesystem,
+ struct fuse_operations* fuse_ops,
+ struct fuse_file_info& info,
+ const std::string& path);
protected:
virtual void Destroy();
@@ -85,16 +84,16 @@ class MountNodeFuseFile : public MountNodeFuse {
int* out_bytes);
private:
- friend class MountFuse;
- DISALLOW_COPY_AND_ASSIGN(MountNodeFuseFile);
+ friend class FuseFs;
+ DISALLOW_COPY_AND_ASSIGN(FileFuseFsNode);
};
-class MountNodeFuseDir : public MountNodeFuse {
+class DirFuseFsNode : public FuseFsNode {
public:
- MountNodeFuseDir(Mount* mount,
- struct fuse_operations* fuse_ops,
- struct fuse_file_info& info,
- const std::string& path);
+ DirFuseFsNode(Filesystem* filesystem,
+ struct fuse_operations* fuse_ops,
+ struct fuse_file_info& info,
+ const std::string& path);
protected:
virtual void Destroy();
@@ -113,10 +112,10 @@ class MountNodeFuseDir : public MountNodeFuse {
off_t off);
private:
- friend class MountFuse;
- DISALLOW_COPY_AND_ASSIGN(MountNodeFuseDir);
+ friend class FuseFs;
+ DISALLOW_COPY_AND_ASSIGN(DirFuseFsNode);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_MOUNT_FUSE_H_
+#endif // LIBRARIES_NACL_IO_FUSEFS_FUSE_FS_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs_factory.cc b/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs_factory.cc
new file mode 100644
index 0000000..aaa9eea
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs_factory.cc
@@ -0,0 +1,27 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "nacl_io/fusefs/fuse_fs_factory.h"
+
+#include "nacl_io/fusefs/fuse_fs.h"
+
+namespace nacl_io {
+
+FuseFsFactory::FuseFsFactory(fuse_operations* fuse_ops) : fuse_ops_(fuse_ops) {}
+
+Error FuseFsFactory::CreateFilesystem(const FsInitArgs& args,
+ ScopedFilesystem* out_fs) {
+ FsInitArgs args_copy(args);
+ args_copy.fuse_ops = fuse_ops_;
+
+ sdk_util::ScopedRef<FuseFs> fs(new FuseFs());
+ Error error = fs->Init(args_copy);
+ if (error)
+ return error;
+
+ *out_fs = fs;
+ return 0;
+}
+
+} // namespace nacl_io
diff --git a/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs_factory.h b/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs_factory.h
new file mode 100644
index 0000000..47afd3d
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs_factory.h
@@ -0,0 +1,27 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIBRARIES_NACL_IO_FUSEFS_FUSE_FS_FACTORY_H_
+#define LIBRARIES_NACL_IO_FUSEFS_FUSE_FS_FACTORY_H_
+
+#include "nacl_io/filesystem.h"
+#include "nacl_io/fs_factory.h"
+
+struct fuse_operations;
+
+namespace nacl_io {
+
+class FuseFsFactory : public FsFactory {
+ public:
+ explicit FuseFsFactory(fuse_operations* fuse_ops);
+ virtual Error CreateFilesystem(const FsInitArgs& args,
+ ScopedFilesystem* out_fs);
+
+ private:
+ fuse_operations* fuse_ops_;
+};
+
+} // namespace nacl_io
+
+#endif // LIBRARIES_NACL_IO_FUSEFS_FUSE_FS_FACTORY_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_html5fs.cc b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc
index a54c183..ac4bb3f 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_html5fs.cc
+++ b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc
@@ -2,16 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/mount_html5fs.h"
+#include "nacl_io/html5fs/html5_fs.h"
#include <errno.h>
#include <fcntl.h>
-#include <ppapi/c/pp_completion_callback.h>
-#include <ppapi/c/pp_errors.h>
#include <stdlib.h>
#include <string.h>
+
#include <algorithm>
-#include "nacl_io/mount_node_html5fs.h"
+
+#include <ppapi/c/pp_completion_callback.h>
+#include <ppapi/c/pp_errors.h>
+
+#include "nacl_io/html5fs/html5_fs_node.h"
#include "sdk_util/auto_lock.h"
namespace nacl_io {
@@ -26,26 +29,24 @@ int64_t strtoull(const char* nptr, char** endptr, int base) {
} // namespace
-Error MountHtml5Fs::Access(const Path& path, int a_mode) {
+Error Html5Fs::Access(const Path& path, int a_mode) {
// a_mode is unused, since all files are readable, writable and executable.
- ScopedMountNode node;
+ ScopedNode node;
return Open(path, O_RDONLY, &node);
}
-Error MountHtml5Fs::Open(const Path& path,
- int open_flags,
- ScopedMountNode* out_node) {
+Error Html5Fs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
out_node->reset(NULL);
Error error = BlockUntilFilesystemOpen();
if (error)
return error;
- PP_Resource fileref = ppapi()->GetFileRefInterface()
- ->Create(filesystem_resource_, path.Join().c_str());
+ PP_Resource fileref = ppapi()->GetFileRefInterface()->Create(
+ filesystem_resource_, path.Join().c_str());
if (!fileref)
return ENOENT;
- ScopedMountNode node(new MountNodeHtml5Fs(this, fileref));
+ ScopedNode node(new Html5FsNode(this, fileref));
error = node->Init(open_flags);
if (error)
return error;
@@ -54,9 +55,9 @@ Error MountHtml5Fs::Open(const Path& path,
return 0;
}
-Error MountHtml5Fs::Unlink(const Path& path) { return Remove(path); }
+Error Html5Fs::Unlink(const Path& path) { return Remove(path); }
-Error MountHtml5Fs::Mkdir(const Path& path, int permissions) {
+Error Html5Fs::Mkdir(const Path& path, int permissions) {
Error error = BlockUntilFilesystemOpen();
if (error)
return error;
@@ -81,9 +82,9 @@ Error MountHtml5Fs::Mkdir(const Path& path, int permissions) {
return 0;
}
-Error MountHtml5Fs::Rmdir(const Path& path) { return Remove(path); }
+Error Html5Fs::Rmdir(const Path& path) { return Remove(path); }
-Error MountHtml5Fs::Remove(const Path& path) {
+Error Html5Fs::Remove(const Path& path) {
Error error = BlockUntilFilesystemOpen();
if (error)
return error;
@@ -95,15 +96,15 @@ Error MountHtml5Fs::Remove(const Path& path) {
if (!fileref_resource.pp_resource())
return ENOENT;
- int32_t result = ppapi()->GetFileRefInterface()
- ->Delete(fileref_resource.pp_resource(), PP_BlockUntilComplete());
+ int32_t result = ppapi()->GetFileRefInterface()->Delete(
+ fileref_resource.pp_resource(), PP_BlockUntilComplete());
if (result != PP_OK)
return PPErrorToErrno(result);
return 0;
}
-Error MountHtml5Fs::Rename(const Path& path, const Path& newpath) {
+Error Html5Fs::Rename(const Path& path, const Path& newpath) {
Error error = BlockUntilFilesystemOpen();
if (error)
return error;
@@ -118,13 +119,13 @@ Error MountHtml5Fs::Rename(const Path& path, const Path& newpath) {
return EACCES;
}
-MountHtml5Fs::MountHtml5Fs()
+Html5Fs::Html5Fs()
: filesystem_resource_(0),
filesystem_open_has_result_(false),
filesystem_open_error_(0) {}
-Error MountHtml5Fs::Init(const MountInitArgs& args) {
- Error error = Mount::Init(args);
+Error Html5Fs::Init(const FsInitArgs& args) {
+ Error error = Filesystem::Init(args);
if (error)
return error;
@@ -133,7 +134,7 @@ Error MountHtml5Fs::Init(const MountInitArgs& args) {
pthread_cond_init(&filesystem_open_cond_, NULL);
- // Parse mount args.
+ // Parse filesystem args.
PP_FileSystemType filesystem_type = PP_FILESYSTEMTYPE_LOCALPERSISTENT;
int64_t expected_size = 0;
for (StringMap_t::const_iterator iter = args.string_map.begin();
@@ -151,8 +152,8 @@ Error MountHtml5Fs::Init(const MountInitArgs& args) {
}
// Initialize filesystem.
- filesystem_resource_ = args.ppapi->GetFileSystemInterface()
- ->Create(ppapi_->GetInstance(), filesystem_type);
+ filesystem_resource_ = args.ppapi->GetFileSystemInterface()->Create(
+ ppapi_->GetInstance(), filesystem_type);
if (filesystem_resource_ == 0)
return ENOSYS;
@@ -162,11 +163,11 @@ Error MountHtml5Fs::Init(const MountInitArgs& args) {
bool main_thread = args.ppapi->GetCoreInterface()->IsMainThread();
PP_CompletionCallback cc =
main_thread ? PP_MakeCompletionCallback(
- &MountHtml5Fs::FilesystemOpenCallbackThunk, this)
+ &Html5Fs::FilesystemOpenCallbackThunk, this)
: PP_BlockUntilComplete();
- int32_t result = args.ppapi->GetFileSystemInterface()
- ->Open(filesystem_resource_, expected_size, cc);
+ int32_t result = args.ppapi->GetFileSystemInterface()->Open(
+ filesystem_resource_, expected_size, cc);
if (!main_thread) {
filesystem_open_has_result_ = true;
@@ -180,12 +181,12 @@ Error MountHtml5Fs::Init(const MountInitArgs& args) {
return 0;
}
-void MountHtml5Fs::Destroy() {
+void Html5Fs::Destroy() {
ppapi_->ReleaseResource(filesystem_resource_);
pthread_cond_destroy(&filesystem_open_cond_);
}
-Error MountHtml5Fs::BlockUntilFilesystemOpen() {
+Error Html5Fs::BlockUntilFilesystemOpen() {
AUTO_LOCK(filesysem_open_lock_);
while (!filesystem_open_has_result_) {
pthread_cond_wait(&filesystem_open_cond_, filesysem_open_lock_.mutex());
@@ -194,13 +195,12 @@ Error MountHtml5Fs::BlockUntilFilesystemOpen() {
}
// static
-void MountHtml5Fs::FilesystemOpenCallbackThunk(void* user_data,
- int32_t result) {
- MountHtml5Fs* self = static_cast<MountHtml5Fs*>(user_data);
+void Html5Fs::FilesystemOpenCallbackThunk(void* user_data, int32_t result) {
+ Html5Fs* self = static_cast<Html5Fs*>(user_data);
self->FilesystemOpenCallback(result);
}
-void MountHtml5Fs::FilesystemOpenCallback(int32_t result) {
+void Html5Fs::FilesystemOpenCallback(int32_t result) {
AUTO_LOCK(filesysem_open_lock_);
filesystem_open_has_result_ = true;
filesystem_open_error_ = PPErrorToErrno(result);
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_html5fs.h b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.h
index 06dad78..e71d636 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_html5fs.h
+++ b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.h
@@ -2,24 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_MOUNT_HTML5FS_H_
-#define LIBRARIES_NACL_IO_MOUNT_HTML5FS_H_
+#ifndef LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_H_
+#define LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_H_
#include <pthread.h>
-#include "nacl_io/mount.h"
+#include "nacl_io/filesystem.h"
#include "nacl_io/pepper_interface.h"
-#include "nacl_io/typed_mount_factory.h"
+#include "nacl_io/typed_fs_factory.h"
#include "sdk_util/simple_lock.h"
namespace nacl_io {
-class MountNode;
+class Node;
-class MountHtml5Fs : public Mount {
+class Html5Fs : public Filesystem {
public:
virtual Error Access(const Path& path, int a_mode);
- virtual Error Open(const Path& path, int mode, ScopedMountNode* out_node);
+ virtual Error Open(const Path& path, int mode, ScopedNode* out_node);
virtual Error Unlink(const Path& path);
virtual Error Mkdir(const Path& path, int permissions);
virtual Error Rmdir(const Path& path);
@@ -29,9 +29,9 @@ class MountHtml5Fs : public Mount {
PP_Resource filesystem_resource() { return filesystem_resource_; }
protected:
- MountHtml5Fs();
+ Html5Fs();
- virtual Error Init(const MountInitArgs& args);
+ virtual Error Init(const FsInitArgs& args);
virtual void Destroy();
Error BlockUntilFilesystemOpen();
@@ -47,9 +47,9 @@ class MountHtml5Fs : public Mount {
pthread_cond_t filesystem_open_cond_;
sdk_util::SimpleLock filesysem_open_lock_;
- friend class TypedMountFactory<MountHtml5Fs>;
+ friend class TypedFsFactory<Html5Fs>;
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_MOUNT_HTML5FS_H_
+#endif // LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_html5fs.cc b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc
index 526f94f..a6fa3ba 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_html5fs.cc
+++ b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/mount_node_html5fs.h"
+#include "nacl_io/html5fs/html5_fs_node.h"
#include <errno.h>
#include <fcntl.h>
@@ -14,9 +14,9 @@
#include <string.h>
#include <vector>
+#include "nacl_io/filesystem.h"
#include "nacl_io/getdents_helper.h"
#include "nacl_io/kernel_handle.h"
-#include "nacl_io/mount.h"
#include "nacl_io/osdirent.h"
#include "nacl_io/pepper_interface.h"
#include "sdk_util/auto_lock.h"
@@ -71,22 +71,22 @@ int32_t OpenFlagsToPPAPIOpenFlags(int open_flags) {
} // namespace
-Error MountNodeHtml5Fs::FSync() {
+Error Html5FsNode::FSync() {
// Cannot call Flush on a directory; simply do nothing.
if (IsaDir())
return 0;
- int32_t result = mount_->ppapi()->GetFileIoInterface()
- ->Flush(fileio_resource_, PP_BlockUntilComplete());
+ int32_t result = filesystem_->ppapi()->GetFileIoInterface()->Flush(
+ fileio_resource_, PP_BlockUntilComplete());
if (result != PP_OK)
return PPErrorToErrno(result);
return 0;
}
-Error MountNodeHtml5Fs::GetDents(size_t offs,
- struct dirent* pdir,
- size_t size,
- int* out_bytes) {
+Error Html5FsNode::GetDents(size_t offs,
+ struct dirent* pdir,
+ size_t size,
+ int* out_bytes) {
*out_bytes = 0;
// If this is not a directory, fail
@@ -100,37 +100,38 @@ Error MountNodeHtml5Fs::GetDents(size_t offs,
OutputBuffer output_buf = {NULL, 0};
PP_ArrayOutput output = {&GetOutputBuffer, &output_buf};
- int32_t result = mount_->ppapi()->GetFileRefInterface()->ReadDirectoryEntries(
- fileref_resource_, output, PP_BlockUntilComplete());
+ int32_t result =
+ filesystem_->ppapi()->GetFileRefInterface()->ReadDirectoryEntries(
+ fileref_resource_, output, PP_BlockUntilComplete());
if (result != PP_OK)
return PPErrorToErrno(result);
PP_DirectoryEntry* entries = static_cast<PP_DirectoryEntry*>(output_buf.data);
for (int i = 0; i < output_buf.element_count; ++i) {
- PP_Var file_name_var =
- mount_->ppapi()->GetFileRefInterface()->GetName(entries[i].file_ref);
+ PP_Var file_name_var = filesystem_->ppapi()->GetFileRefInterface()->GetName(
+ entries[i].file_ref);
// Release the file reference.
- mount_->ppapi()->ReleaseResource(entries[i].file_ref);
+ filesystem_->ppapi()->ReleaseResource(entries[i].file_ref);
if (file_name_var.type != PP_VARTYPE_STRING)
continue;
uint32_t file_name_length;
- const char* file_name = mount_->ppapi()->GetVarInterface()
- ->VarToUtf8(file_name_var, &file_name_length);
+ const char* file_name = filesystem_->ppapi()->GetVarInterface()->VarToUtf8(
+ file_name_var, &file_name_length);
if (file_name) {
- file_name_length = std::min(
- static_cast<size_t>(file_name_length),
- MEMBER_SIZE(dirent, d_name) - 1); // -1 for NULL.
+ file_name_length =
+ std::min(static_cast<size_t>(file_name_length),
+ MEMBER_SIZE(dirent, d_name) - 1); // -1 for NULL.
// TODO(binji): Better handling of ino numbers.
helper.AddDirent(1, file_name, file_name_length);
}
- mount_->ppapi()->GetVarInterface()->Release(file_name_var);
+ filesystem_->ppapi()->GetVarInterface()->Release(file_name_var);
}
// Release the output buffer.
@@ -139,11 +140,11 @@ Error MountNodeHtml5Fs::GetDents(size_t offs,
return helper.GetDents(offs, pdir, size, out_bytes);
}
-Error MountNodeHtml5Fs::GetStat(struct stat* stat) {
+Error Html5FsNode::GetStat(struct stat* stat) {
AUTO_LOCK(node_lock_);
PP_FileInfo info;
- int32_t result = mount_->ppapi()->GetFileRefInterface()->Query(
+ int32_t result = filesystem_->ppapi()->GetFileRefInterface()->Query(
fileref_resource_, &info, PP_BlockUntilComplete());
if (result != PP_OK)
return PPErrorToErrno(result);
@@ -171,21 +172,21 @@ Error MountNodeHtml5Fs::GetStat(struct stat* stat) {
return 0;
}
-Error MountNodeHtml5Fs::Read(const HandleAttr& attr,
- void* buf,
- size_t count,
- int* out_bytes) {
+Error Html5FsNode::Read(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes) {
*out_bytes = 0;
if (IsaDir())
return EISDIR;
- int32_t result =
- mount_->ppapi()->GetFileIoInterface()->Read(fileio_resource_,
- attr.offs,
- static_cast<char*>(buf),
- static_cast<int32_t>(count),
- PP_BlockUntilComplete());
+ int32_t result = filesystem_->ppapi()->GetFileIoInterface()->Read(
+ fileio_resource_,
+ attr.offs,
+ static_cast<char*>(buf),
+ static_cast<int32_t>(count),
+ PP_BlockUntilComplete());
if (result < 0)
return PPErrorToErrno(result);
@@ -193,32 +194,32 @@ Error MountNodeHtml5Fs::Read(const HandleAttr& attr,
return 0;
}
-Error MountNodeHtml5Fs::FTruncate(off_t size) {
+Error Html5FsNode::FTruncate(off_t size) {
if (IsaDir())
return EISDIR;
- int32_t result = mount_->ppapi()->GetFileIoInterface()
- ->SetLength(fileio_resource_, size, PP_BlockUntilComplete());
+ int32_t result = filesystem_->ppapi()->GetFileIoInterface()->SetLength(
+ fileio_resource_, size, PP_BlockUntilComplete());
if (result != PP_OK)
return PPErrorToErrno(result);
return 0;
}
-Error MountNodeHtml5Fs::Write(const HandleAttr& attr,
- const void* buf,
- size_t count,
- int* out_bytes) {
+Error Html5FsNode::Write(const HandleAttr& attr,
+ const void* buf,
+ size_t count,
+ int* out_bytes) {
*out_bytes = 0;
if (IsaDir())
return EISDIR;
- int32_t result = mount_->ppapi()->GetFileIoInterface()
- ->Write(fileio_resource_,
- attr.offs,
- static_cast<const char*>(buf),
- static_cast<int32_t>(count),
- PP_BlockUntilComplete());
+ int32_t result = filesystem_->ppapi()->GetFileIoInterface()->Write(
+ fileio_resource_,
+ attr.offs,
+ static_cast<const char*>(buf),
+ static_cast<int32_t>(count),
+ PP_BlockUntilComplete());
if (result < 0)
return PPErrorToErrno(result);
@@ -226,11 +227,9 @@ Error MountNodeHtml5Fs::Write(const HandleAttr& attr,
return 0;
}
-int MountNodeHtml5Fs::GetType() {
- return fileio_resource_ ? S_IFREG : S_IFDIR;
-}
+int Html5FsNode::GetType() { return fileio_resource_ ? S_IFREG : S_IFDIR; }
-Error MountNodeHtml5Fs::GetSize(size_t* out_size) {
+Error Html5FsNode::GetSize(size_t* out_size) {
*out_size = 0;
if (IsaDir())
@@ -239,8 +238,8 @@ Error MountNodeHtml5Fs::GetSize(size_t* out_size) {
AUTO_LOCK(node_lock_);
PP_FileInfo info;
- int32_t result = mount_->ppapi()->GetFileIoInterface()
- ->Query(fileio_resource_, &info, PP_BlockUntilComplete());
+ int32_t result = filesystem_->ppapi()->GetFileIoInterface()->Query(
+ fileio_resource_, &info, PP_BlockUntilComplete());
if (result != PP_OK)
return PPErrorToErrno(result);
@@ -248,36 +247,30 @@ Error MountNodeHtml5Fs::GetSize(size_t* out_size) {
return 0;
}
-bool MountNodeHtml5Fs::IsaDir() {
- return !fileio_resource_;
-}
+bool Html5FsNode::IsaDir() { return !fileio_resource_; }
-bool MountNodeHtml5Fs::IsaFile() {
- return fileio_resource_;
-}
+bool Html5FsNode::IsaFile() { return fileio_resource_; }
-MountNodeHtml5Fs::MountNodeHtml5Fs(Mount* mount, PP_Resource fileref_resource)
- : MountNode(mount),
+Html5FsNode::Html5FsNode(Filesystem* filesystem, PP_Resource fileref_resource)
+ : Node(filesystem),
fileref_resource_(fileref_resource),
fileio_resource_(0) {}
-Error MountNodeHtml5Fs::Init(int open_flags) {
- Error error = MountNode::Init(open_flags);
+Error Html5FsNode::Init(int open_flags) {
+ Error error = Node::Init(open_flags);
if (error)
return error;
// First query the FileRef to see if it is a file or directory.
PP_FileInfo file_info;
- int32_t query_result =
- mount_->ppapi()->GetFileRefInterface()->Query(fileref_resource_,
- &file_info,
- PP_BlockUntilComplete());
+ int32_t query_result = filesystem_->ppapi()->GetFileRefInterface()->Query(
+ fileref_resource_, &file_info, PP_BlockUntilComplete());
// If this is a directory, do not get a FileIO.
if (query_result == PP_OK && file_info.type == PP_FILETYPE_DIRECTORY)
return 0;
- FileIoInterface* file_io = mount_->ppapi()->GetFileIoInterface();
- fileio_resource_ = file_io->Create(mount_->ppapi()->GetInstance());
+ FileIoInterface* file_io = filesystem_->ppapi()->GetFileIoInterface();
+ fileio_resource_ = file_io->Create(filesystem_->ppapi()->GetInstance());
if (!fileio_resource_)
return ENOSYS;
@@ -290,18 +283,18 @@ Error MountNodeHtml5Fs::Init(int open_flags) {
return 0;
}
-void MountNodeHtml5Fs::Destroy() {
+void Html5FsNode::Destroy() {
FSync();
if (fileio_resource_) {
- mount_->ppapi()->GetFileIoInterface()->Close(fileio_resource_);
- mount_->ppapi()->ReleaseResource(fileio_resource_);
+ filesystem_->ppapi()->GetFileIoInterface()->Close(fileio_resource_);
+ filesystem_->ppapi()->ReleaseResource(fileio_resource_);
}
- mount_->ppapi()->ReleaseResource(fileref_resource_);
+ filesystem_->ppapi()->ReleaseResource(fileref_resource_);
fileio_resource_ = 0;
fileref_resource_ = 0;
- MountNode::Destroy();
+ Node::Destroy();
}
} // namespace nacl_io
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_html5fs.h b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.h
index d8ef90b..984a0ea 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_html5fs.h
+++ b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.h
@@ -2,21 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_MOUNT_HTML5FS_NODE_H_
-#define LIBRARIES_NACL_IO_MOUNT_HTML5FS_NODE_H_
+#ifndef LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_NODE_H_
+#define LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_NODE_H_
#include <ppapi/c/pp_resource.h>
-#include "nacl_io/mount_node.h"
+#include "nacl_io/node.h"
namespace nacl_io {
-class MountHtml5Fs;
+class Html5Fs;
-class MountNodeHtml5Fs : public MountNode {
+class Html5FsNode : public Node {
public:
// Normal OS operations on a node (file), can be called by the kernel
// directly so it must lock and unlock appropriately. These functions
- // must not be called by the mount.
+ // must not be called by the filesystem.
virtual Error FSync();
virtual Error GetDents(size_t offs,
struct dirent* pdir,
@@ -34,12 +34,12 @@ class MountNodeHtml5Fs : public MountNode {
int* out_bytes);
virtual int GetType();
- virtual Error GetSize(size_t *out_size);
+ virtual Error GetSize(size_t* out_size);
virtual bool IsaDir();
virtual bool IsaFile();
protected:
- MountNodeHtml5Fs(Mount* mount, PP_Resource fileref);
+ Html5FsNode(Filesystem* filesystem, PP_Resource fileref);
// Init with standard open flags
virtual Error Init(int open_flags);
@@ -49,9 +49,9 @@ class MountNodeHtml5Fs : public MountNode {
PP_Resource fileref_resource_;
PP_Resource fileio_resource_; // 0 if the file is a directory.
- friend class MountHtml5Fs;
+ friend class Html5Fs;
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_MOUNT_HTML5FS_NODE_H_
+#endif // LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_NODE_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_http.cc b/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.cc
index 4d613e9..29dd761 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_http.cc
+++ b/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/mount_http.h"
+#include "nacl_io/httpfs/http_fs.h"
#include <assert.h>
#include <ctype.h>
@@ -15,12 +15,13 @@
#include <vector>
+#include <ppapi/c/pp_errors.h>
+
+#include "nacl_io/dir_node.h"
+#include "nacl_io/httpfs/http_fs_node.h"
#include "nacl_io/kernel_handle.h"
-#include "nacl_io/mount_node_dir.h"
-#include "nacl_io/mount_node_http.h"
#include "nacl_io/osinttypes.h"
#include "nacl_io/osunistd.h"
-#include <ppapi/c/pp_errors.h>
#include "sdk_util/string_util.h"
namespace nacl_io {
@@ -39,14 +40,14 @@ std::string NormalizeHeaderKey(const std::string& s) {
return result;
}
-Error MountHttp::Access(const Path& path, int a_mode) {
+Error HttpFs::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 = MakeUrl(path);
- ScopedMountNode node(new MountNodeHttp(this, url, cache_content_));
+ ScopedNode node(new HttpFsNode(this, url, cache_content_));
Error error = node->Init(0);
if (error)
return error;
@@ -63,8 +64,7 @@ Error MountHttp::Access(const Path& path, int a_mode) {
return 0;
}
-Error MountHttp::Open(const Path& path, int open_flags,
- ScopedMountNode* out_node) {
+Error HttpFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
out_node->reset(NULL);
assert(url_root_.empty() || url_root_[url_root_.length() - 1] == '/');
@@ -76,7 +76,7 @@ Error MountHttp::Open(const Path& path, int open_flags,
// If we can't find the node in the cache, create it
std::string url = MakeUrl(path);
- ScopedMountNode node(new MountNodeHttp(this, url, cache_content_));
+ ScopedNode node(new HttpFsNode(this, url, cache_content_));
Error error = node->Init(open_flags);
if (error)
return error;
@@ -85,7 +85,7 @@ Error MountHttp::Open(const Path& path, int open_flags,
if (error)
return error;
- ScopedMountNode parent;
+ ScopedNode parent;
error = FindOrCreateDir(path.Parent(), &parent);
if (error)
return error;
@@ -99,7 +99,7 @@ Error MountHttp::Open(const Path& path, int open_flags,
return 0;
}
-Error MountHttp::Unlink(const Path& path) {
+Error HttpFs::Unlink(const Path& path) {
NodeMap_t::iterator iter = node_cache_.find(path.Join());
if (iter == node_cache_.end())
return ENOENT;
@@ -110,7 +110,7 @@ Error MountHttp::Unlink(const Path& path) {
return EACCES;
}
-Error MountHttp::Mkdir(const Path& path, int permissions) {
+Error HttpFs::Mkdir(const Path& path, int permissions) {
NodeMap_t::iterator iter = node_cache_.find(path.Join());
if (iter != node_cache_.end()) {
if (iter->second->IsaDir())
@@ -119,7 +119,7 @@ Error MountHttp::Mkdir(const Path& path, int permissions) {
return EACCES;
}
-Error MountHttp::Rmdir(const Path& path) {
+Error HttpFs::Rmdir(const Path& path) {
NodeMap_t::iterator iter = node_cache_.find(path.Join());
if (iter == node_cache_.end())
return ENOENT;
@@ -130,7 +130,7 @@ Error MountHttp::Rmdir(const Path& path) {
return EACCES;
}
-Error MountHttp::Remove(const Path& path) {
+Error HttpFs::Remove(const Path& path) {
NodeMap_t::iterator iter = node_cache_.find(path.Join());
if (iter == node_cache_.end())
return ENOENT;
@@ -138,7 +138,7 @@ Error MountHttp::Remove(const Path& path) {
return EACCES;
}
-Error MountHttp::Rename(const Path& path, const Path& newpath) {
+Error HttpFs::Rename(const Path& path, const Path& newpath) {
NodeMap_t::iterator iter = node_cache_.find(path.Join());
if (iter == node_cache_.end())
return ENOENT;
@@ -146,9 +146,9 @@ Error MountHttp::Rename(const Path& path, const Path& newpath) {
return EACCES;
}
-PP_Resource MountHttp::MakeUrlRequestInfo(const std::string& url,
- const char* method,
- StringMap_t* additional_headers) {
+PP_Resource HttpFs::MakeUrlRequestInfo(const std::string& url,
+ const char* method,
+ StringMap_t* additional_headers) {
URLRequestInfoInterface* interface = ppapi_->GetURLRequestInfoInterface();
VarInterface* var_interface = ppapi_->GetVarInterface();
@@ -169,8 +169,8 @@ PP_Resource MountHttp::MakeUrlRequestInfo(const std::string& url,
PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS,
PP_MakeBool(allow_credentials_ ? PP_TRUE : PP_FALSE));
- // Merge the mount headers with the request headers. If the field is already
- // set it |additional_headers|, don't use the one from headers_.
+ // Merge the filesystem headers with the request headers. If the field is
+ // already set it |additional_headers|, don't use the one from headers_.
for (StringMap_t::iterator iter = headers_.begin(); iter != headers_.end();
++iter) {
const std::string& key = NormalizeHeaderKey(iter->first);
@@ -195,18 +195,18 @@ PP_Resource MountHttp::MakeUrlRequestInfo(const std::string& url,
return request_info;
}
-MountHttp::MountHttp()
+HttpFs::HttpFs()
: allow_cors_(false),
allow_credentials_(false),
cache_stat_(true),
cache_content_(true) {}
-Error MountHttp::Init(const MountInitArgs& args) {
- Error error = Mount::Init(args);
+Error HttpFs::Init(const FsInitArgs& args) {
+ Error error = Filesystem::Init(args);
if (error)
return error;
- // Parse mount args.
+ // Parse filesystem args.
for (StringMap_t::const_iterator iter = args.string_map.begin();
iter != args.string_map.end();
++iter) {
@@ -247,10 +247,9 @@ Error MountHttp::Init(const MountInitArgs& args) {
return 0;
}
-void MountHttp::Destroy() {}
+void HttpFs::Destroy() {}
-Error MountHttp::FindOrCreateDir(const Path& path,
- ScopedMountNode* out_node) {
+Error HttpFs::FindOrCreateDir(const Path& path, ScopedNode* out_node) {
out_node->reset(NULL);
std::string strpath = path.Join();
NodeMap_t::iterator iter = node_cache_.find(strpath);
@@ -260,14 +259,14 @@ Error MountHttp::FindOrCreateDir(const Path& path,
}
// If the node does not exist, create it.
- ScopedMountNode node(new MountNodeDir(this));
+ ScopedNode node(new DirNode(this));
Error error = node->Init(0);
if (error)
return error;
// If not the root node, find the parent node and add it to the parent
if (!path.Top()) {
- ScopedMountNode parent;
+ ScopedNode parent;
error = FindOrCreateDir(path.Parent(), &parent);
if (error)
return error;
@@ -283,7 +282,7 @@ Error MountHttp::FindOrCreateDir(const Path& path,
return 0;
}
-Error MountHttp::ParseManifest(const char* text) {
+Error HttpFs::ParseManifest(const char* text) {
std::vector<std::string> lines;
sdk_util::SplitString(text, '\n', &lines);
@@ -294,7 +293,8 @@ Error MountHttp::ParseManifest(const char* text) {
// Remove empty words (due to multiple consecutive spaces).
std::vector<std::string> non_empty_words;
for (std::vector<std::string>::const_iterator it = words.begin();
- it != words.end(); ++it) {
+ it != words.end();
+ ++it) {
if (!it->empty())
non_empty_words.push_back(*it);
}
@@ -318,7 +318,9 @@ Error MountHttp::ParseManifest(const char* text) {
mode = S_IFCHR;
break;
default:
- fprintf(stderr, "Unable to parse type %s for %s.\n", modestr.c_str(),
+ fprintf(stderr,
+ "Unable to parse type %s for %s.\n",
+ modestr.c_str(),
name.c_str());
return EINVAL;
}
@@ -330,7 +332,9 @@ Error MountHttp::ParseManifest(const char* text) {
mode |= S_IRUSR | S_IRGRP | S_IROTH;
break;
default:
- fprintf(stderr, "Unable to parse read %s for %s.\n", modestr.c_str(),
+ fprintf(stderr,
+ "Unable to parse read %s for %s.\n",
+ modestr.c_str(),
name.c_str());
return EINVAL;
}
@@ -342,7 +346,9 @@ Error MountHttp::ParseManifest(const char* text) {
mode |= S_IWUSR | S_IWGRP | S_IWOTH;
break;
default:
- fprintf(stderr, "Unable to parse write %s for %s.\n", modestr.c_str(),
+ fprintf(stderr,
+ "Unable to parse write %s for %s.\n",
+ modestr.c_str(),
name.c_str());
return EINVAL;
}
@@ -350,16 +356,16 @@ Error MountHttp::ParseManifest(const char* text) {
Path path(name);
std::string url = MakeUrl(path);
- MountNodeHttp* http_node = new MountNodeHttp(this, url, cache_content_);
+ HttpFsNode* http_node = new HttpFsNode(this, url, cache_content_);
http_node->SetMode(mode);
- ScopedMountNode node(http_node);
+ ScopedNode node(http_node);
Error error = node->Init(0);
if (error)
return error;
http_node->SetCachedSize(atoi(lenstr.c_str()));
- ScopedMountNode dir_node;
+ ScopedNode dir_node;
error = FindOrCreateDir(path.Parent(), &dir_node);
if (error)
return error;
@@ -376,10 +382,10 @@ Error MountHttp::ParseManifest(const char* text) {
return 0;
}
-Error MountHttp::LoadManifest(const std::string& manifest_name,
- char** out_manifest) {
+Error HttpFs::LoadManifest(const std::string& manifest_name,
+ char** out_manifest) {
Path manifest_path(manifest_name);
- ScopedMountNode manifest_node;
+ ScopedNode manifest_node;
*out_manifest = NULL;
int error = Open(manifest_path, O_RDONLY, &manifest_node);
@@ -402,7 +408,7 @@ Error MountHttp::LoadManifest(const std::string& manifest_name,
return 0;
}
-std::string MountHttp::MakeUrl(const Path& path) {
+std::string HttpFs::MakeUrl(const Path& path) {
return url_root_ +
(path.IsAbsolute() ? path.Range(1, path.Size()) : path.Join());
}
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_http.h b/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.h
index 145140d..22d2051 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_http.h
+++ b/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.h
@@ -2,25 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
-#ifndef LIBRARIES_NACL_IO_MOUNT_HTTP_H_
-#define LIBRARIES_NACL_IO_MOUNT_HTTP_H_
+#ifndef LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_H_
+#define LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_H_
#include <string>
-#include "nacl_io/mount.h"
+#include "nacl_io/filesystem.h"
#include "nacl_io/pepper_interface.h"
-#include "nacl_io/typed_mount_factory.h"
+#include "nacl_io/typed_fs_factory.h"
namespace nacl_io {
std::string NormalizeHeaderKey(const std::string& s);
-class MountHttp : public Mount {
+class HttpFs : public Filesystem {
public:
- typedef std::map<std::string, ScopedMountNode> NodeMap_t;
+ typedef std::map<std::string, ScopedNode> NodeMap_t;
virtual Error Access(const Path& path, int a_mode);
- virtual Error Open(const Path& path, int mode, ScopedMountNode* out_node);
+ virtual Error Open(const Path& path, int mode, ScopedNode* out_node);
virtual Error Unlink(const Path& path);
virtual Error Mkdir(const Path& path, int permissions);
virtual Error Rmdir(const Path& path);
@@ -32,13 +31,13 @@ class MountHttp : public Mount {
StringMap_t* additional_headers);
protected:
- MountHttp();
+ HttpFs();
- virtual Error Init(const MountInitArgs& args);
+ virtual Error Init(const FsInitArgs& args);
virtual void Destroy();
- Error FindOrCreateDir(const Path& path, ScopedMountNode* out_node);
+ Error FindOrCreateDir(const Path& path, ScopedNode* out_node);
Error LoadManifest(const std::string& path, char** out_manifest);
- Error ParseManifest(const char *text);
+ Error ParseManifest(const char* text);
NodeMap_t* GetNodeCacheForTesting() { return &node_cache_; }
@@ -55,10 +54,10 @@ class MountHttp : public Mount {
bool cache_stat_;
bool cache_content_;
- friend class TypedMountFactory<MountHttp>;
- friend class MountNodeHttp;
+ friend class TypedFsFactory<HttpFs>;
+ friend class HttpFsNode;
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_MOUNT_HTTP_H_
+#endif // LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_http.cc b/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.cc
index 66b63c7..511bc5c 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_http.cc
+++ b/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/mount_node_http.h"
+#include "nacl_io/httpfs/http_fs_node.h"
#include <assert.h>
#include <errno.h>
@@ -11,8 +11,8 @@
#include <ppapi/c/pp_errors.h>
+#include "nacl_io/httpfs/http_fs.h"
#include "nacl_io/kernel_handle.h"
-#include "nacl_io/mount_http.h"
#include "nacl_io/osinttypes.h"
#if defined(WIN32)
@@ -147,30 +147,30 @@ int HTTPStatusCodeToErrno(int status_code) {
} // namespace
-void MountNodeHttp::SetCachedSize(off_t size) {
+void HttpFsNode::SetCachedSize(off_t size) {
has_cached_size_ = true;
stat_.st_size = size;
}
-Error MountNodeHttp::FSync() { return EACCES; }
+Error HttpFsNode::FSync() { return EACCES; }
-Error MountNodeHttp::GetDents(size_t offs,
- struct dirent* pdir,
- size_t count,
- int* out_bytes) {
+Error HttpFsNode::GetDents(size_t offs,
+ struct dirent* pdir,
+ size_t count,
+ int* out_bytes) {
*out_bytes = 0;
return EACCES;
}
-Error MountNodeHttp::GetStat(struct stat* stat) {
+Error HttpFsNode::GetStat(struct stat* stat) {
AUTO_LOCK(node_lock_);
return GetStat_Locked(stat);
}
-Error MountNodeHttp::Read(const HandleAttr& attr,
- void* buf,
- size_t count,
- int* out_bytes) {
+Error HttpFsNode::Read(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes) {
*out_bytes = 0;
AUTO_LOCK(node_lock_);
@@ -187,18 +187,18 @@ Error MountNodeHttp::Read(const HandleAttr& attr,
return DownloadPartial(attr, buf, count, out_bytes);
}
-Error MountNodeHttp::FTruncate(off_t size) { return EACCES; }
+Error HttpFsNode::FTruncate(off_t size) { return EACCES; }
-Error MountNodeHttp::Write(const HandleAttr& attr,
- const void* buf,
- size_t count,
- int* out_bytes) {
+Error HttpFsNode::Write(const HandleAttr& attr,
+ const void* buf,
+ size_t count,
+ int* out_bytes) {
// TODO(binji): support POST?
*out_bytes = 0;
return EACCES;
}
-Error MountNodeHttp::GetSize(size_t* out_size) {
+Error HttpFsNode::GetSize(size_t* out_size) {
*out_size = 0;
// TODO(binji): This value should be cached properly; i.e. obey the caching
@@ -213,25 +213,25 @@ Error MountNodeHttp::GetSize(size_t* out_size) {
return 0;
}
-MountNodeHttp::MountNodeHttp(Mount* mount,
- const std::string& url,
- bool cache_content)
- : MountNode(mount),
+HttpFsNode::HttpFsNode(Filesystem* filesystem,
+ const std::string& url,
+ bool cache_content)
+ : Node(filesystem),
url_(url),
cache_content_(cache_content),
has_cached_size_(false) {}
-void MountNodeHttp::SetMode(int mode) { stat_.st_mode = mode; }
+void HttpFsNode::SetMode(int mode) { stat_.st_mode = mode; }
-Error MountNodeHttp::GetStat_Locked(struct stat* stat) {
+Error HttpFsNode::GetStat_Locked(struct stat* stat) {
// Assume we need to 'HEAD' if we do not know the size, otherwise, assume
// that the information is constant. We can add a timeout if needed.
- MountHttp* mount = static_cast<MountHttp*>(mount_);
- if (!has_cached_size_ || !mount->cache_stat_) {
+ HttpFs* filesystem = static_cast<HttpFs*>(filesystem_);
+ if (!has_cached_size_ || !filesystem->cache_stat_) {
StringMap_t headers;
- ScopedResource loader(mount_->ppapi());
- ScopedResource request(mount_->ppapi());
- ScopedResource response(mount_->ppapi());
+ ScopedResource loader(filesystem_->ppapi());
+ ScopedResource request(filesystem_->ppapi());
+ ScopedResource response(filesystem_->ppapi());
int32_t statuscode;
StringMap_t response_headers;
Error error = OpenUrl("HEAD",
@@ -280,21 +280,21 @@ Error MountNodeHttp::GetStat_Locked(struct stat* stat) {
return 0;
}
-Error MountNodeHttp::OpenUrl(const char* method,
- StringMap_t* request_headers,
- ScopedResource* out_loader,
- ScopedResource* out_request,
- ScopedResource* out_response,
- int32_t* out_statuscode,
- StringMap_t* out_response_headers) {
+Error HttpFsNode::OpenUrl(const char* method,
+ StringMap_t* request_headers,
+ ScopedResource* out_loader,
+ ScopedResource* out_request,
+ ScopedResource* out_response,
+ int32_t* out_statuscode,
+ StringMap_t* out_response_headers) {
// Clear all out parameters.
*out_statuscode = 0;
out_response_headers->clear();
// Assume lock_ is already held.
- PepperInterface* ppapi = mount_->ppapi();
+ PepperInterface* ppapi = filesystem_->ppapi();
- MountHttp* mount_http = static_cast<MountHttp*>(mount_);
+ HttpFs* mount_http = static_cast<HttpFs*>(filesystem_);
out_request->Reset(
mount_http->MakeUrlRequestInfo(url_, method, request_headers));
if (!out_request->pp_resource())
@@ -350,11 +350,11 @@ Error MountNodeHttp::OpenUrl(const char* method,
return 0;
}
-Error MountNodeHttp::DownloadToCache() {
+Error HttpFsNode::DownloadToCache() {
StringMap_t headers;
- ScopedResource loader(mount_->ppapi());
- ScopedResource request(mount_->ppapi());
- ScopedResource response(mount_->ppapi());
+ ScopedResource loader(filesystem_->ppapi());
+ ScopedResource request(filesystem_->ppapi());
+ ScopedResource response(filesystem_->ppapi());
int32_t statuscode;
StringMap_t response_headers;
Error error = OpenUrl("GET",
@@ -390,10 +390,10 @@ Error MountNodeHttp::DownloadToCache() {
return 0;
}
-Error MountNodeHttp::ReadPartialFromCache(const HandleAttr& attr,
- void* buf,
- int count,
- int* out_bytes) {
+Error HttpFsNode::ReadPartialFromCache(const HandleAttr& attr,
+ void* buf,
+ int count,
+ int* out_bytes) {
*out_bytes = 0;
size_t size = cached_data_.size();
@@ -408,10 +408,10 @@ Error MountNodeHttp::ReadPartialFromCache(const HandleAttr& attr,
return 0;
}
-Error MountNodeHttp::DownloadPartial(const HandleAttr& attr,
- void* buf,
- size_t count,
- int* out_bytes) {
+Error HttpFsNode::DownloadPartial(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes) {
*out_bytes = 0;
StringMap_t headers;
@@ -425,9 +425,9 @@ Error MountNodeHttp::DownloadPartial(const HandleAttr& attr,
attr.offs + count - 1);
headers["Range"] = buffer;
- ScopedResource loader(mount_->ppapi());
- ScopedResource request(mount_->ppapi());
- ScopedResource response(mount_->ppapi());
+ ScopedResource loader(filesystem_->ppapi());
+ ScopedResource request(filesystem_->ppapi());
+ ScopedResource response(filesystem_->ppapi());
int32_t statuscode;
StringMap_t response_headers;
Error error = OpenUrl("GET",
@@ -501,11 +501,11 @@ Error MountNodeHttp::DownloadPartial(const HandleAttr& attr,
return ReadResponseToBuffer(loader, buf, count, out_bytes);
}
-Error MountNodeHttp::DownloadToTemp(int* out_bytes) {
+Error HttpFsNode::DownloadToTemp(int* out_bytes) {
StringMap_t headers;
- ScopedResource loader(mount_->ppapi());
- ScopedResource request(mount_->ppapi());
- ScopedResource response(mount_->ppapi());
+ ScopedResource loader(filesystem_->ppapi());
+ ScopedResource request(filesystem_->ppapi());
+ ScopedResource response(filesystem_->ppapi());
int32_t statuscode;
StringMap_t response_headers;
Error error = OpenUrl("GET",
@@ -527,8 +527,8 @@ Error MountNodeHttp::DownloadToTemp(int* out_bytes) {
return ReadEntireResponseToTemp(loader, out_bytes);
}
-Error MountNodeHttp::ReadEntireResponseToTemp(const ScopedResource& loader,
- int* out_bytes) {
+Error HttpFsNode::ReadEntireResponseToTemp(const ScopedResource& loader,
+ int* out_bytes) {
*out_bytes = 0;
const int kBytesToRead = MAX_READ_BUFFER_SIZE;
@@ -548,8 +548,8 @@ Error MountNodeHttp::ReadEntireResponseToTemp(const ScopedResource& loader,
}
}
-Error MountNodeHttp::ReadEntireResponseToCache(const ScopedResource& loader,
- int* out_bytes) {
+Error HttpFsNode::ReadEntireResponseToCache(const ScopedResource& loader,
+ int* out_bytes) {
*out_bytes = 0;
const int kBytesToRead = MAX_READ_BUFFER_SIZE;
@@ -574,9 +574,9 @@ Error MountNodeHttp::ReadEntireResponseToCache(const ScopedResource& loader,
}
}
-Error MountNodeHttp::ReadResponseToTemp(const ScopedResource& loader,
- int count,
- int* out_bytes) {
+Error HttpFsNode::ReadResponseToTemp(const ScopedResource& loader,
+ int count,
+ int* out_bytes) {
*out_bytes = 0;
if (buffer_.size() < static_cast<size_t>(count))
@@ -602,13 +602,13 @@ Error MountNodeHttp::ReadResponseToTemp(const ScopedResource& loader,
return 0;
}
-Error MountNodeHttp::ReadResponseToBuffer(const ScopedResource& loader,
- void* buf,
- int count,
- int* out_bytes) {
+Error HttpFsNode::ReadResponseToBuffer(const ScopedResource& loader,
+ void* buf,
+ int count,
+ int* out_bytes) {
*out_bytes = 0;
- PepperInterface* ppapi = mount_->ppapi();
+ PepperInterface* ppapi = filesystem_->ppapi();
URLLoaderInterface* loader_interface = ppapi->GetURLLoaderInterface();
char* out_buffer = static_cast<char*>(buf);
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_http.h b/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.h
index 9ad2ab2..d864b2c 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_http.h
+++ b/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.h
@@ -2,22 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_HTTP_H_
-#define LIBRARIES_NACL_IO_MOUNT_NODE_HTTP_H_
+#ifndef LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_NODE_H_
+#define LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_NODE_H_
#include <map>
#include <string>
#include <vector>
#include "nacl_io/error.h"
-#include "nacl_io/mount_node.h"
+#include "nacl_io/node.h"
#include "nacl_io/pepper_interface.h"
namespace nacl_io {
typedef std::map<std::string, std::string> StringMap_t;
-class MountNodeHttp : public MountNode {
+class HttpFsNode : public Node {
public:
virtual Error FSync();
virtual Error GetDents(size_t offs,
@@ -40,7 +40,9 @@ class MountNodeHttp : public MountNode {
void SetMode(int mode);
protected:
- MountNodeHttp(Mount* mount, const std::string& url, bool cache_content);
+ HttpFsNode(Filesystem* filesystem,
+ const std::string& url,
+ bool cache_content);
private:
Error GetStat_Locked(struct stat* stat);
@@ -89,9 +91,9 @@ class MountNodeHttp : public MountNode {
bool has_cached_size_;
std::vector<char> cached_data_;
- friend class MountHttp;
+ friend class HttpFs;
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_MOUNT_NODE_HTTP_H_
+#endif // LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_NODE_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc b/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc
index 5736a3a..18b5c5a 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc
@@ -7,10 +7,10 @@
#include <errno.h>
#include <pthread.h>
-#include "nacl_io/mount.h"
-#include "nacl_io/mount_node.h"
-#include "nacl_io/mount_node_socket.h"
+#include "nacl_io/filesystem.h"
+#include "nacl_io/node.h"
#include "nacl_io/osunistd.h"
+#include "nacl_io/socket/socket_node.h"
#include "sdk_util/auto_lock.h"
@@ -18,21 +18,21 @@ namespace nacl_io {
// It is only legal to construct a handle while the kernel lock is held.
KernelHandle::KernelHandle()
- : mount_(NULL), node_(NULL) {}
+ : filesystem_(NULL), node_(NULL) {}
-KernelHandle::KernelHandle(const ScopedMount& mnt, const ScopedMountNode& node)
- : mount_(mnt), node_(node) {}
+KernelHandle::KernelHandle(const ScopedFilesystem& fs, const ScopedNode& node)
+ : filesystem_(fs), node_(node) {}
KernelHandle::~KernelHandle() {
- // Force release order for cases where mount_ is not ref'd by mounting.
+ // Force release order for cases where filesystem_ is not ref'd by mounting.
node_.reset(NULL);
- mount_.reset(NULL);
+ filesystem_.reset(NULL);
}
-// Returns the MountNodeSocket* if this node is a socket.
-MountNodeSocket* KernelHandle::socket_node() {
+// Returns the SocketNode* if this node is a socket.
+SocketNode* KernelHandle::socket_node() {
if (node_.get() && node_->IsaSock())
- return reinterpret_cast<MountNodeSocket*>(node_.get());
+ return reinterpret_cast<SocketNode*>(node_.get());
return NULL;
}
@@ -156,7 +156,7 @@ Error KernelHandle::VFcntl(int request, int* result, va_list args) {
Error KernelHandle::Accept(PP_Resource* new_sock, struct sockaddr* addr,
socklen_t* len) {
- MountNodeSocket* sock = socket_node();
+ SocketNode* sock = socket_node();
if (!sock)
return ENOTSOCK;
@@ -165,7 +165,7 @@ Error KernelHandle::Accept(PP_Resource* new_sock, struct sockaddr* addr,
}
Error KernelHandle::Connect(const struct sockaddr* addr, socklen_t len) {
- MountNodeSocket* sock = socket_node();
+ SocketNode* sock = socket_node();
if (!sock)
return ENOTSOCK;
@@ -174,7 +174,7 @@ Error KernelHandle::Connect(const struct sockaddr* addr, socklen_t len) {
}
Error KernelHandle::Recv(void* buf, size_t len, int flags, int* out_len) {
- MountNodeSocket* sock = socket_node();
+ SocketNode* sock = socket_node();
if (!sock)
return ENOTSOCK;
if (OpenMode() == O_WRONLY)
@@ -190,7 +190,7 @@ Error KernelHandle::RecvFrom(void* buf,
struct sockaddr* src_addr,
socklen_t* addrlen,
int* out_len) {
- MountNodeSocket* sock = socket_node();
+ SocketNode* sock = socket_node();
if (!sock)
return ENOTSOCK;
if (OpenMode() == O_WRONLY)
@@ -205,7 +205,7 @@ Error KernelHandle::Send(const void* buf,
size_t len,
int flags,
int* out_len) {
- MountNodeSocket* sock = socket_node();
+ SocketNode* sock = socket_node();
if (!sock)
return ENOTSOCK;
if (OpenMode() == O_RDONLY)
@@ -221,7 +221,7 @@ Error KernelHandle::SendTo(const void* buf,
const struct sockaddr* dest_addr,
socklen_t addrlen,
int* out_len) {
- MountNodeSocket* sock = socket_node();
+ SocketNode* sock = socket_node();
if (!sock)
return ENOTSOCK;
if (OpenMode() == O_RDONLY)
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_handle.h b/native_client_sdk/src/libraries/nacl_io/kernel_handle.h
index d445f40..5d62117 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_handle.h
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_handle.h
@@ -10,8 +10,8 @@
#include <ppapi/c/pp_resource.h>
#include "nacl_io/error.h"
-#include "nacl_io/mount.h"
-#include "nacl_io/mount_node.h"
+#include "nacl_io/filesystem.h"
+#include "nacl_io/node.h"
#include "nacl_io/ossocket.h"
#include "nacl_io/ostypes.h"
@@ -22,9 +22,9 @@
namespace nacl_io {
-class MountNodeSocket;
+class SocketNode;
-// HandleAttr struct is passed the MountNode in calls
+// HandleAttr struct is passed the Node in calls
// to Read and Write. It contains handle specific state
// such as the file offset and the open flags.
struct HandleAttr {
@@ -36,13 +36,13 @@ struct HandleAttr {
};
// KernelHandle provides a reference counted container for the open
-// file information, such as it's mount, node, access type and offset.
+// file information, such as it's filesystem, node, access type and offset.
// KernelHandle can only be referenced when the KernelProxy lock is held.
class KernelHandle : public sdk_util::RefObject {
public:
KernelHandle();
- KernelHandle(const ScopedMount& mnt, const ScopedMountNode& node);
+ KernelHandle(const ScopedFilesystem& fs, const ScopedNode& node);
~KernelHandle();
Error Init(int open_flags);
@@ -71,20 +71,20 @@ class KernelHandle : public sdk_util::RefObject {
int* out_len);
Error Write(const void* buf, size_t nbytes, int* bytes_written);
- const ScopedMountNode& node() { return node_; }
- const ScopedMount& mount() { return mount_; }
+ const ScopedNode& node() { return node_; }
+ const ScopedFilesystem& filesystem() { return filesystem_; }
const HandleAttr& Attr() { return handle_attr_; }
int OpenMode() { return handle_attr_.flags & 3; }
private:
- // Returns the MountNodeSocket* if this node is a socket otherwise returns
+ // Returns the SocketNode* if this node is a socket otherwise returns
// NULL.
- MountNodeSocket* socket_node();
+ SocketNode* socket_node();
- ScopedMount mount_;
- ScopedMountNode node_;
+ ScopedFilesystem filesystem_;
+ ScopedNode node_;
sdk_util::SimpleLock handle_lock_;
HandleAttr handle_attr_;
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc b/native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc
index b5f894c..71e8edf 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc
@@ -50,13 +50,13 @@ void ki_init_ppapi(void* kp,
s_kp->Init(ppapi);
}
-int ki_register_mount_type(const char* mount_type,
+int ki_register_fs_type(const char* fs_type,
struct fuse_operations* fuse_ops) {
- return s_kp->RegisterMountType(mount_type, fuse_ops);
+ return s_kp->RegisterFsType(fs_type, fuse_ops);
}
-int ki_unregister_mount_type(const char* mount_type) {
- return s_kp->UnregisterMountType(mount_type);
+int ki_unregister_fs_type(const char* fs_type) {
+ return s_kp->UnregisterFsType(fs_type);
}
int ki_is_initialized() {
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_intercept.h b/native_client_sdk/src/libraries/nacl_io/kernel_intercept.h
index b135213..3e3479a 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_intercept.h
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_intercept.h
@@ -33,9 +33,9 @@ void ki_init(void* kernel_proxy);
void ki_init_ppapi(void* kernel_proxy,
PP_Instance instance,
PPB_GetInterface get_browser_interface);
-int ki_register_mount_type(const char* mount_type,
+int ki_register_fs_type(const char* fs_type,
struct fuse_operations* fuse_ops);
-int ki_unregister_mount_type(const char* mount_type);
+int ki_unregister_fs_type(const char* fs_type);
int ki_is_initialized();
void ki_uninit();
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_object.cc b/native_client_sdk/src/libraries/nacl_io/kernel_object.cc
index 566bf90..fccc5c85 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_object.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_object.cc
@@ -14,9 +14,9 @@
#include <string>
#include <vector>
+#include "nacl_io/filesystem.h"
#include "nacl_io/kernel_handle.h"
-#include "nacl_io/mount.h"
-#include "nacl_io/mount_node.h"
+#include "nacl_io/node.h"
#include "sdk_util/auto_lock.h"
#include "sdk_util/ref_object.h"
@@ -24,61 +24,59 @@
namespace nacl_io {
-KernelObject::KernelObject() {
- cwd_ = "/";
-}
+KernelObject::KernelObject() { cwd_ = "/"; }
KernelObject::~KernelObject() {};
-Error KernelObject::AttachMountAtPath(const ScopedMount& mnt,
- const std::string& path) {
+Error KernelObject::AttachFsAtPath(const ScopedFilesystem& fs,
+ const std::string& path) {
std::string abs_path = GetAbsParts(path).Join();
- AUTO_LOCK(mount_lock_);
- if (mounts_.find(abs_path) != mounts_.end())
+ AUTO_LOCK(fs_lock_);
+ if (filesystems_.find(abs_path) != filesystems_.end())
return EBUSY;
- mounts_[abs_path] = mnt;
+ filesystems_[abs_path] = fs;
return 0;
}
-Error KernelObject::DetachMountAtPath(const std::string& path) {
+Error KernelObject::DetachFsAtPath(const std::string& path) {
std::string abs_path = GetAbsParts(path).Join();
- AUTO_LOCK(mount_lock_);
- MountMap_t::iterator it = mounts_.find(abs_path);
- if (mounts_.end() == it)
+ AUTO_LOCK(fs_lock_);
+ FsMap_t::iterator it = filesystems_.find(abs_path);
+ if (filesystems_.end() == it)
return EINVAL;
// It is only legal to unmount if there are no open references
if (it->second->RefCount() != 1)
return EBUSY;
- mounts_.erase(it);
+ filesystems_.erase(it);
return 0;
}
-// Uses longest prefix to find the mount for the give path, then
-// acquires the mount and returns it with a relative path.
-Error KernelObject::AcquireMountAndRelPath(const std::string& path,
- ScopedMount* out_mount,
- Path* rel_parts) {
+// Uses longest prefix to find the filesystem for the give path, then
+// acquires the filesystem and returns it with a relative path.
+Error KernelObject::AcquireFsAndRelPath(const std::string& path,
+ ScopedFilesystem* out_fs,
+ Path* rel_parts) {
Path abs_parts = GetAbsParts(path);
- out_mount->reset(NULL);
+ out_fs->reset(NULL);
*rel_parts = Path();
- AUTO_LOCK(mount_lock_);
+ AUTO_LOCK(fs_lock_);
// Find longest prefix
size_t max = abs_parts.Size();
for (size_t len = 0; len < abs_parts.Size(); len++) {
- MountMap_t::iterator it = mounts_.find(abs_parts.Range(0, max - len));
- if (it != mounts_.end()) {
+ FsMap_t::iterator it = filesystems_.find(abs_parts.Range(0, max - len));
+ if (it != filesystems_.end()) {
rel_parts->Set("/");
rel_parts->Append(abs_parts.Range(max - len, max));
- *out_mount = it->second;
+ *out_fs = it->second;
return 0;
}
}
@@ -86,20 +84,20 @@ Error KernelObject::AcquireMountAndRelPath(const std::string& path,
return ENOTDIR;
}
-// Given a path, acquire the associated mount and node, creating the
+// Given a path, acquire the associated filesystem and node, creating the
// node if needed based on the provided flags.
-Error KernelObject::AcquireMountAndNode(const std::string& path,
- int oflags,
- ScopedMount* out_mount,
- ScopedMountNode* out_node) {
+Error KernelObject::AcquireFsAndNode(const std::string& path,
+ int oflags,
+ ScopedFilesystem* out_fs,
+ ScopedNode* out_node) {
Path rel_parts;
- out_mount->reset(NULL);
+ out_fs->reset(NULL);
out_node->reset(NULL);
- Error error = AcquireMountAndRelPath(path, out_mount, &rel_parts);
+ Error error = AcquireFsAndRelPath(path, out_fs, &rel_parts);
if (error)
return error;
- error = (*out_mount)->Open(rel_parts, oflags, out_node);
+ error = (*out_fs)->Open(rel_parts, oflags, out_node);
if (error)
return error;
@@ -130,10 +128,10 @@ std::string KernelObject::GetCWD() {
Error KernelObject::SetCWD(const std::string& path) {
std::string abs_path = GetAbsParts(path).Join();
- ScopedMount mnt;
- ScopedMountNode node;
+ ScopedFilesystem fs;
+ ScopedNode node;
- Error error = AcquireMountAndNode(abs_path, O_RDONLY, &mnt, &node);
+ Error error = AcquireFsAndNode(abs_path, O_RDONLY, &fs, &node);
if (error)
return error;
@@ -175,7 +173,8 @@ Error KernelObject::AcquireHandle(int fd, ScopedKernelHandle* out_handle) {
return EBADF;
*out_handle = handle_map_[fd].handle;
- if (out_handle) return 0;
+ if (out_handle)
+ return 0;
return EBADF;
}
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_object.h b/native_client_sdk/src/libraries/nacl_io/kernel_object.h
index df6dba2..1bf714a 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_object.h
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_object.h
@@ -12,9 +12,9 @@
#include <vector>
#include "nacl_io/error.h"
+#include "nacl_io/filesystem.h"
#include "nacl_io/kernel_handle.h"
-#include "nacl_io/mount.h"
-#include "nacl_io/mount_node.h"
+#include "nacl_io/node.h"
#include "nacl_io/path.h"
#include "sdk_util/macros.h"
@@ -37,31 +37,31 @@ class KernelObject {
int flags;
};
typedef std::vector<Descriptor_t> HandleMap_t;
- typedef std::map<std::string, ScopedMount> MountMap_t;
+ typedef std::map<std::string, ScopedFilesystem> FsMap_t;
KernelObject();
virtual ~KernelObject();
- // Attach the given Mount object at the specified path.
- Error AttachMountAtPath(const ScopedMount& mnt, const std::string& path);
+ // Attach the given Filesystem object at the specified path.
+ Error AttachFsAtPath(const ScopedFilesystem& fs, const std::string& path);
- // Unmap the Mount object from the specified path and release it.
- Error DetachMountAtPath(const std::string& path);
+ // Unmap the Filesystem object from the specified path and release it.
+ Error DetachFsAtPath(const std::string& path);
- // Find the mount for the given path, and acquires it and return a
- // path relative to the mount.
- // Assumes |out_mount| and |rel_path| are non-NULL.
- Error AcquireMountAndRelPath(const std::string& path,
- ScopedMount* out_mount,
+ // Find the filesystem for the given path, and acquires it and return a
+ // path relative to the filesystem.
+ // Assumes |out_fs| and |rel_path| are non-NULL.
+ Error AcquireFsAndRelPath(const std::string& path,
+ ScopedFilesystem* out_fs,
Path* rel_path);
- // Find the mount and node for the given path, acquiring/creating it as
+ // Find the filesystem and node for the given path, acquiring/creating it as
// specified by the |oflags|.
- // Assumes |out_mount| and |out_node| are non-NULL.
- Error AcquireMountAndNode(const std::string& path,
+ // Assumes |out_fs| and |out_node| are non-NULL.
+ Error AcquireFsAndNode(const std::string& path,
int oflags,
- ScopedMount* out_mount,
- ScopedMountNode* out_node);
+ ScopedFilesystem* out_fs,
+ ScopedNode* out_node);
// Get FD-specific flags (currently only FD_CLOEXEC is supported).
Error GetFDFlags(int fd, int* out_flags);
@@ -73,7 +73,7 @@ class KernelObject {
Error AcquireHandle(int fd, ScopedKernelHandle* out_handle);
// Allocate a new fd and assign the handle to it, while
- // ref counting the handle and associated mount.
+ // ref counting the handle and associated filesystem.
// Assumes |handle| is non-NULL;
int AllocateFD(const ScopedKernelHandle& handle);
@@ -88,17 +88,17 @@ class KernelObject {
// Returns parts of the absolute path for the given relative path
Path GetAbsParts(const std::string& path);
-private:
+ private:
std::string cwd_;
std::vector<int> free_fds_;
HandleMap_t handle_map_;
- MountMap_t mounts_;
+ FsMap_t filesystems_;
// Lock to protect free_fds_ and handle_map_.
sdk_util::SimpleLock handle_lock_;
- // Lock to protect handle_map_.
- sdk_util::SimpleLock mount_lock_;
+ // Lock to protect filesystems_.
+ sdk_util::SimpleLock fs_lock_;
// Lock to protect cwd_.
sdk_util::SimpleLock cwd_lock_;
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
index b18f2ad..0ca2c39 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
@@ -18,27 +18,27 @@
#include <iterator>
#include <string>
-#include "nacl_io/fuse_mount_factory.h"
+#include "nacl_io/devfs/dev_fs.h"
+#include "nacl_io/filesystem.h"
+#include "nacl_io/fusefs/fuse_fs_factory.h"
#include "nacl_io/host_resolver.h"
+#include "nacl_io/html5fs/html5_fs.h"
+#include "nacl_io/httpfs/http_fs.h"
#include "nacl_io/kernel_handle.h"
#include "nacl_io/kernel_wrap_real.h"
-#include "nacl_io/mount.h"
-#include "nacl_io/mount_dev.h"
-#include "nacl_io/mount_html5fs.h"
-#include "nacl_io/mount_http.h"
-#include "nacl_io/mount_mem.h"
-#include "nacl_io/mount_node.h"
-#include "nacl_io/mount_node_pipe.h"
-#include "nacl_io/mount_node_tcp.h"
-#include "nacl_io/mount_node_udp.h"
-#include "nacl_io/mount_passthrough.h"
-#include "nacl_io/mount_stream.h"
+#include "nacl_io/memfs/mem_fs.h"
+#include "nacl_io/node.h"
#include "nacl_io/osmman.h"
#include "nacl_io/ossocket.h"
#include "nacl_io/osstat.h"
+#include "nacl_io/passthroughfs/passthrough_fs.h"
#include "nacl_io/path.h"
#include "nacl_io/pepper_interface.h"
-#include "nacl_io/typed_mount_factory.h"
+#include "nacl_io/pipe/pipe_node.h"
+#include "nacl_io/socket/tcp_node.h"
+#include "nacl_io/socket/udp_node.h"
+#include "nacl_io/stream/stream_fs.h"
+#include "nacl_io/typed_fs_factory.h"
#include "sdk_util/auto_lock.h"
#include "sdk_util/ref_object.h"
#include "sdk_util/string_util.h"
@@ -58,7 +58,7 @@ KernelProxy::KernelProxy() : dev_(0), ppapi_(NULL),
KernelProxy::~KernelProxy() {
// Clean up the MountFactories.
- for (MountFactoryMap_t::iterator i = factories_.begin();
+ for (FsFactoryMap_t::iterator i = factories_.begin();
i != factories_.end();
++i) {
delete i->second;
@@ -72,11 +72,11 @@ Error KernelProxy::Init(PepperInterface* ppapi) {
ppapi_ = ppapi;
dev_ = 1;
- factories_["memfs"] = new TypedMountFactory<MountMem>;
- factories_["dev"] = new TypedMountFactory<MountDev>;
- factories_["html5fs"] = new TypedMountFactory<MountHtml5Fs>;
- factories_["httpfs"] = new TypedMountFactory<MountHttp>;
- factories_["passthroughfs"] = new TypedMountFactory<MountPassthrough>;
+ factories_["memfs"] = new TypedFsFactory<MemFs>;
+ factories_["dev"] = new TypedFsFactory<DevFs>;
+ factories_["html5fs"] = new TypedFsFactory<Html5Fs>;
+ factories_["httpfs"] = new TypedFsFactory<HttpFs>;
+ factories_["passthroughfs"] = new TypedFsFactory<PassthroughFs>;
int result;
result = mount("", "/", "passthroughfs", 0, NULL);
@@ -112,10 +112,10 @@ Error KernelProxy::Init(PepperInterface* ppapi) {
host_resolver_.Init(ppapi_);
#endif
- MountInitArgs args;
+ FsInitArgs args;
args.dev = dev_++;
args.ppapi = ppapi_;
- stream_mount_.reset(new MountStream());
+ stream_mount_.reset(new StreamFs());
result = stream_mount_->Init(args);
if (result != 0) {
assert(false);
@@ -125,18 +125,18 @@ Error KernelProxy::Init(PepperInterface* ppapi) {
return rtn;
}
-bool KernelProxy::RegisterMountType(const char* mount_type,
+bool KernelProxy::RegisterFsType(const char* fs_type,
fuse_operations* fuse_ops) {
- MountFactoryMap_t::iterator iter = factories_.find(mount_type);
+ FsFactoryMap_t::iterator iter = factories_.find(fs_type);
if (iter != factories_.end())
return false;
- factories_[mount_type] = new FuseMountFactory(fuse_ops);
+ factories_[fs_type] = new FuseFsFactory(fuse_ops);
return true;
}
-bool KernelProxy::UnregisterMountType(const char* mount_type) {
- MountFactoryMap_t::iterator iter = factories_.find(mount_type);
+bool KernelProxy::UnregisterFsType(const char* fs_type) {
+ FsFactoryMap_t::iterator iter = factories_.find(fs_type);
if (iter == factories_.end())
return false;
@@ -146,27 +146,27 @@ bool KernelProxy::UnregisterMountType(const char* mount_type) {
}
int KernelProxy::open_resource(const char* path) {
- ScopedMount mnt;
+ ScopedFilesystem fs;
Path rel;
- Error error = AcquireMountAndRelPath(path, &mnt, &rel);
+ Error error = AcquireFsAndRelPath(path, &fs, &rel);
if (error) {
errno = error;
return -1;
}
- ScopedMountNode node;
- error = mnt->OpenResource(rel, &node);
+ ScopedNode node;
+ error = fs->OpenResource(rel, &node);
if (error) {
// OpenResource failed, try Open().
- error = mnt->Open(rel, O_RDONLY, &node);
+ error = fs->Open(rel, O_RDONLY, &node);
if (error) {
errno = error;
return -1;
}
}
- ScopedKernelHandle handle(new KernelHandle(mnt, node));
+ ScopedKernelHandle handle(new KernelHandle(fs, node));
error = handle->Init(O_RDONLY);
if (error) {
errno = error;
@@ -177,16 +177,16 @@ int KernelProxy::open_resource(const char* path) {
}
int KernelProxy::open(const char* path, int open_flags) {
- ScopedMount mnt;
- ScopedMountNode node;
+ ScopedFilesystem fs;
+ ScopedNode node;
- Error error = AcquireMountAndNode(path, open_flags, &mnt, &node);
+ Error error = AcquireFsAndNode(path, open_flags, &fs, &node);
if (error) {
errno = error;
return -1;
}
- ScopedKernelHandle handle(new KernelHandle(mnt, node));
+ ScopedKernelHandle handle(new KernelHandle(fs, node));
error = handle->Init(open_flags);
if (error) {
errno = error;
@@ -197,8 +197,8 @@ int KernelProxy::open(const char* path, int open_flags) {
}
int KernelProxy::pipe(int pipefds[2]) {
- MountNodePipe* pipe = new MountNodePipe(stream_mount_.get());
- ScopedMountNode node(pipe);
+ PipeNode* pipe = new PipeNode(stream_mount_.get());
+ ScopedNode node(pipe);
if (pipe->Init(O_RDWR) == 0) {
ScopedKernelHandle handle0(new KernelHandle(stream_mount_, node));
@@ -331,16 +331,16 @@ int KernelProxy::utime(const char* filename, const struct utimbuf* times) {
}
int KernelProxy::mkdir(const char* path, mode_t mode) {
- ScopedMount mnt;
+ ScopedFilesystem fs;
Path rel;
- Error error = AcquireMountAndRelPath(path, &mnt, &rel);
+ Error error = AcquireFsAndRelPath(path, &fs, &rel);
if (error) {
errno = error;
return -1;
}
- error = mnt->Mkdir(rel, mode);
+ error = fs->Mkdir(rel, mode);
if (error) {
errno = error;
return -1;
@@ -350,16 +350,16 @@ int KernelProxy::mkdir(const char* path, mode_t mode) {
}
int KernelProxy::rmdir(const char* path) {
- ScopedMount mnt;
+ ScopedFilesystem fs;
Path rel;
- Error error = AcquireMountAndRelPath(path, &mnt, &rel);
+ Error error = AcquireFsAndRelPath(path, &fs, &rel);
if (error) {
errno = error;
return -1;
}
- error = mnt->Rmdir(rel);
+ error = fs->Rmdir(rel);
if (error) {
errno = error;
return -1;
@@ -387,7 +387,7 @@ int KernelProxy::mount(const char* source,
std::string abs_path = GetAbsParts(target).Join();
// Find a factory of that type
- MountFactoryMap_t::iterator factory = factories_.find(filesystemtype);
+ FsFactoryMap_t::iterator factory = factories_.find(filesystemtype);
if (factory == factories_.end()) {
errno = ENODEV;
return -1;
@@ -415,19 +415,19 @@ int KernelProxy::mount(const char* source,
}
}
- MountInitArgs args;
+ FsInitArgs args;
args.dev = dev_++;
args.string_map = smap;
args.ppapi = ppapi_;
- ScopedMount mnt;
- Error error = factory->second->CreateMount(args, &mnt);
+ ScopedFilesystem fs;
+ Error error = factory->second->CreateFilesystem(args, &fs);
if (error) {
errno = error;
return -1;
}
- error = AttachMountAtPath(mnt, abs_path);
+ error = AttachFsAtPath(fs, abs_path);
if (error) {
errno = error;
return -1;
@@ -437,7 +437,7 @@ int KernelProxy::mount(const char* source,
}
int KernelProxy::umount(const char* path) {
- Error error = DetachMountAtPath(path);
+ Error error = DetachFsAtPath(path);
if (error) {
errno = error;
return -1;
@@ -611,16 +611,16 @@ off_t KernelProxy::lseek(int fd, off_t offset, int whence) {
}
int KernelProxy::unlink(const char* path) {
- ScopedMount mnt;
+ ScopedFilesystem fs;
Path rel;
- Error error = AcquireMountAndRelPath(path, &mnt, &rel);
+ Error error = AcquireFsAndRelPath(path, &fs, &rel);
if (error) {
errno = error;
return -1;
}
- error = mnt->Unlink(rel);
+ error = fs->Unlink(rel);
if (error) {
errno = error;
return -1;
@@ -640,23 +640,23 @@ int KernelProxy::lstat(const char* path, struct stat* buf) {
}
int KernelProxy::rename(const char* path, const char* newpath) {
- ScopedMount mnt;
+ ScopedFilesystem fs;
Path rel;
- Error error = AcquireMountAndRelPath(path, &mnt, &rel);
+ Error error = AcquireFsAndRelPath(path, &fs, &rel);
if (error) {
errno = error;
return -1;
}
- ScopedMount newmnt;
+ ScopedFilesystem newfs;
Path newrel;
- error = AcquireMountAndRelPath(newpath, &newmnt, &newrel);
+ error = AcquireFsAndRelPath(newpath, &newfs, &newrel);
if (error) {
errno = error;
return -1;
}
- if (newmnt.get() != mnt.get()) {
+ if (newfs.get() != fs.get()) {
// Renaming accross mountpoints is not allowed
errno = EXDEV;
return -1;
@@ -666,7 +666,7 @@ int KernelProxy::rename(const char* path, const char* newpath) {
if (rel == newrel)
return 0;
- error = mnt->Rename(rel, newrel);
+ error = fs->Rename(rel, newrel);
if (error) {
errno = error;
return -1;
@@ -676,16 +676,16 @@ int KernelProxy::rename(const char* path, const char* newpath) {
}
int KernelProxy::remove(const char* path) {
- ScopedMount mnt;
+ ScopedFilesystem fs;
Path rel;
- Error error = AcquireMountAndRelPath(path, &mnt, &rel);
+ Error error = AcquireFsAndRelPath(path, &fs, &rel);
if (error) {
errno = error;
return -1;
}
- error = mnt->Remove(rel);
+ error = fs->Remove(rel);
if (error) {
errno = error;
return -1;
@@ -751,16 +751,16 @@ int KernelProxy::fcntl(int fd, int request, va_list args) {
}
int KernelProxy::access(const char* path, int amode) {
- ScopedMount mnt;
+ ScopedFilesystem fs;
Path rel;
- Error error = AcquireMountAndRelPath(path, &mnt, &rel);
+ Error error = AcquireFsAndRelPath(path, &fs, &rel);
if (error) {
errno = error;
return -1;
}
- error = mnt->Access(rel, amode);
+ error = fs->Access(rel, amode);
if (error) {
errno = error;
return -1;
@@ -1184,9 +1184,9 @@ int KernelProxy::accept(int fd, struct sockaddr* addr, socklen_t* len) {
return -1;
}
- MountNodeSocket* sock = new MountNodeTCP(stream_mount_.get(), new_sock);
+ SocketNode* sock = new TcpNode(stream_mount_.get(), new_sock);
- // The MountNodeSocket now holds a reference to the new socket
+ // The SocketNode now holds a reference to the new socket
// so we release ours.
ppapi_->ReleaseResource(new_sock);
error = sock->Init(O_RDWR);
@@ -1195,7 +1195,7 @@ int KernelProxy::accept(int fd, struct sockaddr* addr, socklen_t* len) {
return -1;
}
- ScopedMountNode node(sock);
+ ScopedNode node(sock);
ScopedKernelHandle new_handle(new KernelHandle(stream_mount_, node));
error = new_handle->Init(O_RDWR);
if (error != 0) {
@@ -1529,14 +1529,14 @@ int KernelProxy::socket(int domain, int type, int protocol) {
type &= ~SOCK_NONBLOCK;
}
- MountNodeSocket* sock = NULL;
+ SocketNode* sock = NULL;
switch (type) {
case SOCK_DGRAM:
- sock = new MountNodeUDP(stream_mount_.get());
+ sock = new UdpNode(stream_mount_.get());
break;
case SOCK_STREAM:
- sock = new MountNodeTCP(stream_mount_.get());
+ sock = new TcpNode(stream_mount_.get());
break;
case SOCK_SEQPACKET:
@@ -1550,7 +1550,7 @@ int KernelProxy::socket(int domain, int type, int protocol) {
return -1;
}
- ScopedMountNode node(sock);
+ ScopedNode node(sock);
Error rtn = sock->Init(O_RDWR);
if (rtn != 0) {
errno = rtn;
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.h b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.h
index e037110..a0232753 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.h
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.h
@@ -9,14 +9,14 @@
#include <string>
#include "nacl_io/event_emitter.h"
+#include "nacl_io/fs_factory.h"
#include "nacl_io/host_resolver.h"
#include "nacl_io/kernel_object.h"
-#include "nacl_io/mount_factory.h"
-#include "nacl_io/mount_stream.h"
#include "nacl_io/ossignal.h"
#include "nacl_io/ossocket.h"
#include "nacl_io/ostypes.h"
#include "nacl_io/osutime.h"
+#include "nacl_io/stream/stream_fs.h"
struct fuse_operations;
struct timeval;
@@ -27,33 +27,33 @@ class PepperInterface;
// KernelProxy provide one-to-one mapping for libc kernel calls. Calls to the
-// proxy will result in IO access to the provided Mount and MountNode objects.
+// proxy will result in IO access to the provided Filesystem and Node objects.
//
// NOTE: The KernelProxy does not directly take any kernel locks, all locking
-// is done by the parent class KernelObject. Instead, KernelProxy is
-// responsible for taking the locks of the KernelHandle, and MountNode objects.
-// For this reason, a KernelObject call should not be done while holding
-// a handle or node lock. In addition, to ensure locking order,
-// a KernelHandle lock must never be taken after taking the associated
-// MountNode's lock.
+// is done by the parent class KernelObject. Instead, KernelProxy is
+// responsible for taking the locks of the KernelHandle, and Node objects. For
+// this reason, a KernelObject call should not be done while holding a handle
+// or node lock. In addition, to ensure locking order, a KernelHandle lock
+// must never be taken after taking the associated Node's lock.
//
// NOTE: The KernelProxy is the only class that should be setting errno. All
// other classes should return Error (as defined by nacl_io/error.h).
class KernelProxy : protected KernelObject {
public:
- typedef std::map<std::string, MountFactory*> MountFactoryMap_t;
+ typedef std::map<std::string, FsFactory*> FsFactoryMap_t;
KernelProxy();
virtual ~KernelProxy();
// Takes ownership of |ppapi|.
- // |ppapi| may be NULL. If so, no mount that uses pepper calls can be mounted.
+ // |ppapi| may be NULL. If so, no filesystem that uses pepper calls can be
+ // mounted.
virtual Error Init(PepperInterface* ppapi);
- // Register/Unregister a new mount type. See the documentation in nacl_io.h
- // for more info.
- bool RegisterMountType(const char* mount_type, fuse_operations* fuse_ops);
- bool UnregisterMountType(const char* mount_type);
+ // Register/Unregister a new filesystem type. See the documentation in
+ // nacl_io.h for more info.
+ bool RegisterFsType(const char* fs_type, fuse_operations* fuse_ops);
+ bool UnregisterFsType(const char* fs_type);
virtual int pipe(int pipefds[2]);
@@ -66,7 +66,7 @@ class KernelProxy : protected KernelObject {
virtual int dup(int fd);
virtual int dup2(int fd, int newfd);
- // Path related System calls handled by KernelProxy (not mount-specific)
+ // Path related System calls handled by KernelProxy (not filesystem-specific)
virtual int chdir(const char* path);
virtual char* getcwd(char* buf, size_t size);
virtual char* getwd(char* buf);
@@ -83,20 +83,20 @@ class KernelProxy : protected KernelObject {
virtual int lchown(const char* path, uid_t owner, gid_t group);
virtual int utime(const char* filename, const struct utimbuf* times);
- // System calls that take a path as an argument:
- // The kernel proxy will look for the Node associated to the path. To
- // find the node, the kernel proxy calls the corresponding mount's GetNode()
- // method. The corresponding method will be called. If the node
- // cannot be found, errno is set and -1 is returned.
+ // System calls that take a path as an argument: The kernel proxy will look
+ // for the Node associated to the path. To find the node, the kernel proxy
+ // calls the corresponding filesystem's GetNode() method. The corresponding
+ // method will be called. If the node cannot be found, errno is set and -1 is
+ // returned.
virtual int chmod(const char *path, mode_t mode);
virtual int mkdir(const char *path, mode_t mode);
virtual int rmdir(const char *path);
virtual int stat(const char *path, struct stat *buf);
// System calls that take a file descriptor as an argument:
- // The kernel proxy will determine to which mount the file
+ // The kernel proxy will determine to which filesystem the file
// descriptor's corresponding file handle belongs. The
- // associated mount's function will be called.
+ // associated filesystem's function will be called.
virtual ssize_t read(int fd, void *buf, size_t nbyte);
virtual ssize_t write(int fd, const void *buf, size_t nbyte);
@@ -111,20 +111,20 @@ class KernelProxy : protected KernelObject {
virtual int isatty(int fd);
virtual int ioctl(int fd, int request, va_list args);
- // lseek() relies on the mount's Stat() to determine whether or not the
+ // lseek() relies on the filesystem's Stat() to determine whether or not the
// file handle corresponding to fd is a directory
virtual off_t lseek(int fd, off_t offset, int whence);
- // remove() uses the mount's GetNode() and Stat() to determine whether or
- // not the path corresponds to a directory or a file. The mount's Rmdir()
- // or Unlink() is called accordingly.
+ // remove() uses the filesystem's GetNode() and Stat() to determine whether
+ // or not the path corresponds to a directory or a file. The filesystem's
+ // Rmdir() or Unlink() is called accordingly.
virtual int remove(const char* path);
- // unlink() is a simple wrapper around the mount's Unlink function.
+ // unlink() is a simple wrapper around the filesystem's Unlink function.
virtual int unlink(const char* path);
virtual int truncate(const char* path, off_t len);
virtual int lstat(const char* path, struct stat* buf);
virtual int rename(const char* path, const char* newpath);
- // access() uses the Mount's Stat().
+ // access() uses the Filesystem's Stat().
virtual int access(const char* path, int amode);
virtual int readlink(const char *path, char *buf, size_t count);
virtual int utimes(const char *filename, const struct timeval times[2]);
@@ -197,8 +197,8 @@ class KernelProxy : protected KernelObject {
#endif // PROVIDES_SOCKET_API
protected:
- MountFactoryMap_t factories_;
- sdk_util::ScopedRef<MountStream> stream_mount_;
+ FsFactoryMap_t factories_;
+ sdk_util::ScopedRef<StreamFs> stream_mount_;
int dev_;
PepperInterface* ppapi_;
static KernelProxy *s_instance_;
diff --git a/native_client_sdk/src/libraries/nacl_io/library.dsc b/native_client_sdk/src/libraries/nacl_io/library.dsc
index abddc64..e76ecd8 100644
--- a/native_client_sdk/src/libraries/nacl_io/library.dsc
+++ b/native_client_sdk/src/libraries/nacl_io/library.dsc
@@ -12,18 +12,23 @@
'TYPE' : 'lib',
'SOURCES' : [
'dbgprint.c',
+ "devfs/dev_fs.cc",
+ "devfs/tty_event_emitter.cc",
+ "devfs/tty_node.cc",
+ "dir_node.cc",
"event_emitter.cc",
- "event_emitter_pipe.cc",
- "event_emitter_stream.cc",
- "event_emitter_tcp.cc",
- "event_emitter_udp.cc",
"event_listener.cc",
"fifo_char.cc",
- "fifo_packet.cc",
- "fuse_mount_factory.cc",
+ "filesystem.cc",
+ "fusefs/fuse_fs.cc",
+ "fusefs/fuse_fs_factory.cc",
"getdents_helper.cc",
"h_errno.cc",
"host_resolver.cc",
+ "html5fs/html5_fs.cc",
+ "html5fs/html5_fs_node.cc",
+ "httpfs/http_fs.cc",
+ "httpfs/http_fs_node.cc",
"in6_addr.c",
"kernel_handle.cc",
"kernel_intercept.cc",
@@ -33,31 +38,27 @@
"kernel_wrap_glibc.cc",
"kernel_wrap_newlib.cc",
"kernel_wrap_win.cc",
- "mount.cc",
- "mount_dev.cc",
- "mount_fuse.cc",
- "mount_html5fs.cc",
- "mount_http.cc",
- "mount_mem.cc",
- "mount_node.cc",
- "mount_node_dir.cc",
- "mount_node_html5fs.cc",
- "mount_node_http.cc",
- "mount_node_mem.cc",
- "mount_node_pipe.cc",
- "mount_node_socket.cc",
- "mount_node_stream.cc",
- "mount_node_tcp.cc",
- "mount_node_tty.cc",
- "mount_node_udp.cc",
- "mount_passthrough.cc",
- "mount_stream.cc",
+ "memfs/mem_fs.cc",
+ "memfs/mem_fs_node.cc",
"nacl_io.cc",
- "packet.cc",
+ "node.cc",
+ "passthroughfs/passthrough_fs.cc",
"path.cc",
"pepper_interface.cc",
"pepper_interface_delegate.cc",
+ "pipe/pipe_event_emitter.cc",
+ "pipe/pipe_node.cc",
"real_pepper_interface.cc",
+ "socket/fifo_packet.cc",
+ "socket/packet.cc",
+ "socket/socket_node.cc",
+ "socket/tcp_event_emitter.cc",
+ "socket/tcp_node.cc",
+ "socket/udp_event_emitter.cc",
+ "socket/udp_node.cc",
+ "stream/stream_event_emitter.cc",
+ "stream/stream_fs.cc",
+ "stream/stream_node.cc",
"syscalls/accept.c",
"syscalls/access.c",
"syscalls/bind.c",
@@ -152,22 +153,29 @@
'HEADERS': [
{
'FILES': [
+ "char_node.h",
"dbgprint.h",
+ "devfs/dev_fs.h",
+ "devfs/tty_event_emitter.h",
+ "devfs/tty_node.h",
+ "dir_node.h",
"error.h",
"event_emitter.h",
"event_listener.h",
- "event_emitter_pipe.h",
- "event_emitter_stream.h",
- "event_emitter_tcp.h",
- "event_emitter_udp.h",
"fifo_char.h",
"fifo_interface.h",
"fifo_null.h",
- "fifo_packet.h",
+ "filesystem.h",
+ "fs_factory.h",
+ "fusefs/fuse_fs_factory.h",
+ "fusefs/fuse_fs.h",
"fuse.h",
- "fuse_mount_factory.h",
"getdents_helper.h",
"host_resolver.h",
+ "html5fs/html5_fs.h",
+ "html5fs/html5_fs_node.h",
+ "httpfs/http_fs.h",
+ "httpfs/http_fs_node.h",
"inode_pool.h",
"ioctl.h",
"kernel_handle.h",
@@ -176,46 +184,40 @@
"kernel_proxy.h",
"kernel_wrap.h",
"kernel_wrap_real.h",
- "mount_dev.h",
- "mount_factory.h",
- "mount.h",
- "mount_fuse.h",
- "mount_html5fs.h",
- "mount_http.h",
- "mount_mem.h",
- "mount_node.h",
- "mount_node_char.h",
- "mount_node_dir.h",
- "mount_node_html5fs.h",
- "mount_node_http.h",
- "mount_node_mem.h",
- "mount_node_pipe.h",
- "mount_node_socket.h",
- "mount_node_stream.h",
- "mount_node_tcp.h",
- "mount_node_tty.h",
- "mount_node_udp.h",
- "mount_passthrough.h",
- "mount_stream.h",
+ "memfs/mem_fs.h",
+ "memfs/mem_fs_node.h",
"nacl_io.h",
+ "node.h",
"osdirent.h",
"osinttypes.h",
"osmman.h",
"ossignal.h",
"ossocket.h",
"osstat.h",
+ "ostermios.h",
"ostime.h",
"ostypes.h",
"osunistd.h",
"osutime.h",
- "ostermios.h",
- "packet.h",
+ "passthroughfs/passthrough_fs.h",
"path.h",
"pepper_interface_delegate.h",
"pepper_interface_dummy.h",
"pepper_interface.h",
+ "pipe/pipe_event_emitter.h",
+ "pipe/pipe_node.h",
"real_pepper_interface.h",
- "typed_mount_factory.h",
+ "socket/fifo_packet.h",
+ "socket/packet.h",
+ "socket/socket_node.h",
+ "socket/tcp_event_emitter.h",
+ "socket/tcp_node.h",
+ "socket/udp_event_emitter.h",
+ "socket/udp_node.h",
+ "stream/stream_event_emitter.h",
+ "stream/stream_fs.h",
+ "stream/stream_node.h",
+ "typed_fs_factory.h",
],
'DEST': 'include/nacl_io',
},
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_mem.cc b/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.cc
index f00aa15..e34d424 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_mem.cc
+++ b/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.cc
@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/mount_mem.h"
+#include "nacl_io/memfs/mem_fs.h"
#include <errno.h>
#include <fcntl.h>
#include <string>
-#include "nacl_io/mount.h"
-#include "nacl_io/mount_node.h"
-#include "nacl_io/mount_node_dir.h"
-#include "nacl_io/mount_node_mem.h"
+#include "nacl_io/dir_node.h"
+#include "nacl_io/filesystem.h"
+#include "nacl_io/memfs/mem_fs_node.h"
+#include "nacl_io/node.h"
#include "nacl_io/osstat.h"
#include "nacl_io/osunistd.h"
#include "nacl_io/path.h"
@@ -21,14 +21,14 @@
namespace nacl_io {
-MountMem::MountMem() : root_(NULL) {}
+MemFs::MemFs() : root_(NULL) {}
-Error MountMem::Init(const MountInitArgs& args) {
- Error error = Mount::Init(args);
+Error MemFs::Init(const FsInitArgs& args) {
+ Error error = Filesystem::Init(args);
if (error)
return error;
- root_.reset(new MountNodeDir(this));
+ root_.reset(new DirNode(this));
error = root_->Init(0);
if (error) {
root_.reset(NULL);
@@ -37,11 +37,9 @@ Error MountMem::Init(const MountInitArgs& args) {
return 0;
}
-Error MountMem::FindNode(const Path& path,
- int type,
- ScopedMountNode* out_node) {
+Error MemFs::FindNode(const Path& path, int type, ScopedNode* out_node) {
out_node->reset(NULL);
- ScopedMountNode node = root_;
+ ScopedNode node = root_;
// If there is no root there, we have an error.
if (node == NULL)
@@ -76,8 +74,8 @@ Error MountMem::FindNode(const Path& path,
return 0;
}
-Error MountMem::Access(const Path& path, int a_mode) {
- ScopedMountNode node;
+Error MemFs::Access(const Path& path, int a_mode) {
+ ScopedNode node;
Error error = FindNode(path, 0, &node);
if (error)
@@ -93,10 +91,9 @@ Error MountMem::Access(const Path& path, int a_mode) {
return 0;
}
-Error MountMem::Open(const Path& path, int open_flags,
- ScopedMountNode* out_node) {
+Error MemFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
out_node->reset(NULL);
- ScopedMountNode node;
+ ScopedNode node;
Error error = FindNode(path, 0, &node);
if (error) {
@@ -105,12 +102,12 @@ Error MountMem::Open(const Path& path, int open_flags,
return ENOENT;
// Now first find the parent directory to see if we can add it
- ScopedMountNode parent;
+ ScopedNode parent;
error = FindNode(path.Parent(), S_IFDIR, &parent);
if (error)
return error;
- node.reset(new MountNodeMem(this));
+ node.reset(new MemFsNode(this));
error = node->Init(open_flags);
if (error)
return error;
@@ -131,29 +128,28 @@ Error MountMem::Open(const Path& path, int open_flags,
return EEXIST;
if (open_flags & O_TRUNC)
- static_cast<MountNodeMem*>(node.get())->Resize(0);
+ static_cast<MemFsNode*>(node.get())->Resize(0);
}
-
*out_node = node;
return 0;
}
-Error MountMem::Mkdir(const Path& path, int mode) {
- // We expect a Mount "absolute" path
+Error MemFs::Mkdir(const Path& path, int mode) {
+ // We expect a Filesystem "absolute" path
if (!path.IsAbsolute())
return ENOENT;
- // The root of the mount is already created by the mount
+ // The root of the filesystem is already created by the filesystem
if (path.Size() == 1)
return EEXIST;
- ScopedMountNode parent;
+ ScopedNode parent;
int error = FindNode(path.Parent(), S_IFDIR, &parent);
if (error)
return error;
- ScopedMountNode node;
+ ScopedNode node;
error = parent->FindChild(path.Basename(), &node);
if (!error)
return EEXIST;
@@ -164,7 +160,7 @@ Error MountMem::Mkdir(const Path& path, int mode) {
// Allocate a node, with a RefCount of 1. If added to the parent
// it will get ref counted again. In either case, release the
// recount we have on exit.
- node.reset(new MountNodeDir(this));
+ node.reset(new DirNode(this));
error = node->Init(0);
if (error)
return error;
@@ -172,23 +168,23 @@ Error MountMem::Mkdir(const Path& path, int mode) {
return parent->AddChild(path.Basename(), node);
}
-Error MountMem::Unlink(const Path& path) {
+Error MemFs::Unlink(const Path& path) {
return RemoveInternal(path, REMOVE_FILE);
}
-Error MountMem::Rmdir(const Path& path) {
+Error MemFs::Rmdir(const Path& path) {
return RemoveInternal(path, REMOVE_DIR);
}
-Error MountMem::Remove(const Path& path) {
+Error MemFs::Remove(const Path& path) {
return RemoveInternal(path, REMOVE_ALL);
}
-Error MountMem::Rename(const Path& src_path, const Path& target_path) {
- ScopedMountNode src_node;
- ScopedMountNode src_parent;
- ScopedMountNode target_node;
- ScopedMountNode target_parent;
+Error MemFs::Rename(const Path& src_path, const Path& target_path) {
+ ScopedNode src_node;
+ ScopedNode src_parent;
+ ScopedNode target_node;
+ ScopedNode target_parent;
int error = FindNode(src_path, 0, &src_node);
if (error)
return error;
@@ -253,28 +249,28 @@ Error MountMem::Rename(const Path& src_path, const Path& target_path) {
return 0;
}
-Error MountMem::RemoveInternal(const Path& path, int remove_type) {
+Error MemFs::RemoveInternal(const Path& path, int remove_type) {
bool dir_only = remove_type == REMOVE_DIR;
bool file_only = remove_type == REMOVE_FILE;
bool remove_dir = (remove_type & REMOVE_DIR) != 0;
if (dir_only) {
- // We expect a Mount "absolute" path
+ // We expect a Filesystem "absolute" path
if (!path.IsAbsolute())
return ENOENT;
- // The root of the mount is already created by the mount
+ // The root of the filesystem is already created by the filesystem
if (path.Size() == 1)
return EEXIST;
}
- ScopedMountNode parent;
+ ScopedNode parent;
int error = FindNode(path.Parent(), S_IFDIR, &parent);
if (error)
return error;
// Verify we find a child which is a directory.
- ScopedMountNode child;
+ ScopedNode child;
error = parent->FindChild(path.Basename(), &child);
if (error)
return error;
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_mem.h b/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.h
index 8ad87ca..89df5fa 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_mem.h
+++ b/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.h
@@ -2,23 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_MOUNT_MEM_H_
-#define LIBRARIES_NACL_IO_MOUNT_MEM_H_
+#ifndef LIBRARIES_NACL_IO_MEMFS_MEM_FS_H_
+#define LIBRARIES_NACL_IO_MEMFS_MEM_FS_H_
-#include "nacl_io/mount.h"
-#include "nacl_io/typed_mount_factory.h"
+#include "nacl_io/filesystem.h"
+#include "nacl_io/typed_fs_factory.h"
namespace nacl_io {
-class MountMem : public Mount {
+class MemFs : public Filesystem {
protected:
- MountMem();
+ MemFs();
- using Mount::Init;
- virtual Error Init(const MountInitArgs& args);
+ using Filesystem::Init;
+ virtual Error Init(const FsInitArgs& args);
// The protected functions are only used internally and will not
- // acquire or release the mount's lock themselves. The caller is
+ // acquire or release the filesystem's lock themselves. The caller is
// required to use correct locking as needed.
// Allocate or free an INODE number.
@@ -26,30 +26,30 @@ class MountMem : public Mount {
void FreeINO(int ino);
// Find a Node specified node optionally failing if type does not match.
- virtual Error FindNode(const Path& path, int type, ScopedMountNode* out_node);
+ virtual Error FindNode(const Path& path, int type, ScopedNode* out_node);
public:
virtual Error Access(const Path& path, int a_mode);
- virtual Error Open(const Path& path, int mode, ScopedMountNode* out_node);
+ virtual Error Open(const Path& path, int mode, ScopedNode* out_node);
virtual Error Unlink(const Path& path);
virtual Error Mkdir(const Path& path, int perm);
virtual Error Rmdir(const Path& path);
virtual Error Remove(const Path& path);
virtual Error Rename(const Path& path, const Path& newpath);
-private:
+ private:
static const int REMOVE_DIR = 1;
static const int REMOVE_FILE = 2;
static const int REMOVE_ALL = REMOVE_DIR | REMOVE_FILE;
Error RemoveInternal(const Path& path, int remove_type);
- ScopedMountNode root_;
+ ScopedNode root_;
- friend class TypedMountFactory<MountMem>;
- DISALLOW_COPY_AND_ASSIGN(MountMem);
+ friend class TypedFsFactory<MemFs>;
+ DISALLOW_COPY_AND_ASSIGN(MemFs);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_MOUNT_MEM_H_
+#endif // LIBRARIES_NACL_IO_MEMFS_MEM_FS_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_mem.cc b/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs_node.cc
index 50dafd7..e26c54e 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_mem.cc
+++ b/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs_node.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/mount_node_mem.h"
+#include "nacl_io/memfs/mem_fs_node.h"
#include <errno.h>
#include <string.h>
@@ -23,17 +23,16 @@ const size_t kMaxResizeIncrement = 16 * 1024 * 1024;
} // namespace
-MountNodeMem::MountNodeMem(Mount* mount)
- : MountNode(mount) {
+MemFsNode::MemFsNode(Filesystem* filesystem) : Node(filesystem) {
SetType(S_IFREG);
}
-MountNodeMem::~MountNodeMem() {}
+MemFsNode::~MemFsNode() {}
-Error MountNodeMem::Read(const HandleAttr& attr,
- void* buf,
- size_t count,
- int* out_bytes) {
+Error MemFsNode::Read(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes) {
*out_bytes = 0;
AUTO_LOCK(node_lock_);
@@ -51,10 +50,10 @@ Error MountNodeMem::Read(const HandleAttr& attr,
return 0;
}
-Error MountNodeMem::Write(const HandleAttr& attr,
- const void* buf,
- size_t count,
- int* out_bytes) {
+Error MemFsNode::Write(const HandleAttr& attr,
+ const void* buf,
+ size_t count,
+ int* out_bytes) {
*out_bytes = 0;
AUTO_LOCK(node_lock_);
@@ -71,13 +70,13 @@ Error MountNodeMem::Write(const HandleAttr& attr,
return 0;
}
-Error MountNodeMem::FTruncate(off_t new_size) {
+Error MemFsNode::FTruncate(off_t new_size) {
AUTO_LOCK(node_lock_);
Resize(new_size);
return 0;
}
-void MountNodeMem::Resize(off_t new_size) {
+void MemFsNode::Resize(off_t new_size) {
if (new_size > static_cast<off_t>(data_.capacity())) {
// While the node size is small, grow exponentially. When it starts to get
// larger, grow linearly.
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_mem.h b/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs_node.h
index ef2ba49..071f856 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_mem.h
+++ b/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs_node.h
@@ -2,21 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_MEM_H_
-#define LIBRARIES_NACL_IO_MOUNT_NODE_MEM_H_
+#ifndef LIBRARIES_NACL_IO_MEMFS_MEM_FS_NODE_H_
+#define LIBRARIES_NACL_IO_MEMFS_MEM_FS_NODE_H_
-#include "nacl_io/mount_node.h"
+#include "nacl_io/node.h"
#include <vector>
namespace nacl_io {
-class MountNodeMem : public MountNode {
+class MemFsNode : public Node {
public:
- explicit MountNodeMem(Mount* mount);
+ explicit MemFsNode(Filesystem* filesystem);
protected:
- virtual ~MountNodeMem();
+ virtual ~MemFsNode();
public:
// Normal read/write operations on a file
@@ -34,9 +34,9 @@ class MountNodeMem : public MountNode {
void Resize(off_t size);
std::vector<char> data_;
- friend class MountMem;
+ friend class MemFs;
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_MOUNT_NODE_MEM_H_
+#endif // LIBRARIES_NACL_IO_MEMFS_MEM_FS_NODE_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_factory.h b/native_client_sdk/src/libraries/nacl_io/mount_factory.h
deleted file mode 100644
index 48842ba..0000000
--- a/native_client_sdk/src/libraries/nacl_io/mount_factory.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIBRARIES_NACL_IO_MOUNT_FACTORY_H_
-#define LIBRARIES_NACL_IO_MOUNT_FACTORY_H_
-
-#include <errno.h>
-
-#include "nacl_io/error.h"
-#include "sdk_util/scoped_ref.h"
-
-namespace nacl_io {
-
-class PepperInterface;
-class Mount;
-struct MountInitArgs;
-
-class MountFactory {
- public:
- virtual ~MountFactory() {}
- virtual Error CreateMount(const MountInitArgs& args,
- sdk_util::ScopedRef<Mount>* out_mount) = 0;
-};
-
-} // namespace nacl_io
-
-#endif // LIBRARIES_NACL_IO_MOUNT_FACTORY_H_
-
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_char.h b/native_client_sdk/src/libraries/nacl_io/mount_node_char.h
deleted file mode 100644
index da34483..0000000
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_char.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_CHAR_H
-#define LIBRARIES_NACL_IO_MOUNT_NODE_CHAR_H
-
-#include "nacl_io/mount_node.h"
-
-namespace nacl_io {
-
-class MountNodeCharDevice : public MountNode {
- public:
- explicit MountNodeCharDevice(Mount* mount) : MountNode(mount) {
- SetType(S_IFCHR);
- }
-};
-
-}
-
-#endif // LIBRARIES_NACL_IO_MOUNT_NODE_CHAR_H
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_dir.h b/native_client_sdk/src/libraries/nacl_io/mount_node_dir.h
deleted file mode 100644
index 33e6574..0000000
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_dir.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_DIR_H_
-#define LIBRARIES_NACL_IO_MOUNT_NODE_DIR_H_
-
-#include <map>
-#include <string>
-#include <vector>
-
-#include "nacl_io/getdents_helper.h"
-#include "nacl_io/mount_node.h"
-
-namespace nacl_io {
-
-class MountDev;
-class MountHtml5Fs;
-class MountHttp;
-class MountMem;
-class MountNodeDir;
-
-typedef sdk_util::ScopedRef<MountNodeDir> ScopedMountNodeDir;
-
-class MountNodeDir : public MountNode {
- protected:
- explicit MountNodeDir(Mount* mnt);
- virtual ~MountNodeDir();
-
- public:
- typedef std::map<std::string, ScopedMountNode> MountNodeMap_t;
-
- virtual Error FTruncate(off_t size);
- virtual Error GetDents(size_t offs,
- struct dirent* pdir,
- size_t count,
- int* out_bytes);
- virtual Error Read(const HandleAttr& attr, void *buf,
- size_t count, int* out_bytes);
- virtual Error Write(const HandleAttr& attr, const void *buf,
- size_t count, int* out_bytes);
-
- // Adds a finds or adds a directory entry as an INO, updating the refcount
- virtual Error AddChild(const std::string& name, const ScopedMountNode& node);
- virtual Error RemoveChild(const std::string& name);
- virtual Error FindChild(const std::string& name, ScopedMountNode* out_node);
- virtual int ChildCount();
-
-protected:
- void BuildCache_Locked();
- void ClearCache_Locked();
-
-private:
- GetDentsHelper cache_;
- MountNodeMap_t map_;
- bool cache_built_;
-
- friend class MountDev;
- friend class MountMem;
- friend class MountHttp;
- friend class MountHtml5Fs;
-};
-
-} // namespace nacl_io
-
-#endif // LIBRARIES_NACL_IO_MOUNT_NODE_DIR_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_pipe.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_pipe.cc
deleted file mode 100644
index cc27a1f..0000000
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_pipe.cc
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "nacl_io/mount_node_pipe.h"
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <string.h>
-
-#include "nacl_io/event_emitter_pipe.h"
-#include "nacl_io/ioctl.h"
-#include "nacl_io/kernel_handle.h"
-
-namespace {
- const size_t kDefaultPipeSize = 512 * 1024;
-}
-
-namespace nacl_io {
-
-MountNodePipe::MountNodePipe(Mount* mnt)
- : MountNodeStream(mnt),
- pipe_(new EventEmitterPipe(kDefaultPipeSize)) {
-}
-
-EventEmitter* MountNodePipe::GetEventEmitter() {
- return pipe_.get();
-}
-
-Error MountNodePipe::Read(const HandleAttr& attr,
- void *buf,
- size_t count,
- int* out_bytes) {
- int ms = attr.IsBlocking() ? read_timeout_ : 0;
-
- EventListenerLock wait(GetEventEmitter());
- Error err = wait.WaitOnEvent(POLLIN, ms);
- if (err)
- return err;
-
- *out_bytes = pipe_->Read_Locked(static_cast<char *>(buf), count);
- return 0;
-}
-
-Error MountNodePipe::Write(const HandleAttr& attr,
- const void *buf,
- size_t count,
- int* out_bytes) {
- int ms = attr.IsBlocking() ? write_timeout_ : 0;
-
- EventListenerLock wait(GetEventEmitter());
- Error err = wait.WaitOnEvent(POLLOUT, ms);
- if (err)
- return err;
-
- *out_bytes = pipe_->Write_Locked(static_cast<const char *>(buf), count);
- return 0;
-}
-
-} // namespace nacl_io
-
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_pipe.h b/native_client_sdk/src/libraries/nacl_io/mount_node_pipe.h
deleted file mode 100644
index a109af9..0000000
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_pipe.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_PIPE_H_
-#define LIBRARIES_NACL_IO_MOUNT_NODE_PIPE_H_
-
-#include <map>
-#include <string>
-
-#include "nacl_io/event_emitter_pipe.h"
-#include "nacl_io/mount_node_stream.h"
-
-namespace nacl_io {
-
-class MountNodePipe : public MountNodeStream {
- public:
- explicit MountNodePipe(Mount* mnt);
-
- virtual EventEmitter* GetEventEmitter();
- virtual Error Read(const HandleAttr& attr, void *buf, size_t count,
- int* out_bytes);
- virtual Error Write(const HandleAttr& attr, const void *buf,
- size_t count, int* out_bytes);
-
- protected:
- ScopedEventEmitterPipe pipe_;
-
- friend class KernelProxy;
- friend class MountStream;
-};
-
-
-} // namespace nacl_io
-
-#endif // LIBRARIES_NACL_IO_MOUNT_NODE_PIPE_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_stream.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_stream.cc
deleted file mode 100644
index d38a69e..0000000
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_stream.cc
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "nacl_io/mount_node_stream.h"
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <string.h>
-
-#include "nacl_io/ioctl.h"
-#include "nacl_io/mount_stream.h"
-#include "sdk_util/atomicops.h"
-
-
-namespace nacl_io {
-
-MountNodeStream::MountNodeStream(Mount* mnt)
- : MountNode(mnt),
- read_timeout_(-1),
- write_timeout_(-1),
- stream_state_flags_(0) {
-}
-
-Error MountNodeStream::Init(int open_flags) {
- MountNode::Init(open_flags);
- if (open_flags & O_NONBLOCK)
- SetStreamFlags(SSF_NON_BLOCK);
-
- return 0;
-}
-
-void MountNodeStream::SetStreamFlags(uint32_t bits) {
- sdk_util::AtomicOrFetch(&stream_state_flags_, bits);
-}
-
-void MountNodeStream::ClearStreamFlags(uint32_t bits) {
- sdk_util::AtomicAndFetch(&stream_state_flags_, ~bits);
-}
-
-uint32_t MountNodeStream::GetStreamFlags() {
- return stream_state_flags_;
-}
-
-bool MountNodeStream::TestStreamFlags(uint32_t bits) {
- return (stream_state_flags_ & bits) == bits;
-}
-
-
-void MountNodeStream::QueueInput() {}
-void MountNodeStream::QueueOutput() {}
-
-MountStream* MountNodeStream::mount_stream() {
- return static_cast<MountStream*>(mount_);
-}
-
-} // namespace nacl_io
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_passthrough.h b/native_client_sdk/src/libraries/nacl_io/mount_passthrough.h
deleted file mode 100644
index 3cc3285..0000000
--- a/native_client_sdk/src/libraries/nacl_io/mount_passthrough.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIBRARIES_NACL_IO_MOUNT_PASSTHROUGH_H_
-#define LIBRARIES_NACL_IO_MOUNT_PASSTHROUGH_H_
-
-#include "nacl_io/mount.h"
-#include "nacl_io/typed_mount_factory.h"
-
-namespace nacl_io {
-
-class MountPassthrough : public Mount {
- protected:
- MountPassthrough();
-
- virtual Error Init(const MountInitArgs& args);
- virtual void Destroy();
-
- public:
- virtual Error Access(const Path& path, int a_mode);
- virtual Error Open(const Path& path, int mode, ScopedMountNode* out_node);
- virtual Error OpenResource(const Path& path, ScopedMountNode* out_node);
- virtual Error Unlink(const Path& path);
- virtual Error Mkdir(const Path& path, int perm);
- virtual Error Rmdir(const Path& path);
- virtual Error Remove(const Path& path);
- virtual Error Rename(const Path& path, const Path& newpath);
-
-private:
- friend class TypedMountFactory<MountPassthrough>;
- DISALLOW_COPY_AND_ASSIGN(MountPassthrough);
-};
-
-} // namespace nacl_io
-
-#endif // LIBRARIES_NACL_IO_MOUNT_PASSTHROUGH_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/nacl_io.cc b/native_client_sdk/src/libraries/nacl_io/nacl_io.cc
index 2263d1b..b597496 100644
--- a/native_client_sdk/src/libraries/nacl_io/nacl_io.cc
+++ b/native_client_sdk/src/libraries/nacl_io/nacl_io.cc
@@ -16,11 +16,11 @@ void nacl_io_init_ppapi(PP_Instance instance,
ki_init_ppapi(NULL, instance, get_interface);
}
-int nacl_io_register_mount_type(const char* mount_type,
+int nacl_io_register_fs_type(const char* fs_type,
fuse_operations* fuse_ops) {
- return ki_register_mount_type(mount_type, fuse_ops);
+ return ki_register_fs_type(fs_type, fuse_ops);
}
-int nacl_io_unregister_mount_type(const char* mount_type) {
- return ki_unregister_mount_type(mount_type);
+int nacl_io_unregister_fs_type(const char* fs_type) {
+ return ki_unregister_fs_type(fs_type);
}
diff --git a/native_client_sdk/src/libraries/nacl_io/nacl_io.h b/native_client_sdk/src/libraries/nacl_io/nacl_io.h
index 98490f2..7c49222 100644
--- a/native_client_sdk/src/libraries/nacl_io/nacl_io.h
+++ b/native_client_sdk/src/libraries/nacl_io/nacl_io.h
@@ -16,7 +16,7 @@ EXTERN_C_BEGIN
* Initialize nacl_io.
*
* NOTE: If you initialize nacl_io with this constructor, you cannot
- * use any mounts that require PPAPI; e.g. persistent storage, etc.
+ * use any filesystems that require PPAPI; e.g. persistent storage, etc.
*/
void nacl_io_init();
@@ -38,9 +38,7 @@ void nacl_io_init();
* |get_interface| can be retrieved via
* pp::Module::Get()->get_browser_interface()
*/
-void nacl_io_init_ppapi(PP_Instance instance,
- PPB_GetInterface get_interface);
-
+void nacl_io_init_ppapi(PP_Instance instance, PPB_GetInterface get_interface);
/**
* Mount a new filesystem type.
@@ -72,7 +70,7 @@ void nacl_io_init_ppapi(PP_Instance instance,
* data: Unused.
*
* "html5fs": A filesystem that uses PPAPI FileSystem interface, which can be
- * read in JavaScript via the HTML5 FileSystem API. This mount
+ * read in JavaScript via the HTML5 FileSystem API. This filesystem
* provides the use of persistent storage. Please read the
* documentation in ppapi/c/ppb_file_system.h for more information.
* source: Unused.
@@ -118,7 +116,7 @@ void nacl_io_init_ppapi(PP_Instance instance,
*/
/**
- * Register a new mount type, using a FUSE interface to implement it.
+ * Register a new filesystem type, using a FUSE interface to implement it.
*
* Example:
* int my_open(const char* path, struct fuse_file_info*) {
@@ -140,44 +138,44 @@ void nacl_io_init_ppapi(PP_Instance instance,
*
* ...
*
- * const char mount_type[] = "my_mount";
- * int result = nacl_io_register_mount_type(mount_type, &my_fuse_ops);
+ * const char fs_type[] = "my_fs";
+ * int result = nacl_io_register_fs_type(fs_type, &my_fuse_ops);
* if (!result) {
- * fprintf(stderr, "Error registering mount type %s.\n", mount_type);
+ * fprintf(stderr, "Error registering filesystem type %s.\n", fs_type);
* exit(1);
* }
*
* ...
*
- * int result = mount("", "/mnt/foo", mount_type, 0, NULL);
+ * int result = mount("", "/fs/foo", fs_type, 0, NULL);
* if (!result) {
- * fprintf(stderr, "Error mounting %s.\n", mount_type);
+ * fprintf(stderr, "Error mounting %s.\n", fs_type);
* exit(1);
* }
*
* See fuse.h for more information about the FUSE interface.
* Also see fuse.sourceforge.net for more information about FUSE in general.
*
- * @param[in] mount_type The name of the new mount type.
+ * @param[in] fs_type The name of the new filesystem type.
* @param[in] fuse_ops A pointer to the FUSE interface that will be used to
- * implement this mount type. This pointer must be valid for the lifetime
- * of all mounts and nodes that are created with it.
+ * implement this filesystem type. This pointer must be valid for the
+ * lifetime of all filesystems and nodes that are created with it.
* @return 0 on success, -1 on failure (with errno set).
*/
struct fuse_operations;
-int nacl_io_register_mount_type(const char* mount_type,
- struct fuse_operations* fuse_ops);
+int nacl_io_register_fs_type(const char* fs_type,
+ struct fuse_operations* fuse_ops);
/**
- * Unregister a mount type, previously registered by
- * nacl_io_register_mount_type().
+ * Unregister a filesystem type, previously registered by
+ * nacl_io_register_fs_type().
*
- * @param[in] mount_type The name of the mount type; the same identifier that
- * was passed to nacl_io_register_mount_type().
+ * @param[in] fs_type The name of the filesystem type; the same identifier that
+ * was passed to nacl_io_register_fs_type().
* @return 0 on success, -1 on failure (with errno set).
*/
-int nacl_io_unregister_mount_type(const char* mount_type);
+int nacl_io_unregister_fs_type(const char* fs_type);
EXTERN_C_END
-#endif /* LIBRARIES_NACL_IO_NACL_IO_H_ */
+#endif /* LIBRARIES_NACL_IO_NACL_IO_H_ */
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node.cc b/native_client_sdk/src/libraries/nacl_io/node.cc
index f69225d..802eee3 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/node.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/mount_node.h"
+#include "nacl_io/node.h"
#include <assert.h>
#include <errno.h>
@@ -14,9 +14,9 @@
#include <algorithm>
#include <string>
+#include "nacl_io/filesystem.h"
#include "nacl_io/kernel_handle.h"
#include "nacl_io/kernel_wrap_real.h"
-#include "nacl_io/mount.h"
#include "nacl_io/osmman.h"
#include "sdk_util/auto_lock.h"
@@ -25,42 +25,42 @@ namespace nacl_io {
static const int USR_ID = 1001;
static const int GRP_ID = 1002;
-MountNode::MountNode(Mount* mount) : mount_(mount) {
+Node::Node(Filesystem* filesystem) : filesystem_(filesystem) {
memset(&stat_, 0, sizeof(stat_));
stat_.st_gid = GRP_ID;
stat_.st_uid = USR_ID;
stat_.st_mode = S_IRALL | S_IWALL;
- // Mount should normally never be NULL, but may be null in tests.
+ // Filesystem should normally never be NULL, but may be null in tests.
// If NULL, at least set the inode to a valid (nonzero) value.
- if (mount_)
- mount_->OnNodeCreated(this);
+ if (filesystem_)
+ filesystem_->OnNodeCreated(this);
else
stat_.st_ino = 1;
}
-MountNode::~MountNode() {}
+Node::~Node() {}
-Error MountNode::Init(int open_flags) {
+Error Node::Init(int open_flags) {
return 0;
}
-void MountNode::Destroy() {
- if (mount_) {
- mount_->OnNodeDestroyed(this);
+void Node::Destroy() {
+ if (filesystem_) {
+ filesystem_->OnNodeDestroyed(this);
}
}
-EventEmitter* MountNode::GetEventEmitter() { return NULL; }
+EventEmitter* Node::GetEventEmitter() { return NULL; }
-uint32_t MountNode::GetEventStatus() {
+uint32_t Node::GetEventStatus() {
if (GetEventEmitter())
return GetEventEmitter()->GetEventStatus();
return POLLIN | POLLOUT;
}
-bool MountNode::CanOpen(int open_flags) {
+bool Node::CanOpen(int open_flags) {
switch (open_flags & 3) {
case O_RDONLY:
return (stat_.st_mode & S_IRALL) != 0;
@@ -73,11 +73,11 @@ bool MountNode::CanOpen(int open_flags) {
return false;
}
-Error MountNode::FSync() { return 0; }
+Error Node::FSync() { return 0; }
-Error MountNode::FTruncate(off_t length) { return EINVAL; }
+Error Node::FTruncate(off_t length) { return EINVAL; }
-Error MountNode::GetDents(size_t offs,
+Error Node::GetDents(size_t offs,
struct dirent* pdir,
size_t count,
int* out_bytes) {
@@ -85,13 +85,13 @@ Error MountNode::GetDents(size_t offs,
return ENOTDIR;
}
-Error MountNode::GetStat(struct stat* pstat) {
+Error Node::GetStat(struct stat* pstat) {
AUTO_LOCK(node_lock_);
memcpy(pstat, &stat_, sizeof(stat_));
return 0;
}
-Error MountNode::Ioctl(int request, ...) {
+Error Node::Ioctl(int request, ...) {
va_list ap;
va_start(ap, request);
Error rtn = VIoctl(request, ap);
@@ -99,9 +99,9 @@ Error MountNode::Ioctl(int request, ...) {
return rtn;
}
-Error MountNode::VIoctl(int request, va_list args) { return EINVAL; }
+Error Node::VIoctl(int request, va_list args) { return EINVAL; }
-Error MountNode::Read(const HandleAttr& attr,
+Error Node::Read(const HandleAttr& attr,
void* buf,
size_t count,
int* out_bytes) {
@@ -109,7 +109,7 @@ Error MountNode::Read(const HandleAttr& attr,
return EINVAL;
}
-Error MountNode::Write(const HandleAttr& attr,
+Error Node::Write(const HandleAttr& attr,
const void* buf,
size_t count,
int* out_bytes) {
@@ -117,7 +117,7 @@ Error MountNode::Write(const HandleAttr& attr,
return EINVAL;
}
-Error MountNode::MMap(void* addr,
+Error Node::MMap(void* addr,
size_t length,
int prot,
int flags,
@@ -131,8 +131,8 @@ Error MountNode::MMap(void* addr,
if (prot & PROT_EXEC)
return EPERM;
- // This default mmap support is just enough to make dlopen work.
- // This implementation just reads from the mount into the mmap'd memory area.
+ // This default mmap support is just enough to make dlopen work. This
+ // implementation just reads from the filesystem into the mmap'd memory area.
void* new_addr = addr;
int mmap_error = _real_mmap(
&new_addr, length, prot | PROT_WRITE, flags | MAP_ANONYMOUS, -1, 0);
@@ -155,60 +155,60 @@ Error MountNode::MMap(void* addr,
return 0;
}
-Error MountNode::Tcflush(int queue_selector) {
+Error Node::Tcflush(int queue_selector) {
return EINVAL;
}
-Error MountNode::Tcgetattr(struct termios* termios_p) {
+Error Node::Tcgetattr(struct termios* termios_p) {
return EINVAL;
}
-Error MountNode::Tcsetattr(int optional_actions,
+Error Node::Tcsetattr(int optional_actions,
const struct termios *termios_p) {
return EINVAL;
}
-int MountNode::GetLinks() { return stat_.st_nlink; }
+int Node::GetLinks() { return stat_.st_nlink; }
-int MountNode::GetMode() { return stat_.st_mode & ~S_IFMT; }
+int Node::GetMode() { return stat_.st_mode & ~S_IFMT; }
-Error MountNode::GetSize(size_t* out_size) {
+Error Node::GetSize(size_t* out_size) {
*out_size = stat_.st_size;
return 0;
}
-int MountNode::GetType() { return stat_.st_mode & S_IFMT; }
+int Node::GetType() { return stat_.st_mode & S_IFMT; }
-void MountNode::SetType(int type) {
+void Node::SetType(int type) {
assert((type & ~S_IFMT) == 0);
stat_.st_mode &= ~S_IFMT;
stat_.st_mode |= type;
}
-bool MountNode::IsaDir() { return (stat_.st_mode & S_IFDIR) != 0; }
+bool Node::IsaDir() { return (stat_.st_mode & S_IFDIR) != 0; }
-bool MountNode::IsaFile() { return (stat_.st_mode & S_IFREG) != 0; }
+bool Node::IsaFile() { return (stat_.st_mode & S_IFREG) != 0; }
-bool MountNode::IsaSock() { return (stat_.st_mode & S_IFSOCK) != 0; }
+bool Node::IsaSock() { return (stat_.st_mode & S_IFSOCK) != 0; }
-bool MountNode::IsaTTY() { return (stat_.st_mode & S_IFCHR) != 0; }
+bool Node::IsaTTY() { return (stat_.st_mode & S_IFCHR) != 0; }
-Error MountNode::AddChild(const std::string& name,
- const ScopedMountNode& node) {
+Error Node::AddChild(const std::string& name,
+ const ScopedNode& node) {
return ENOTDIR;
}
-Error MountNode::RemoveChild(const std::string& name) { return ENOTDIR; }
+Error Node::RemoveChild(const std::string& name) { return ENOTDIR; }
-Error MountNode::FindChild(const std::string& name, ScopedMountNode* out_node) {
+Error Node::FindChild(const std::string& name, ScopedNode* out_node) {
out_node->reset(NULL);
return ENOTDIR;
}
-int MountNode::ChildCount() { return 0; }
+int Node::ChildCount() { return 0; }
-void MountNode::Link() { stat_.st_nlink++; }
+void Node::Link() { stat_.st_nlink++; }
-void MountNode::Unlink() { stat_.st_nlink--; }
+void Node::Unlink() { stat_.st_nlink--; }
} // namespace nacl_io
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node.h b/native_client_sdk/src/libraries/nacl_io/node.h
index 80e27fa..962a338 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node.h
+++ b/native_client_sdk/src/libraries/nacl_io/node.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_H_
-#define LIBRARIES_NACL_IO_MOUNT_NODE_H_
+#ifndef LIBRARIES_NACL_IO_NODE_H_
+#define LIBRARIES_NACL_IO_NODE_H_
#include <stdarg.h>
#include <string>
@@ -24,18 +24,18 @@
namespace nacl_io {
-class Mount;
-class MountNode;
+class Filesystem;
+class Node;
struct HandleAttr;
-typedef sdk_util::ScopedRef<MountNode> ScopedMountNode;
+typedef sdk_util::ScopedRef<Node> ScopedNode;
// NOTE: The KernelProxy is the only class that should be setting errno. All
// other classes should return Error (as defined by nacl_io/error.h).
-class MountNode : public sdk_util::RefObject {
+class Node : public sdk_util::RefObject {
protected:
- explicit MountNode(Mount* mount);
- virtual ~MountNode();
+ explicit Node(Filesystem* filesystem);
+ virtual ~Node();
protected:
virtual Error Init(int open_flags);
@@ -52,9 +52,9 @@ class MountNode : public sdk_util::RefObject {
// Normal OS operations on a node (file), can be called by the kernel
// directly so it must lock and unlock appropriately. These functions
- // must not be called by the mount.
+ // must not be called by the filesystem.
virtual Error FSync();
- // It is expected that the derived MountNode will fill with 0 when growing
+ // It is expected that the derived Node will fill with 0 when growing
// the file.
virtual Error FTruncate(off_t length);
// Assume that |out_bytes| is non-NULL.
@@ -87,7 +87,7 @@ class MountNode : public sdk_util::RefObject {
virtual Error Tcflush(int queue_selector);
virtual Error Tcgetattr(struct termios* termios_p);
virtual Error Tcsetattr(int optional_actions,
- const struct termios *termios_p);
+ const struct termios* termios_p);
virtual int GetLinks();
virtual int GetMode();
@@ -104,17 +104,17 @@ class MountNode : public sdk_util::RefObject {
virtual int ChildCount();
protected:
- // Directory operations on the node are done by the Mount. The mount's lock
- // must be held while these calls are made.
+ // Directory operations on the node are done by the Filesystem. The
+ // filesystem's lock must be held while these calls are made.
// Adds or removes a directory entry updating the link numbers and refcount
// Assumes that |node| is non-NULL.
- virtual Error AddChild(const std::string& name, const ScopedMountNode& node);
+ virtual Error AddChild(const std::string& name, const ScopedNode& node);
virtual Error RemoveChild(const std::string& name);
// Find a child and return it without updating the refcount
// Assumes that |out_node| is non-NULL.
- virtual Error FindChild(const std::string& name, ScopedMountNode* out_node);
+ virtual Error FindChild(const std::string& name, ScopedNode* out_node);
// Update the link count
virtual void Link();
@@ -126,19 +126,19 @@ class MountNode : public sdk_util::RefObject {
// We use a pointer directly to avoid cycles in the ref count.
// TODO(noelallen) We should change this so it's unnecessary for the node
- // to track it's parent. When a node is unlinked, the mount should do
+ // to track it's parent. When a node is unlinked, the filesystem should do
// any cleanup it needs.
- Mount* mount_;
-
- friend class Mount;
- friend class MountDev;
- friend class MountFuse;
- friend class MountHtml5Fs;
- friend class MountHttp;
- friend class MountMem;
- friend class MountNodeDir;
+ Filesystem* filesystem_;
+
+ friend class DevFs;
+ friend class DirNode;
+ friend class Filesystem;
+ friend class FuseFs;
+ friend class Html5Fs;
+ friend class HttpFs;
+ friend class MemFs;
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_MOUNT_NODE_H_
+#endif // LIBRARIES_NACL_IO_NODE_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_passthrough.cc b/native_client_sdk/src/libraries/nacl_io/passthroughfs/passthrough_fs.cc
index 9f91763..8ca51d6 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_passthrough.cc
+++ b/native_client_sdk/src/libraries/nacl_io/passthroughfs/passthrough_fs.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/mount_passthrough.h"
+#include "nacl_io/passthroughfs/passthrough_fs.h"
#include <errno.h>
@@ -11,10 +11,10 @@
namespace nacl_io {
-class MountNodePassthrough : public MountNode {
+class PassthroughFsNode : public Node {
public:
- explicit MountNodePassthrough(Mount* mount, int real_fd)
- : MountNode(mount), real_fd_(real_fd) {}
+ explicit PassthroughFsNode(Filesystem* filesystem, int real_fd)
+ : Node(filesystem), real_fd_(real_fd) {}
protected:
virtual Error Init(int flags) { return 0; }
@@ -104,68 +104,65 @@ class MountNodePassthrough : public MountNode {
}
private:
- friend class MountPassthrough;
+ friend class PassthroughFs;
int real_fd_;
};
-MountPassthrough::MountPassthrough() {}
+PassthroughFs::PassthroughFs() {}
-Error MountPassthrough::Init(const MountInitArgs& args) {
- return Mount::Init(args);
+Error PassthroughFs::Init(const FsInitArgs& args) {
+ return Filesystem::Init(args);
}
-void MountPassthrough::Destroy() {}
+void PassthroughFs::Destroy() {}
-Error MountPassthrough::Access(const Path& path, int a_mode) {
+Error PassthroughFs::Access(const Path& path, int a_mode) {
// There is no underlying 'access' syscall in NaCl. It just returns ENOSYS.
return ENOSYS;
}
-Error MountPassthrough::Open(const Path& path,
- int mode,
- ScopedMountNode* out_node) {
+Error PassthroughFs::Open(const Path& path, int mode, ScopedNode* out_node) {
out_node->reset(NULL);
int real_fd;
int error = _real_open(path.Join().c_str(), mode, 0666, &real_fd);
if (error)
return error;
- out_node->reset(new MountNodePassthrough(this, real_fd));
+ out_node->reset(new PassthroughFsNode(this, real_fd));
return 0;
}
-Error MountPassthrough::OpenResource(const Path& path,
- ScopedMountNode* out_node) {
+Error PassthroughFs::OpenResource(const Path& path, ScopedNode* out_node) {
int real_fd;
out_node->reset(NULL);
int error = _real_open_resource(path.Join().c_str(), &real_fd);
if (error)
return error;
- out_node->reset(new MountNodePassthrough(this, real_fd));
+ out_node->reset(new PassthroughFsNode(this, real_fd));
return 0;
}
-Error MountPassthrough::Unlink(const Path& path) {
+Error PassthroughFs::Unlink(const Path& path) {
// Not implemented by NaCl.
return ENOSYS;
}
-Error MountPassthrough::Mkdir(const Path& path, int perm) {
+Error PassthroughFs::Mkdir(const Path& path, int perm) {
return _real_mkdir(path.Join().c_str(), perm);
}
-Error MountPassthrough::Rmdir(const Path& path) {
+Error PassthroughFs::Rmdir(const Path& path) {
return _real_rmdir(path.Join().c_str());
}
-Error MountPassthrough::Remove(const Path& path) {
+Error PassthroughFs::Remove(const Path& path) {
// Not implemented by NaCl.
return ENOSYS;
}
-Error MountPassthrough::Rename(const Path& path, const Path& newpath) {
+Error PassthroughFs::Rename(const Path& path, const Path& newpath) {
// Not implemented by NaCl.
return ENOSYS;
}
diff --git a/native_client_sdk/src/libraries/nacl_io/passthroughfs/passthrough_fs.h b/native_client_sdk/src/libraries/nacl_io/passthroughfs/passthrough_fs.h
new file mode 100644
index 0000000..983c5da
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/passthroughfs/passthrough_fs.h
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIBRARIES_NACL_IO_PASSTHROUGHFS_PASSTHROUGH_FS_H_
+
+#define LIBRARIES_NACL_IO_PASSTHROUGHFS_PASSTHROUGH_FS_H_
+
+#include "nacl_io/filesystem.h"
+#include "nacl_io/typed_fs_factory.h"
+
+namespace nacl_io {
+
+class PassthroughFs : public Filesystem {
+ protected:
+ PassthroughFs();
+
+ virtual Error Init(const FsInitArgs& args);
+ virtual void Destroy();
+
+ public:
+ virtual Error Access(const Path& path, int a_mode);
+ virtual Error Open(const Path& path, int mode, ScopedNode* out_node);
+ virtual Error OpenResource(const Path& path, ScopedNode* out_node);
+ virtual Error Unlink(const Path& path);
+ virtual Error Mkdir(const Path& path, int perm);
+ virtual Error Rmdir(const Path& path);
+ virtual Error Remove(const Path& path);
+ virtual Error Rename(const Path& path, const Path& newpath);
+
+ private:
+ friend class TypedFsFactory<PassthroughFs>;
+ DISALLOW_COPY_AND_ASSIGN(PassthroughFs);
+};
+
+} // namespace nacl_io
+
+#endif // LIBRARIES_NACL_IO_PASSTHROUGHFS_PASSTHROUGH_FS_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/event_emitter_tty.cc b/native_client_sdk/src/libraries/nacl_io/pipe/pipe_event_emitter.cc
index 7df065a..542068f 100644
--- a/native_client_sdk/src/libraries/nacl_io/event_emitter_tty.cc
+++ b/native_client_sdk/src/libraries/nacl_io/pipe/pipe_event_emitter.cc
@@ -2,27 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <poll.h>
-#include <stdint.h>
-#include <stdlib.h>
+#include "nacl_io/pipe/pipe_event_emitter.h"
-#include "nacl_io/event_emitter_tty.h"
+#include <algorithm>
namespace nacl_io {
-EventEmitterTTY::EventEmitterTTY(size_t size)
+PipeEventEmitter::PipeEventEmitter(size_t size)
: fifo_(std::max<size_t>(1, size)) {
UpdateStatus_Locked();
}
-size_t EventEmitterPipe::Read_Locked(char* data, size_t len) {
+size_t PipeEventEmitter::Read_Locked(char* data, size_t len) {
size_t out_len = fifo_.Read(data, len);
UpdateStatus_Locked();
return out_len;
}
-size_t EventEmitterPipe::Write_Locked(const char* data, size_t len) {
+size_t PipeEventEmitter::Write_Locked(const char* data, size_t len) {
size_t out_len = fifo_.Write(data, len);
UpdateStatus_Locked();
diff --git a/native_client_sdk/src/libraries/nacl_io/event_emitter_pipe.h b/native_client_sdk/src/libraries/nacl_io/pipe/pipe_event_emitter.h
index a357bea..5c731db 100644
--- a/native_client_sdk/src/libraries/nacl_io/event_emitter_pipe.h
+++ b/native_client_sdk/src/libraries/nacl_io/pipe/pipe_event_emitter.h
@@ -2,27 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_EVENT_EMITTER_PIPE_H_
-#define LIBRARIES_NACL_IO_EVENT_EMITTER_PIPE_H_
+#ifndef LIBRARIES_NACL_IO_PIPE_PIPE_EVENT_EMITTER_H_
+#define LIBRARIES_NACL_IO_PIPE_PIPE_EVENT_EMITTER_H_
#include <poll.h>
#include <stdint.h>
#include <stdlib.h>
-#include "nacl_io/event_emitter_stream.h"
#include "nacl_io/fifo_char.h"
+#include "nacl_io/stream/stream_event_emitter.h"
#include "sdk_util/auto_lock.h"
#include "sdk_util/macros.h"
namespace nacl_io {
-class EventEmitterPipe;
-typedef sdk_util::ScopedRef<EventEmitterPipe> ScopedEventEmitterPipe;
+class PipeEventEmitter;
+typedef sdk_util::ScopedRef<PipeEventEmitter> ScopedPipeEventEmitter;
-class EventEmitterPipe : public EventEmitterStream {
+class PipeEventEmitter : public StreamEventEmitter {
public:
- EventEmitterPipe(size_t size);
+ PipeEventEmitter(size_t size);
size_t Read_Locked(char* data, size_t len);
size_t Write_Locked(const char* data, size_t len);
@@ -33,10 +33,9 @@ class EventEmitterPipe : public EventEmitterStream {
private:
FIFOChar fifo_;
- DISALLOW_COPY_AND_ASSIGN(EventEmitterPipe);
+ DISALLOW_COPY_AND_ASSIGN(PipeEventEmitter);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_EVENT_EMITTER_PIPE_H_
-
+#endif // LIBRARIES_NACL_IO_PIPE_PIPE_EVENT_EMITTER_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.cc b/native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.cc
new file mode 100644
index 0000000..fce322b
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.cc
@@ -0,0 +1,58 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "nacl_io/pipe/pipe_node.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <string.h>
+
+#include "nacl_io/ioctl.h"
+#include "nacl_io/kernel_handle.h"
+#include "nacl_io/pipe/pipe_event_emitter.h"
+
+namespace {
+const size_t kDefaultPipeSize = 512 * 1024;
+}
+
+namespace nacl_io {
+
+PipeNode::PipeNode(Filesystem* fs)
+ : StreamNode(fs), pipe_(new PipeEventEmitter(kDefaultPipeSize)) {}
+
+EventEmitter* PipeNode::GetEventEmitter() { return pipe_.get(); }
+
+Error PipeNode::Read(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes) {
+ int ms = attr.IsBlocking() ? read_timeout_ : 0;
+
+ EventListenerLock wait(GetEventEmitter());
+ Error err = wait.WaitOnEvent(POLLIN, ms);
+ if (err)
+ return err;
+
+ *out_bytes = pipe_->Read_Locked(static_cast<char*>(buf), count);
+ return 0;
+}
+
+Error PipeNode::Write(const HandleAttr& attr,
+ const void* buf,
+ size_t count,
+ int* out_bytes) {
+ int ms = attr.IsBlocking() ? write_timeout_ : 0;
+
+ EventListenerLock wait(GetEventEmitter());
+ Error err = wait.WaitOnEvent(POLLOUT, ms);
+ if (err)
+ return err;
+
+ *out_bytes = pipe_->Write_Locked(static_cast<const char*>(buf), count);
+ return 0;
+}
+
+} // namespace nacl_io
+
diff --git a/native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.h b/native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.h
new file mode 100644
index 0000000..4b4c937
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.h
@@ -0,0 +1,39 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIBRARIES_NACL_IO_PIPE_PIPE_NODE_H_
+#define LIBRARIES_NACL_IO_PIPE_PIPE_NODE_H_
+
+#include <map>
+#include <string>
+
+#include "nacl_io/pipe/pipe_event_emitter.h"
+#include "nacl_io/stream/stream_node.h"
+
+namespace nacl_io {
+
+class PipeNode : public StreamNode {
+ public:
+ explicit PipeNode(Filesystem* fs);
+
+ virtual EventEmitter* GetEventEmitter();
+ virtual Error Read(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes);
+ virtual Error Write(const HandleAttr& attr,
+ const void* buf,
+ size_t count,
+ int* out_bytes);
+
+ protected:
+ ScopedPipeEventEmitter pipe_;
+
+ friend class KernelProxy;
+ friend class StreamFs;
+};
+
+} // namespace nacl_io
+
+#endif // LIBRARIES_NACL_IO_PIPE_PIPE_NODE_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/fifo_packet.cc b/native_client_sdk/src/libraries/nacl_io/socket/fifo_packet.cc
index 94354af..c2b3540 100644
--- a/native_client_sdk/src/libraries/nacl_io/fifo_packet.cc
+++ b/native_client_sdk/src/libraries/nacl_io/socket/fifo_packet.cc
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/fifo_packet.h"
+#include "nacl_io/socket/fifo_packet.h"
#include <stdlib.h>
#include <string.h>
#include <algorithm>
-#include "nacl_io/packet.h"
+#include "nacl_io/socket/packet.h"
namespace nacl_io {
diff --git a/native_client_sdk/src/libraries/nacl_io/fifo_packet.h b/native_client_sdk/src/libraries/nacl_io/socket/fifo_packet.h
index b9e5c44..b9e5c44 100644
--- a/native_client_sdk/src/libraries/nacl_io/fifo_packet.h
+++ b/native_client_sdk/src/libraries/nacl_io/socket/fifo_packet.h
diff --git a/native_client_sdk/src/libraries/nacl_io/packet.cc b/native_client_sdk/src/libraries/nacl_io/socket/packet.cc
index c75fb11..fcfbf7d 100644
--- a/native_client_sdk/src/libraries/nacl_io/packet.cc
+++ b/native_client_sdk/src/libraries/nacl_io/socket/packet.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/packet.h"
+#include "nacl_io/socket/packet.h"
#include <string.h>
diff --git a/native_client_sdk/src/libraries/nacl_io/packet.h b/native_client_sdk/src/libraries/nacl_io/socket/packet.h
index 46f3b3b..b238a7b 100644
--- a/native_client_sdk/src/libraries/nacl_io/packet.h
+++ b/native_client_sdk/src/libraries/nacl_io/socket/packet.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_PACKET_H_
-#define LIBRARIES_NACL_IO_PACKET_H_
+#ifndef LIBRARIES_NACL_IO_SOCKET_PACKET_H_
+#define LIBRARIES_NACL_IO_SOCKET_PACKET_H_
#include "nacl_io/fifo_interface.h"
#include "ppapi/c/pp_resource.h"
@@ -42,4 +42,4 @@ class Packet {
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_PACKET_H_
+#endif // LIBRARIES_NACL_IO_SOCKET_PACKET_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc b/native_client_sdk/src/libraries/nacl_io/socket/socket_node.cc
index d137e07..e3baabc 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc
+++ b/native_client_sdk/src/libraries/nacl_io/socket/socket_node.cc
@@ -2,15 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "nacl_io/socket/socket_node.h"
+
#include "nacl_io/ossocket.h"
#ifdef PROVIDES_SOCKET_API
#include <errno.h>
#include <string.h>
+#include "nacl_io/filesystem.h"
#include "nacl_io/kernel_handle.h"
-#include "nacl_io/mount.h"
-#include "nacl_io/mount_node_socket.h"
#include "nacl_io/pepper_interface.h"
#include "ppapi/c/pp_resource.h"
@@ -18,8 +19,8 @@
namespace nacl_io {
-MountNodeSocket::MountNodeSocket(Mount* mount)
- : MountNodeStream(mount),
+SocketNode::SocketNode(Filesystem* filesystem)
+ : StreamNode(filesystem),
socket_resource_(0),
local_addr_(0),
remote_addr_(0),
@@ -30,8 +31,8 @@ MountNodeSocket::MountNodeSocket(Mount* mount)
SetType(S_IFSOCK);
}
-MountNodeSocket::MountNodeSocket(Mount* mount, PP_Resource socket)
- : MountNodeStream(mount),
+SocketNode::SocketNode(Filesystem* filesystem, PP_Resource socket)
+ : StreamNode(filesystem),
socket_resource_(socket),
local_addr_(0),
remote_addr_(0),
@@ -40,16 +41,16 @@ MountNodeSocket::MountNodeSocket(Mount* mount, PP_Resource socket)
keep_alive_(false) {
memset(&linger_, 0, sizeof(linger_));
SetType(S_IFSOCK);
- mount_->ppapi()->AddRefResource(socket_resource_);
+ filesystem_->ppapi()->AddRefResource(socket_resource_);
}
-void MountNodeSocket::Destroy() {
+void SocketNode::Destroy() {
if (socket_resource_)
- mount_->ppapi()->ReleaseResource(socket_resource_);
+ filesystem_->ppapi()->ReleaseResource(socket_resource_);
if (local_addr_)
- mount_->ppapi()->ReleaseResource(local_addr_);
+ filesystem_->ppapi()->ReleaseResource(local_addr_);
if (remote_addr_)
- mount_->ppapi()->ReleaseResource(remote_addr_);
+ filesystem_->ppapi()->ReleaseResource(remote_addr_);
socket_resource_ = 0;
local_addr_ = 0;
@@ -57,55 +58,54 @@ void MountNodeSocket::Destroy() {
}
// Assume that |addr| and |out_addr| are non-NULL.
-Error MountNodeSocket::MMap(void* addr,
- size_t length,
- int prot,
- int flags,
- size_t offset,
- void** out_addr) {
+Error SocketNode::MMap(void* addr,
+ size_t length,
+ int prot,
+ int flags,
+ size_t offset,
+ void** out_addr) {
return EACCES;
}
// Normal read/write operations on a Socket are equivalent to
// send/recv with a flag value of 0.
-Error MountNodeSocket::Read(const HandleAttr& attr,
- void* buf,
- size_t count,
- int* out_bytes) {
+Error SocketNode::Read(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes) {
return Recv(attr, buf, count, 0, out_bytes);
}
-Error MountNodeSocket::Write(const HandleAttr& attr,
- const void* buf,
- size_t count,
- int* out_bytes) {
+Error SocketNode::Write(const HandleAttr& attr,
+ const void* buf,
+ size_t count,
+ int* out_bytes) {
return Send(attr, buf, count, 0, out_bytes);
}
-
-NetAddressInterface* MountNodeSocket::NetInterface() {
- if (mount_->ppapi() == NULL)
+NetAddressInterface* SocketNode::NetInterface() {
+ if (filesystem_->ppapi() == NULL)
return NULL;
- return mount_->ppapi()->GetNetAddressInterface();
+ return filesystem_->ppapi()->GetNetAddressInterface();
}
-TCPSocketInterface* MountNodeSocket::TCPInterface() {
- if (mount_->ppapi() == NULL)
+TCPSocketInterface* SocketNode::TCPInterface() {
+ if (filesystem_->ppapi() == NULL)
return NULL;
- return mount_->ppapi()->GetTCPSocketInterface();
+ return filesystem_->ppapi()->GetTCPSocketInterface();
}
-UDPSocketInterface* MountNodeSocket::UDPInterface() {
- if (mount_->ppapi() == NULL)
+UDPSocketInterface* SocketNode::UDPInterface() {
+ if (filesystem_->ppapi() == NULL)
return NULL;
- return mount_->ppapi()->GetUDPSocketInterface();
+ return filesystem_->ppapi()->GetUDPSocketInterface();
}
-PP_Resource MountNodeSocket::SockAddrToResource(const struct sockaddr* addr,
- socklen_t len) {
+PP_Resource SocketNode::SockAddrToResource(const struct sockaddr* addr,
+ socklen_t len) {
if (NULL == addr)
return 0;
@@ -120,8 +120,9 @@ PP_Resource MountNodeSocket::SockAddrToResource(const struct sockaddr* addr,
addr4.port = sin->sin_port;
memcpy(addr4.addr, &sin->sin_addr, sizeof(addr4.addr));
- return mount_->ppapi()->GetNetAddressInterface()->CreateFromIPv4Address(
- mount_->ppapi()->GetInstance(), &addr4);
+ return filesystem_->ppapi()
+ ->GetNetAddressInterface()
+ ->CreateFromIPv4Address(filesystem_->ppapi()->GetInstance(), &addr4);
}
if (AF_INET6 == addr->sa_family) {
@@ -135,16 +136,16 @@ PP_Resource MountNodeSocket::SockAddrToResource(const struct sockaddr* addr,
addr6.port = sin->sin6_port;
memcpy(addr6.addr, &sin->sin6_addr, sizeof(addr6.addr));
- return mount_->ppapi()->GetNetAddressInterface()->CreateFromIPv6Address(
- mount_->ppapi()->GetInstance(), &addr6);
+ return filesystem_->ppapi()
+ ->GetNetAddressInterface()
+ ->CreateFromIPv6Address(filesystem_->ppapi()->GetInstance(), &addr6);
}
return 0;
}
-
-socklen_t MountNodeSocket::ResourceToSockAddr(PP_Resource addr,
- socklen_t len,
- struct sockaddr* out_addr) {
+socklen_t SocketNode::ResourceToSockAddr(PP_Resource addr,
+ socklen_t len,
+ struct sockaddr* out_addr) {
if (0 == addr)
return 0;
@@ -176,8 +177,7 @@ socklen_t MountNodeSocket::ResourceToSockAddr(PP_Resource addr,
return 0;
}
-bool MountNodeSocket::IsEquivalentAddress(PP_Resource addr1,
- PP_Resource addr2) {
+bool SocketNode::IsEquivalentAddress(PP_Resource addr1, PP_Resource addr2) {
if (addr1 == addr2)
return true;
@@ -196,16 +196,16 @@ bool MountNodeSocket::IsEquivalentAddress(PP_Resource addr1,
return memcmp(saddr1, saddr2, len1) == 0;
}
-Error MountNodeSocket::Accept(const HandleAttr& attr,
- PP_Resource* new_sock,
- struct sockaddr* addr,
- socklen_t* len) {
+Error SocketNode::Accept(const HandleAttr& attr,
+ PP_Resource* new_sock,
+ struct sockaddr* addr,
+ socklen_t* len) {
return ENOSYS;
}
-Error MountNodeSocket::Connect(const HandleAttr& attr,
- const struct sockaddr* addr,
- socklen_t len) {
+Error SocketNode::Connect(const HandleAttr& attr,
+ const struct sockaddr* addr,
+ socklen_t len) {
if (len < 1)
return EINVAL;
@@ -215,14 +215,12 @@ Error MountNodeSocket::Connect(const HandleAttr& attr,
return EOPNOTSUPP;
}
-Error MountNodeSocket::Listen(int backlog) {
- return EOPNOTSUPP;
-}
+Error SocketNode::Listen(int backlog) { return EOPNOTSUPP; }
-Error MountNodeSocket::GetSockOpt(int lvl,
- int optname,
- void* optval,
- socklen_t* len) {
+Error SocketNode::GetSockOpt(int lvl,
+ int optname,
+ void* optval,
+ socklen_t* len) {
if (lvl != SOL_SOCKET)
return ENOPROTOOPT;
@@ -258,17 +256,16 @@ Error MountNodeSocket::GetSockOpt(int lvl,
return ENOPROTOOPT;
}
-
int copy_bytes = std::min(value_len, *len);
memcpy(optval, value_ptr, copy_bytes);
*len = value_len;
return 0;
}
-Error MountNodeSocket::SetSockOpt(int lvl,
- int optname,
- const void* optval,
- socklen_t len) {
+Error SocketNode::SetSockOpt(int lvl,
+ int optname,
+ const void* optval,
+ socklen_t len) {
if (lvl != SOL_SOCKET)
return ENOPROTOOPT;
@@ -312,43 +309,43 @@ Error MountNodeSocket::SetSockOpt(int lvl,
return ENOPROTOOPT;
}
-Error MountNodeSocket::Bind(const struct sockaddr* addr, socklen_t len) {
+Error SocketNode::Bind(const struct sockaddr* addr, socklen_t len) {
return EINVAL;
}
-Error MountNodeSocket::Recv(const HandleAttr& attr,
- void* buf,
- size_t len,
- int flags,
- int* out_len) {
+Error SocketNode::Recv(const HandleAttr& attr,
+ void* buf,
+ size_t len,
+ int flags,
+ int* out_len) {
return RecvFrom(attr, buf, len, flags, NULL, 0, out_len);
}
-Error MountNodeSocket::RecvFrom(const HandleAttr& attr,
- void* buf,
- size_t len,
- int flags,
- struct sockaddr* src_addr,
- socklen_t* addrlen,
- int* out_len) {
+Error SocketNode::RecvFrom(const HandleAttr& attr,
+ void* buf,
+ size_t len,
+ int flags,
+ struct sockaddr* src_addr,
+ socklen_t* addrlen,
+ int* out_len) {
PP_Resource addr = 0;
Error err = RecvHelper(attr, buf, len, flags, &addr, out_len);
if (0 == err && 0 != addr) {
if (src_addr)
*addrlen = ResourceToSockAddr(addr, *addrlen, src_addr);
- mount_->ppapi()->ReleaseResource(addr);
+ filesystem_->ppapi()->ReleaseResource(addr);
}
return err;
}
-Error MountNodeSocket::RecvHelper(const HandleAttr& attr,
- void* buf,
- size_t len,
- int flags,
- PP_Resource* addr,
- int* out_len) {
+Error SocketNode::RecvHelper(const HandleAttr& attr,
+ void* buf,
+ size_t len,
+ int flags,
+ PP_Resource* addr,
+ int* out_len) {
if (0 == socket_resource_)
return EBADF;
@@ -356,8 +353,8 @@ Error MountNodeSocket::RecvHelper(const HandleAttr& attr,
if ((flags & MSG_DONTWAIT) || !attr.IsBlocking())
ms = 0;
- //TODO(noelallen) BUG=295177
- //For UDP we should support filtering packets when using connect
+ // TODO(noelallen) BUG=295177
+ // For UDP we should support filtering packets when using connect
EventListenerLock wait(GetEventEmitter());
Error err = wait.WaitOnEvent(POLLIN, ms);
@@ -376,21 +373,21 @@ Error MountNodeSocket::RecvHelper(const HandleAttr& attr,
return err;
}
-Error MountNodeSocket::Send(const HandleAttr& attr,
- const void* buf,
- size_t len,
- int flags,
- int* out_len) {
+Error SocketNode::Send(const HandleAttr& attr,
+ const void* buf,
+ size_t len,
+ int flags,
+ int* out_len) {
return SendHelper(attr, buf, len, flags, remote_addr_, out_len);
}
-Error MountNodeSocket::SendTo(const HandleAttr& attr,
- const void* buf,
- size_t len,
- int flags,
- const struct sockaddr* dest_addr,
- socklen_t addrlen,
- int* out_len) {
+Error SocketNode::SendTo(const HandleAttr& attr,
+ const void* buf,
+ size_t len,
+ int flags,
+ const struct sockaddr* dest_addr,
+ socklen_t addrlen,
+ int* out_len) {
if ((NULL == dest_addr) && (0 == remote_addr_))
return EDESTADDRREQ;
@@ -399,16 +396,16 @@ Error MountNodeSocket::SendTo(const HandleAttr& attr,
return EINVAL;
Error err = SendHelper(attr, buf, len, flags, addr, out_len);
- mount_->ppapi()->ReleaseResource(addr);
+ filesystem_->ppapi()->ReleaseResource(addr);
return err;
}
-Error MountNodeSocket::SendHelper(const HandleAttr& attr,
- const void* buf,
- size_t len,
- int flags,
- PP_Resource addr,
- int* out_len) {
+Error SocketNode::SendHelper(const HandleAttr& attr,
+ const void* buf,
+ size_t len,
+ int flags,
+ PP_Resource addr,
+ int* out_len) {
if (0 == socket_resource_)
return EBADF;
@@ -437,18 +434,15 @@ Error MountNodeSocket::SendHelper(const HandleAttr& attr,
return err;
}
-void MountNodeSocket::SetError_Locked(int pp_error_num) {
+void SocketNode::SetError_Locked(int pp_error_num) {
SetStreamFlags(SSF_ERROR | SSF_CLOSED);
ClearStreamFlags(SSF_CAN_SEND | SSF_CAN_RECV);
last_errno_ = PPErrorToErrno(pp_error_num);
}
-Error MountNodeSocket::Shutdown(int how) {
- return EOPNOTSUPP;
-}
-
+Error SocketNode::Shutdown(int how) { return EOPNOTSUPP; }
-Error MountNodeSocket::GetPeerName(struct sockaddr* addr, socklen_t* len) {
+Error SocketNode::GetPeerName(struct sockaddr* addr, socklen_t* len) {
if (NULL == addr || NULL == len)
return EFAULT;
@@ -461,7 +455,7 @@ Error MountNodeSocket::GetPeerName(struct sockaddr* addr, socklen_t* len) {
return ENOTCONN;
}
-Error MountNodeSocket::GetSockName(struct sockaddr* addr, socklen_t* len) {
+Error SocketNode::GetSockName(struct sockaddr* addr, socklen_t* len) {
if (NULL == addr || NULL == len)
return EFAULT;
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_socket.h b/native_client_sdk/src/libraries/nacl_io/socket/socket_node.h
index 3ecb3db..fe3b3f06 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_socket.h
+++ b/native_client_sdk/src/libraries/nacl_io/socket/socket_node.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_SOCKET_H_
-#define LIBRARIES_NACL_IO_MOUNT_NODE_SOCKET_H_
+#ifndef LIBRARIES_NACL_IO_SOCKET_SOCKET_NODE_H_
+#define LIBRARIES_NACL_IO_SOCKET_SOCKET_NODE_H_
#include "nacl_io/ossocket.h"
#ifdef PROVIDES_SOCKET_API
@@ -13,10 +13,10 @@
#include <ppapi/c/pp_resource.h>
#include <ppapi/c/ppb_net_address.h>
-#include "nacl_io/mount.h"
-#include "nacl_io/mount_node.h"
-#include "nacl_io/mount_node_stream.h"
+#include "nacl_io/filesystem.h"
+#include "nacl_io/node.h"
#include "nacl_io/pepper_interface.h"
+#include "nacl_io/stream/stream_node.h"
namespace nacl_io {
@@ -24,14 +24,14 @@ namespace nacl_io {
* should be looping on Send/Recv size. */
static const size_t MAX_SOCK_TRANSFER = 65536;
-class MountStream;
-class MountNodeSocket;
-typedef sdk_util::ScopedRef<MountNodeSocket> ScopedMountNodeSocket;
+class StreamFs;
+class SocketNode;
+typedef sdk_util::ScopedRef<SocketNode> ScopedSocketNode;
-class MountNodeSocket : public MountNodeStream {
+class SocketNode : public StreamNode {
public:
- explicit MountNodeSocket(Mount* mount);
- MountNodeSocket(Mount* mount, PP_Resource socket);
+ explicit SocketNode(Filesystem* filesystem);
+ SocketNode(Filesystem* filesystem, PP_Resource socket);
protected:
virtual void Destroy();
@@ -127,7 +127,6 @@ class MountNodeSocket : public MountNodeStream {
PP_Resource* addr,
int* out_len);
-
// Per socket type send and recv
virtual Error Recv_Locked(void* buffer,
size_t len,
@@ -139,7 +138,6 @@ class MountNodeSocket : public MountNodeStream {
PP_Resource addr,
int* out_len) = 0;
-
NetAddressInterface* NetInterface();
TCPSocketInterface* TCPInterface();
UDPSocketInterface* UDPInterface();
@@ -161,10 +159,10 @@ class MountNodeSocket : public MountNodeStream {
struct linger linger_;
friend class KernelProxy;
- friend class MountStream;
+ friend class StreamFs;
};
} // namespace nacl_io
#endif // PROVIDES_SOCKET_API
-#endif // LIBRARIES_NACL_IO_MOUNT_NODE_SOCKET_H_
+#endif // LIBRARIES_NACL_IO_SOCKET_SOCKET_NODE_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/event_emitter_tcp.cc b/native_client_sdk/src/libraries/nacl_io/socket/tcp_event_emitter.cc
index cce6359..9f5778a 100644
--- a/native_client_sdk/src/libraries/nacl_io/event_emitter_tcp.cc
+++ b/native_client_sdk/src/libraries/nacl_io/socket/tcp_event_emitter.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/event_emitter_tcp.h"
+#include "nacl_io/socket/tcp_event_emitter.h"
#include <poll.h>
#include <stdint.h>
@@ -13,21 +13,20 @@
namespace nacl_io {
-EventEmitterTCP::EventEmitterTCP(size_t rsize, size_t wsize)
+TcpEventEmitter::TcpEventEmitter(size_t rsize, size_t wsize)
: in_fifo_(rsize),
out_fifo_(wsize),
error_(false),
listening_(false),
- accepted_socket_(0) {
-}
+ accepted_socket_(0) {}
-uint32_t EventEmitterTCP::ReadIn_Locked(char* data, uint32_t len) {
+uint32_t TcpEventEmitter::ReadIn_Locked(char* data, uint32_t len) {
uint32_t count = in_fifo_.Read(data, len);
UpdateStatus_Locked();
return count;
}
-void EventEmitterTCP::UpdateStatus_Locked() {
+void TcpEventEmitter::UpdateStatus_Locked() {
if (error_) {
RaiseEvents_Locked(POLLIN | POLLOUT);
return;
@@ -39,55 +38,53 @@ void EventEmitterTCP::UpdateStatus_Locked() {
return;
}
- EventEmitterStream::UpdateStatus_Locked();
+ StreamEventEmitter::UpdateStatus_Locked();
}
-void EventEmitterTCP::SetListening_Locked() {
+void TcpEventEmitter::SetListening_Locked() {
listening_ = true;
UpdateStatus_Locked();
}
-uint32_t EventEmitterTCP::WriteIn_Locked(const char* data, uint32_t len) {
+uint32_t TcpEventEmitter::WriteIn_Locked(const char* data, uint32_t len) {
uint32_t count = in_fifo_.Write(data, len);
UpdateStatus_Locked();
return count;
}
-uint32_t EventEmitterTCP::ReadOut_Locked(char* data, uint32_t len) {
+uint32_t TcpEventEmitter::ReadOut_Locked(char* data, uint32_t len) {
uint32_t count = out_fifo_.Read(data, len);
UpdateStatus_Locked();
return count;
}
-uint32_t EventEmitterTCP::WriteOut_Locked(const char* data, uint32_t len) {
+uint32_t TcpEventEmitter::WriteOut_Locked(const char* data, uint32_t len) {
uint32_t count = out_fifo_.Write(data, len);
UpdateStatus_Locked();
return count;
}
-void EventEmitterTCP::ConnectDone_Locked() {
+void TcpEventEmitter::ConnectDone_Locked() {
RaiseEvents_Locked(POLLOUT);
UpdateStatus_Locked();
}
-bool EventEmitterTCP::GetError_Locked() {
- return error_;
-}
+bool TcpEventEmitter::GetError_Locked() { return error_; }
-void EventEmitterTCP::SetError_Locked() {
+void TcpEventEmitter::SetError_Locked() {
error_ = true;
UpdateStatus_Locked();
}
-void EventEmitterTCP::SetAcceptedSocket_Locked(PP_Resource socket) {
+void TcpEventEmitter::SetAcceptedSocket_Locked(PP_Resource socket) {
accepted_socket_ = socket;
UpdateStatus_Locked();
}
-PP_Resource EventEmitterTCP::GetAcceptedSocket_Locked() {
+PP_Resource TcpEventEmitter::GetAcceptedSocket_Locked() {
int rtn = accepted_socket_;
accepted_socket_ = 0;
UpdateStatus_Locked();
diff --git a/native_client_sdk/src/libraries/nacl_io/event_emitter_tcp.h b/native_client_sdk/src/libraries/nacl_io/socket/tcp_event_emitter.h
index 0d49f15..1e17a95 100644
--- a/native_client_sdk/src/libraries/nacl_io/event_emitter_tcp.h
+++ b/native_client_sdk/src/libraries/nacl_io/socket/tcp_event_emitter.h
@@ -2,28 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_EVENT_EMITTER_TCP_H_
-#define LIBRARIES_NACL_IO_EVENT_EMITTER_TCP_H_
+#ifndef LIBRARIES_NACL_IO_SOCKET_TCP_EVENT_EMITTER_H_
+#define LIBRARIES_NACL_IO_SOCKET_TCP_EVENT_EMITTER_H_
-#include "nacl_io/event_emitter_stream.h"
#include "nacl_io/fifo_char.h"
+#include "nacl_io/stream/stream_event_emitter.h"
#include <ppapi/c/pp_resource.h>
#include "sdk_util/macros.h"
#include "sdk_util/scoped_ref.h"
-
namespace nacl_io {
-class EventEmitterTCP;
-class MountNode;
+class TcpEventEmitter;
+class Node;
-typedef sdk_util::ScopedRef<EventEmitterTCP> ScopedEventEmitterTCP;
+typedef sdk_util::ScopedRef<TcpEventEmitter> ScopedTcpEventEmitter;
-class EventEmitterTCP : public EventEmitterStream {
+class TcpEventEmitter : public StreamEventEmitter {
public:
- EventEmitterTCP(size_t rsize, size_t wsize);
+ TcpEventEmitter(size_t rsize, size_t wsize);
uint32_t ReadIn_Locked(char* buffer, uint32_t len);
uint32_t WriteIn_Locked(const char* buffer, uint32_t len);
@@ -49,10 +48,9 @@ class EventEmitterTCP : public EventEmitterStream {
bool error_;
bool listening_;
PP_Resource accepted_socket_;
- DISALLOW_COPY_AND_ASSIGN(EventEmitterTCP);
+ DISALLOW_COPY_AND_ASSIGN(TcpEventEmitter);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_EVENT_EMITTER_TCP_H_
-
+#endif // LIBRARIES_NACL_IO_SOCKET_TCP_EVENT_EMITTER_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_tcp.cc b/native_client_sdk/src/libraries/nacl_io/socket/tcp_node.cc
index 1366eec11..d4f4122 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_tcp.cc
+++ b/native_client_sdk/src/libraries/nacl_io/socket/tcp_node.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
#include "nacl_io/ossocket.h"
#ifdef PROVIDES_SOCKET_API
@@ -12,43 +11,40 @@
#include <algorithm>
#include "nacl_io/kernel_handle.h"
-#include "nacl_io/mount_node_tcp.h"
-#include "nacl_io/mount_stream.h"
#include "nacl_io/pepper_interface.h"
+#include "nacl_io/socket/tcp_node.h"
+#include "nacl_io/stream/stream_fs.h"
namespace {
- const size_t kMaxPacketSize = 65536;
- const size_t kDefaultFifoSize = kMaxPacketSize * 8;
+const size_t kMaxPacketSize = 65536;
+const size_t kDefaultFifoSize = kMaxPacketSize * 8;
}
namespace nacl_io {
-class TCPWork : public MountStream::Work {
+class TcpWork : public StreamFs::Work {
public:
- explicit TCPWork(const ScopedEventEmitterTCP& emitter)
- : MountStream::Work(emitter->stream()->mount_stream()),
+ explicit TcpWork(const ScopedTcpEventEmitter& emitter)
+ : StreamFs::Work(emitter->stream()->stream()),
emitter_(emitter),
- data_(NULL) {
- }
+ data_(NULL) {}
- ~TCPWork() {
- delete[] data_;
- }
+ ~TcpWork() { delete[] data_; }
TCPSocketInterface* TCPInterface() {
- return mount()->ppapi()->GetTCPSocketInterface();
+ return filesystem()->ppapi()->GetTCPSocketInterface();
}
protected:
- ScopedEventEmitterTCP emitter_;
+ ScopedTcpEventEmitter emitter_;
char* data_;
};
-class TCPSendWork : public TCPWork {
+class TcpSendWork : public TcpWork {
public:
- explicit TCPSendWork(const ScopedEventEmitterTCP& emitter,
- const ScopedMountNodeSocket& stream)
- : TCPWork(emitter), node_(stream) {}
+ explicit TcpSendWork(const ScopedTcpEventEmitter& emitter,
+ const ScopedSocketNode& stream)
+ : TcpWork(emitter), node_(stream) {}
virtual bool Start(int32_t val) {
AUTO_LOCK(emitter_->GetLock());
@@ -72,7 +68,7 @@ class TCPSendWork : public TCPWork {
int err = TCPInterface()->Write(node_->socket_resource(),
data_,
capped_len,
- mount()->GetRunCompletion(this));
+ filesystem()->GetRunCompletion(this));
if (err != PP_OK_COMPLETIONPENDING) {
// Anything else, we should assume the socket has gone bad.
@@ -102,17 +98,17 @@ class TCPSendWork : public TCPWork {
// We assume that transmits will always complete. If the upstream
// actually back pressures, enough to prevent the Send callback
// from triggering, this resource may never go away.
- ScopedMountNodeSocket node_;
+ ScopedSocketNode node_;
};
-class TCPRecvWork : public TCPWork {
+class TcpRecvWork : public TcpWork {
public:
- explicit TCPRecvWork(const ScopedEventEmitterTCP& emitter)
- : TCPWork(emitter) {}
+ explicit TcpRecvWork(const ScopedTcpEventEmitter& emitter)
+ : TcpWork(emitter) {}
virtual bool Start(int32_t val) {
AUTO_LOCK(emitter_->GetLock());
- MountNodeTCP* stream = static_cast<MountNodeTCP*>(emitter_->stream());
+ TcpNode* stream = static_cast<TcpNode*>(emitter_->stream());
// Does the stream exist, and can it recv?
if (NULL == stream || !stream->TestStreamFlags(SSF_CAN_RECV))
@@ -133,7 +129,7 @@ class TCPRecvWork : public TCPWork {
int err = TCPInterface()->Read(stream->socket_resource(),
data_,
capped_len,
- mount()->GetRunCompletion(this));
+ filesystem()->GetRunCompletion(this));
if (err != PP_OK_COMPLETIONPENDING) {
// Anything else, we should assume the socket has gone bad.
stream->SetError_Locked(err);
@@ -146,7 +142,7 @@ class TCPRecvWork : public TCPWork {
virtual void Run(int32_t length_error) {
AUTO_LOCK(emitter_->GetLock());
- MountNodeTCP* stream = static_cast<MountNodeTCP*>(emitter_->stream());
+ TcpNode* stream = static_cast<TcpNode*>(emitter_->stream());
if (!stream)
return;
@@ -163,20 +159,18 @@ class TCPRecvWork : public TCPWork {
}
};
-class TCPAcceptWork : public MountStream::Work {
+class TCPAcceptWork : public StreamFs::Work {
public:
- explicit TCPAcceptWork(MountStream* stream,
- const ScopedEventEmitterTCP& emitter)
- : MountStream::Work(stream),
- emitter_(emitter) {}
+ explicit TCPAcceptWork(StreamFs* stream, const ScopedTcpEventEmitter& emitter)
+ : StreamFs::Work(stream), emitter_(emitter) {}
TCPSocketInterface* TCPInterface() {
- return mount()->ppapi()->GetTCPSocketInterface();
+ return filesystem()->ppapi()->GetTCPSocketInterface();
}
virtual bool Start(int32_t val) {
AUTO_LOCK(emitter_->GetLock());
- MountNodeTCP* node = static_cast<MountNodeTCP*>(emitter_->stream());
+ TcpNode* node = static_cast<TcpNode*>(emitter_->stream());
// Does the stream exist, and can it accept?
if (NULL == node)
@@ -188,7 +182,7 @@ class TCPAcceptWork : public MountStream::Work {
int err = TCPInterface()->Accept(node->socket_resource(),
&new_socket_,
- mount()->GetRunCompletion(this));
+ filesystem()->GetRunCompletion(this));
if (err != PP_OK_COMPLETIONPENDING) {
// Anything else, we should assume the socket has gone bad.
@@ -201,7 +195,7 @@ class TCPAcceptWork : public MountStream::Work {
virtual void Run(int32_t error) {
AUTO_LOCK(emitter_->GetLock());
- MountNodeTCP* node = static_cast<MountNodeTCP*>(emitter_->stream());
+ TcpNode* node = static_cast<TcpNode*>(emitter_->stream());
if (node == NULL)
return;
@@ -216,23 +210,22 @@ class TCPAcceptWork : public MountStream::Work {
protected:
PP_Resource new_socket_;
- ScopedEventEmitterTCP emitter_;
+ ScopedTcpEventEmitter emitter_;
};
-class TCPConnectWork : public MountStream::Work {
+class TCPConnectWork : public StreamFs::Work {
public:
- explicit TCPConnectWork(MountStream* stream,
- const ScopedEventEmitterTCP& emitter)
- : MountStream::Work(stream),
- emitter_(emitter) {}
+ explicit TCPConnectWork(StreamFs* stream,
+ const ScopedTcpEventEmitter& emitter)
+ : StreamFs::Work(stream), emitter_(emitter) {}
TCPSocketInterface* TCPInterface() {
- return mount()->ppapi()->GetTCPSocketInterface();
+ return filesystem()->ppapi()->GetTCPSocketInterface();
}
virtual bool Start(int32_t val) {
AUTO_LOCK(emitter_->GetLock());
- MountNodeTCP* node = static_cast<MountNodeTCP*>(emitter_->stream());
+ TcpNode* node = static_cast<TcpNode*>(emitter_->stream());
// Does the stream exist, and can it connect?
if (NULL == node)
@@ -240,7 +233,7 @@ class TCPConnectWork : public MountStream::Work {
int err = TCPInterface()->Connect(node->socket_resource(),
node->remote_addr(),
- mount()->GetRunCompletion(this));
+ filesystem()->GetRunCompletion(this));
if (err != PP_OK_COMPLETIONPENDING) {
// Anything else, we should assume the socket has gone bad.
node->SetError_Locked(err);
@@ -252,7 +245,7 @@ class TCPConnectWork : public MountStream::Work {
virtual void Run(int32_t error) {
AUTO_LOCK(emitter_->GetLock());
- MountNodeTCP* node = static_cast<MountNodeTCP*>(emitter_->stream());
+ TcpNode* node = static_cast<TcpNode*>(emitter_->stream());
if (node == NULL)
return;
@@ -267,30 +260,30 @@ class TCPConnectWork : public MountStream::Work {
}
protected:
- ScopedEventEmitterTCP emitter_;
+ ScopedTcpEventEmitter emitter_;
};
-MountNodeTCP::MountNodeTCP(Mount* mount)
- : MountNodeSocket(mount),
- emitter_(new EventEmitterTCP(kDefaultFifoSize, kDefaultFifoSize)),
+TcpNode::TcpNode(Filesystem* filesystem)
+ : SocketNode(filesystem),
+ emitter_(new TcpEventEmitter(kDefaultFifoSize, kDefaultFifoSize)),
tcp_nodelay_(false) {
emitter_->AttachStream(this);
}
-MountNodeTCP::MountNodeTCP(Mount* mount, PP_Resource socket)
- : MountNodeSocket(mount, socket),
- emitter_(new EventEmitterTCP(kDefaultFifoSize, kDefaultFifoSize)),
+TcpNode::TcpNode(Filesystem* filesystem, PP_Resource socket)
+ : SocketNode(filesystem, socket),
+ emitter_(new TcpEventEmitter(kDefaultFifoSize, kDefaultFifoSize)),
tcp_nodelay_(false) {
emitter_->AttachStream(this);
}
-void MountNodeTCP::Destroy() {
+void TcpNode::Destroy() {
emitter_->DetachStream();
- MountNodeSocket::Destroy();
+ SocketNode::Destroy();
}
-Error MountNodeTCP::Init(int open_flags) {
- Error err = MountNodeSocket::Init(open_flags);
+Error TcpNode::Init(int open_flags) {
+ Error err = SocketNode::Init(open_flags);
if (err != 0)
return err;
@@ -304,7 +297,8 @@ Error MountNodeTCP::Init(int open_flags) {
remote_addr_ = TCPInterface()->GetRemoteAddress(socket_resource_);
ConnectDone_Locked();
} else {
- socket_resource_ = TCPInterface()->Create(mount_->ppapi()->GetInstance());
+ socket_resource_ =
+ TCPInterface()->Create(filesystem_->ppapi()->GetInstance());
if (0 == socket_resource_)
return EACCES;
SetStreamFlags(SSF_CAN_CONNECT);
@@ -313,19 +307,14 @@ Error MountNodeTCP::Init(int open_flags) {
return 0;
}
-EventEmitter* MountNodeTCP::GetEventEmitter() {
- return emitter_.get();
-}
+EventEmitter* TcpNode::GetEventEmitter() { return emitter_.get(); }
-void MountNodeTCP::SetError_Locked(int pp_error_num) {
- MountNodeSocket::SetError_Locked(pp_error_num);
+void TcpNode::SetError_Locked(int pp_error_num) {
+ SocketNode::SetError_Locked(pp_error_num);
emitter_->SetError_Locked();
}
-Error MountNodeTCP::GetSockOpt(int lvl,
- int optname,
- void* optval,
- socklen_t* len) {
+Error TcpNode::GetSockOpt(int lvl, int optname, void* optval, socklen_t* len) {
if (lvl == IPPROTO_TCP && optname == TCP_NODELAY) {
AUTO_LOCK(node_lock_);
int value = tcp_nodelay_;
@@ -336,25 +325,25 @@ Error MountNodeTCP::GetSockOpt(int lvl,
return 0;
}
- return MountNodeSocket::GetSockOpt(lvl, optname, optval, len);
+ return SocketNode::GetSockOpt(lvl, optname, optval, len);
}
-
-Error MountNodeTCP::SetNoDelay_Locked() {
+Error TcpNode::SetNoDelay_Locked() {
if (!IsConnected())
return 0;
- int32_t error = TCPInterface()->SetOption(socket_resource_,
- PP_TCPSOCKET_OPTION_NO_DELAY,
- PP_MakeBool(tcp_nodelay_ ? PP_TRUE : PP_FALSE),
- PP_BlockUntilComplete());
+ int32_t error =
+ TCPInterface()->SetOption(socket_resource_,
+ PP_TCPSOCKET_OPTION_NO_DELAY,
+ PP_MakeBool(tcp_nodelay_ ? PP_TRUE : PP_FALSE),
+ PP_BlockUntilComplete());
return PPErrorToErrno(error);
}
-Error MountNodeTCP::SetSockOpt(int lvl,
- int optname,
- const void* optval,
- socklen_t len) {
+Error TcpNode::SetSockOpt(int lvl,
+ int optname,
+ const void* optval,
+ socklen_t len) {
if (lvl == IPPROTO_TCP && optname == TCP_NODELAY) {
if (len < sizeof(int))
return EINVAL;
@@ -363,25 +352,25 @@ Error MountNodeTCP::SetSockOpt(int lvl,
return SetNoDelay_Locked();
}
- return MountNodeSocket::SetSockOpt(lvl, optname, optval, len);
+ return SocketNode::SetSockOpt(lvl, optname, optval, len);
}
-void MountNodeTCP::QueueAccept() {
- MountStream::Work* work = new TCPAcceptWork(mount_stream(), emitter_);
- mount_stream()->EnqueueWork(work);
+void TcpNode::QueueAccept() {
+ StreamFs::Work* work = new TCPAcceptWork(stream(), emitter_);
+ stream()->EnqueueWork(work);
}
-void MountNodeTCP::QueueConnect() {
- MountStream::Work* work = new TCPConnectWork(mount_stream(), emitter_);
- mount_stream()->EnqueueWork(work);
+void TcpNode::QueueConnect() {
+ StreamFs::Work* work = new TCPConnectWork(stream(), emitter_);
+ stream()->EnqueueWork(work);
}
-void MountNodeTCP::QueueInput() {
- MountStream::Work* work = new TCPRecvWork(emitter_);
- mount_stream()->EnqueueWork(work);
+void TcpNode::QueueInput() {
+ StreamFs::Work* work = new TcpRecvWork(emitter_);
+ stream()->EnqueueWork(work);
}
-void MountNodeTCP::QueueOutput() {
+void TcpNode::QueueOutput() {
if (TestStreamFlags(SSF_SENDING))
return;
@@ -391,15 +380,14 @@ void MountNodeTCP::QueueOutput() {
if (0 == emitter_->BytesInOutputFIFO())
return;
- MountStream::Work* work = new TCPSendWork(emitter_,
- ScopedMountNodeSocket(this));
- mount_stream()->EnqueueWork(work);
+ StreamFs::Work* work = new TcpSendWork(emitter_, ScopedSocketNode(this));
+ stream()->EnqueueWork(work);
}
-Error MountNodeTCP::Accept(const HandleAttr& attr,
- PP_Resource* out_sock,
- struct sockaddr* addr,
- socklen_t* len) {
+Error TcpNode::Accept(const HandleAttr& attr,
+ PP_Resource* out_sock,
+ struct sockaddr* addr,
+ socklen_t* len) {
EventListenerLock wait(GetEventEmitter());
if (!TestStreamFlags(SSF_LISTENING))
@@ -424,7 +412,7 @@ Error MountNodeTCP::Accept(const HandleAttr& attr,
// Set the out paramaters
PP_Resource remote_addr = TCPInterface()->GetRemoteAddress(*out_sock);
*len = ResourceToSockAddr(remote_addr, *len, addr);
- mount_->ppapi()->ReleaseResource(remote_addr);
+ filesystem_->ppapi()->ReleaseResource(remote_addr);
QueueAccept();
return 0;
@@ -434,7 +422,7 @@ Error MountNodeTCP::Accept(const HandleAttr& attr,
// bind but report the correct address later, just in case someone is
// binding without really caring what the address is (for example to
// select a more optimized interface/route.)
-Error MountNodeTCP::Bind(const struct sockaddr* addr, socklen_t len) {
+Error TcpNode::Bind(const struct sockaddr* addr, socklen_t len) {
AUTO_LOCK(node_lock_);
/* Only bind once. */
@@ -442,13 +430,12 @@ Error MountNodeTCP::Bind(const struct sockaddr* addr, socklen_t len) {
return EINVAL;
local_addr_ = SockAddrToResource(addr, len);
- int err = TCPInterface()->Bind(socket_resource_,
- local_addr_,
- PP_BlockUntilComplete());
+ int err = TCPInterface()->Bind(
+ socket_resource_, local_addr_, PP_BlockUntilComplete());
// If we fail, release the local addr resource
if (err != PP_OK) {
- mount_->ppapi()->ReleaseResource(local_addr_);
+ filesystem_->ppapi()->ReleaseResource(local_addr_);
local_addr_ = 0;
return PPErrorToErrno(err);
}
@@ -456,9 +443,9 @@ Error MountNodeTCP::Bind(const struct sockaddr* addr, socklen_t len) {
return 0;
}
-Error MountNodeTCP::Connect(const HandleAttr& attr,
- const struct sockaddr* addr,
- socklen_t len) {
+Error TcpNode::Connect(const HandleAttr& attr,
+ const struct sockaddr* addr,
+ socklen_t len) {
EventListenerLock wait(GetEventEmitter());
if (TestStreamFlags(SSF_CONNECTING))
@@ -490,7 +477,7 @@ Error MountNodeTCP::Connect(const HandleAttr& attr,
return 0;
}
-Error MountNodeTCP::Shutdown(int how) {
+Error TcpNode::Shutdown(int how) {
AUTO_LOCK(node_lock_);
if (!IsConnected())
return ENOTCONN;
@@ -501,7 +488,7 @@ Error MountNodeTCP::Shutdown(int how) {
return 0;
}
-void MountNodeTCP::ConnectDone_Locked() {
+void TcpNode::ConnectDone_Locked() {
local_addr_ = TCPInterface()->GetLocalAddress(socket_resource_);
// Now that we are connected, we can start sending and receiving.
@@ -518,19 +505,18 @@ void MountNodeTCP::ConnectDone_Locked() {
QueueInput();
}
-void MountNodeTCP::ConnectFailed_Locked() {
- mount_->ppapi()->ReleaseResource(remote_addr_);
+void TcpNode::ConnectFailed_Locked() {
+ filesystem_->ppapi()->ReleaseResource(remote_addr_);
remote_addr_ = 0;
}
-Error MountNodeTCP::Listen(int backlog) {
+Error TcpNode::Listen(int backlog) {
AUTO_LOCK(node_lock_);
if (!IsBound())
return EINVAL;
- int err = TCPInterface()->Listen(socket_resource_,
- backlog,
- PP_BlockUntilComplete());
+ int err = TCPInterface()->Listen(
+ socket_resource_, backlog, PP_BlockUntilComplete());
if (err != PP_OK)
return PPErrorToErrno(err);
@@ -541,24 +527,24 @@ Error MountNodeTCP::Listen(int backlog) {
return 0;
}
-Error MountNodeTCP::Recv_Locked(void* buf,
- size_t len,
- PP_Resource* out_addr,
- int* out_len) {
+Error TcpNode::Recv_Locked(void* buf,
+ size_t len,
+ PP_Resource* out_addr,
+ int* out_len) {
assert(emitter_.get());
*out_len = emitter_->ReadIn_Locked((char*)buf, len);
*out_addr = remote_addr_;
// Ref the address copy we pass back.
- mount_->ppapi()->AddRefResource(remote_addr_);
+ filesystem_->ppapi()->AddRefResource(remote_addr_);
return 0;
}
// TCP ignores dst addr passed to send_to, and always uses bound address
-Error MountNodeTCP::Send_Locked(const void* buf,
- size_t len,
- PP_Resource,
- int* out_len) {
+Error TcpNode::Send_Locked(const void* buf,
+ size_t len,
+ PP_Resource,
+ int* out_len) {
assert(emitter_.get());
if (emitter_->GetError_Locked())
return EPIPE;
@@ -566,7 +552,6 @@ Error MountNodeTCP::Send_Locked(const void* buf,
return 0;
}
-
} // namespace nacl_io
#endif // PROVIDES_SOCKET_API
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_tcp.h b/native_client_sdk/src/libraries/nacl_io/socket/tcp_node.h
index 6b45bc4..6b2686c 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_tcp.h
+++ b/native_client_sdk/src/libraries/nacl_io/socket/tcp_node.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_TCP_H_
-#define LIBRARIES_NACL_IO_MOUNT_NODE_TCP_H_
+#ifndef LIBRARIES_NACL_IO_SOCKET_TCP_NODE_H_
+#define LIBRARIES_NACL_IO_SOCKET_TCP_NODE_H_
#include "nacl_io/ossocket.h"
#ifdef PROVIDES_SOCKET_API
@@ -11,16 +11,16 @@
#include <ppapi/c/pp_resource.h>
#include <ppapi/c/ppb_tcp_socket.h>
-#include "nacl_io/event_emitter_tcp.h"
-#include "nacl_io/mount_node.h"
-#include "nacl_io/mount_node_socket.h"
+#include "nacl_io/node.h"
+#include "nacl_io/socket/socket_node.h"
+#include "nacl_io/socket/tcp_event_emitter.h"
namespace nacl_io {
-class MountNodeTCP : public MountNodeSocket {
+class TcpNode : public SocketNode {
public:
- explicit MountNodeTCP(Mount* mount);
- MountNodeTCP(Mount* mount, PP_Resource socket);
+ explicit TcpNode(Filesystem* filesystem);
+ TcpNode(Filesystem* filesystem, PP_Resource socket);
protected:
virtual Error Init(int open_flags);
@@ -42,10 +42,7 @@ class MountNodeTCP : public MountNodeSocket {
virtual Error Connect(const HandleAttr& attr,
const struct sockaddr* addr,
socklen_t len);
- virtual Error GetSockOpt(int lvl,
- int optname,
- void* optval,
- socklen_t* len);
+ virtual Error GetSockOpt(int lvl, int optname, void* optval, socklen_t* len);
virtual Error Listen(int backlog);
virtual Error SetSockOpt(int lvl,
int optname,
@@ -69,13 +66,12 @@ class MountNodeTCP : public MountNodeSocket {
PP_Resource addr,
int* out_len);
- ScopedEventEmitterTCP emitter_;
+ ScopedTcpEventEmitter emitter_;
PP_Resource accepted_socket_;
bool tcp_nodelay_;
};
-
} // namespace nacl_io
#endif // PROVIDES_SOCKET_API
-#endif // LIBRARIES_NACL_IO_MOUNT_NODE_TCP_H_
+#endif // LIBRARIES_NACL_IO_SOCKET_TCP_NODE_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/event_emitter_udp.cc b/native_client_sdk/src/libraries/nacl_io/socket/udp_event_emitter.cc
index 8b64526a..3c88d03 100644
--- a/native_client_sdk/src/libraries/nacl_io/event_emitter_udp.cc
+++ b/native_client_sdk/src/libraries/nacl_io/socket/udp_event_emitter.cc
@@ -2,43 +2,39 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/event_emitter_udp.h"
-
-#include <poll.h>
-#include <stdint.h>
-#include <stdlib.h>
+#include "nacl_io/socket/udp_event_emitter.h"
#include "sdk_util/auto_lock.h"
namespace nacl_io {
-EventEmitterUDP::EventEmitterUDP(size_t rsize, size_t wsize)
+UdpEventEmitter::UdpEventEmitter(size_t rsize, size_t wsize)
: in_fifo_(rsize),
out_fifo_(wsize) {
UpdateStatus_Locked();
}
-Packet* EventEmitterUDP::ReadRXPacket_Locked() {
+Packet* UdpEventEmitter::ReadRXPacket_Locked() {
Packet* packet = in_fifo_.ReadPacket();
UpdateStatus_Locked();
return packet;
}
-void EventEmitterUDP::WriteRXPacket_Locked(Packet* packet) {
+void UdpEventEmitter::WriteRXPacket_Locked(Packet* packet) {
in_fifo_.WritePacket(packet);
UpdateStatus_Locked();
}
-Packet* EventEmitterUDP::ReadTXPacket_Locked() {
+Packet* UdpEventEmitter::ReadTXPacket_Locked() {
Packet* packet = out_fifo_.ReadPacket();
UpdateStatus_Locked();
return packet;
}
-void EventEmitterUDP::WriteTXPacket_Locked(Packet* packet) {
+void UdpEventEmitter::WriteTXPacket_Locked(Packet* packet) {
out_fifo_.WritePacket(packet);
UpdateStatus_Locked();
diff --git a/native_client_sdk/src/libraries/nacl_io/event_emitter_udp.h b/native_client_sdk/src/libraries/nacl_io/socket/udp_event_emitter.h
index cb64fbc..33013c5 100644
--- a/native_client_sdk/src/libraries/nacl_io/event_emitter_udp.h
+++ b/native_client_sdk/src/libraries/nacl_io/socket/udp_event_emitter.h
@@ -2,23 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_EVENT_EMITTER_UDP_H_
-#define LIBRARIES_NACL_IO_EVENT_EMITTER_UDP_H_
+#ifndef LIBRARIES_NACL_IO_SOCKET_UDP_EVENT_EMITTER_H_
+#define LIBRARIES_NACL_IO_SOCKET_UDP_EVENT_EMITTER_H_
-#include "nacl_io/event_emitter_stream.h"
-#include "nacl_io/fifo_packet.h"
+#include "nacl_io/socket/fifo_packet.h"
+#include "nacl_io/stream/stream_event_emitter.h"
#include "sdk_util/macros.h"
#include "sdk_util/scoped_ref.h"
namespace nacl_io {
-class EventEmitterUDP;
-typedef sdk_util::ScopedRef<EventEmitterUDP> ScopedEventEmitterUDP;
+class UdpEventEmitter;
+typedef sdk_util::ScopedRef<UdpEventEmitter> ScopedUdpEventEmitter;
-class EventEmitterUDP : public EventEmitterStream {
+class UdpEventEmitter : public StreamEventEmitter {
public:
- EventEmitterUDP(size_t rsize, size_t wsize);
+ UdpEventEmitter(size_t rsize, size_t wsize);
// Takes or gives away ownership of the packet.
Packet* ReadRXPacket_Locked();
@@ -34,10 +34,9 @@ protected:
private:
FIFOPacket in_fifo_;
FIFOPacket out_fifo_;
- DISALLOW_COPY_AND_ASSIGN(EventEmitterUDP);
+ DISALLOW_COPY_AND_ASSIGN(UdpEventEmitter);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_EVENT_EMITTER_UDP_H_
-
+#endif // LIBRARIES_NACL_IO_SOCKET_UDP_EVENT_EMITTER_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_udp.cc b/native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc
index c35a8f5..a0f759c 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_udp.cc
+++ b/native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc
@@ -2,52 +2,48 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
-#include "nacl_io/mount_node_udp.h"
+#include "nacl_io/socket/udp_node.h"
#include <errno.h>
#include <string.h>
#include <algorithm>
-#include "nacl_io/event_emitter_udp.h"
-#include "nacl_io/mount_stream.h"
-#include "nacl_io/packet.h"
#include "nacl_io/pepper_interface.h"
+#include "nacl_io/socket/packet.h"
+#include "nacl_io/socket/udp_event_emitter.h"
+#include "nacl_io/stream/stream_fs.h"
namespace {
- const size_t kMaxPacketSize = 65536;
- const size_t kDefaultFifoSize = kMaxPacketSize * 8;
+const size_t kMaxPacketSize = 65536;
+const size_t kDefaultFifoSize = kMaxPacketSize * 8;
}
namespace nacl_io {
-class UDPWork : public MountStream::Work {
+class UdpWork : public StreamFs::Work {
public:
- explicit UDPWork(const ScopedEventEmitterUDP& emitter)
- : MountStream::Work(emitter->stream()->mount_stream()),
+ explicit UdpWork(const ScopedUdpEventEmitter& emitter)
+ : StreamFs::Work(emitter->stream()->stream()),
emitter_(emitter),
- packet_(NULL) {
- }
+ packet_(NULL) {}
- ~UDPWork() {
- delete packet_;
- }
+ ~UdpWork() { delete packet_; }
UDPSocketInterface* UDPInterface() {
- return mount()->ppapi()->GetUDPSocketInterface();
+ return filesystem()->ppapi()->GetUDPSocketInterface();
}
protected:
- ScopedEventEmitterUDP emitter_;
+ ScopedUdpEventEmitter emitter_;
Packet* packet_;
};
-class UDPSendWork : public UDPWork {
+class UdpSendWork : public UdpWork {
public:
- explicit UDPSendWork(const ScopedEventEmitterUDP& emitter,
- const ScopedMountNodeSocket& node)
- : UDPWork(emitter), node_(node) {}
+ explicit UdpSendWork(const ScopedUdpEventEmitter& emitter,
+ const ScopedSocketNode& node)
+ : UdpWork(emitter), node_(node) {}
virtual bool Start(int32_t val) {
AUTO_LOCK(emitter_->GetLock());
@@ -64,7 +60,7 @@ class UDPSendWork : public UDPWork {
packet_->buffer(),
packet_->len(),
packet_->addr(),
- mount()->GetRunCompletion(this));
+ filesystem()->GetRunCompletion(this));
if (err != PP_OK_COMPLETIONPENDING) {
// Anything else, we should assume the socket has gone bad.
node_->SetError_Locked(err);
@@ -92,24 +88,21 @@ class UDPSendWork : public UDPWork {
// We assume that transmits will always complete. If the upstream
// actually back pressures, enough to prevent the Send callback
// from triggering, this resource may never go away.
- ScopedMountNodeSocket node_;
+ ScopedSocketNode node_;
};
-
-class UDPRecvWork : public UDPWork {
+class UdpRecvWork : public UdpWork {
public:
- explicit UDPRecvWork(const ScopedEventEmitterUDP& emitter)
- : UDPWork(emitter) {
+ explicit UdpRecvWork(const ScopedUdpEventEmitter& emitter)
+ : UdpWork(emitter) {
data_ = new char[kMaxPacketSize];
}
- ~UDPRecvWork() {
- delete[] data_;
- }
+ ~UdpRecvWork() { delete[] data_; }
virtual bool Start(int32_t val) {
AUTO_LOCK(emitter_->GetLock());
- MountNodeUDP* stream = static_cast<MountNodeUDP*>(emitter_->stream());
+ UdpNode* stream = static_cast<UdpNode*>(emitter_->stream());
// Does the stream exist, and can it recv?
if (NULL == stream || !stream->TestStreamFlags(SSF_CAN_RECV))
@@ -124,7 +117,7 @@ class UDPRecvWork : public UDPWork {
data_,
kMaxPacketSize,
&addr_,
- mount()->GetRunCompletion(this));
+ filesystem()->GetRunCompletion(this));
if (err != PP_OK_COMPLETIONPENDING) {
stream->SetError_Locked(err);
return false;
@@ -135,13 +128,13 @@ class UDPRecvWork : public UDPWork {
virtual void Run(int32_t length_error) {
AUTO_LOCK(emitter_->GetLock());
- MountNodeUDP* stream = static_cast<MountNodeUDP*>(emitter_->stream());
+ UdpNode* stream = static_cast<UdpNode*>(emitter_->stream());
if (NULL == stream)
return;
// On successful receive we queue more input
if (length_error > 0) {
- Packet* packet = new Packet(mount()->ppapi());
+ Packet* packet = new Packet(filesystem()->ppapi());
packet->Copy(data_, length_error, addr_);
emitter_->WriteRXPacket_Locked(packet);
stream->ClearStreamFlags(SSF_RECVING);
@@ -156,54 +149,52 @@ class UDPRecvWork : public UDPWork {
PP_Resource addr_;
};
-
-MountNodeUDP::MountNodeUDP(Mount* mount)
- : MountNodeSocket(mount),
- emitter_(new EventEmitterUDP(kDefaultFifoSize, kDefaultFifoSize)) {
+UdpNode::UdpNode(Filesystem* filesystem)
+ : SocketNode(filesystem),
+ emitter_(new UdpEventEmitter(kDefaultFifoSize, kDefaultFifoSize)) {
emitter_->AttachStream(this);
}
-void MountNodeUDP::Destroy() {
+void UdpNode::Destroy() {
emitter_->DetachStream();
- MountNodeSocket::Destroy();
+ SocketNode::Destroy();
}
-EventEmitterUDP* MountNodeUDP::GetEventEmitter() {
- return emitter_.get();
-}
+UdpEventEmitter* UdpNode::GetEventEmitter() { return emitter_.get(); }
-Error MountNodeUDP::Init(int open_flags) {
- Error err = MountNodeSocket::Init(open_flags);
+Error UdpNode::Init(int open_flags) {
+ Error err = SocketNode::Init(open_flags);
if (err != 0)
return err;
if (UDPInterface() == NULL)
return EACCES;
- socket_resource_ = UDPInterface()->Create(mount_->ppapi()->GetInstance());
+ socket_resource_ =
+ UDPInterface()->Create(filesystem_->ppapi()->GetInstance());
if (0 == socket_resource_)
return EACCES;
return 0;
}
-void MountNodeUDP::QueueInput() {
- UDPRecvWork* work = new UDPRecvWork(emitter_);
- mount_stream()->EnqueueWork(work);
+void UdpNode::QueueInput() {
+ UdpRecvWork* work = new UdpRecvWork(emitter_);
+ stream()->EnqueueWork(work);
}
-void MountNodeUDP::QueueOutput() {
+void UdpNode::QueueOutput() {
if (!TestStreamFlags(SSF_CAN_SEND))
return;
if (TestStreamFlags(SSF_SENDING))
return;
- UDPSendWork* work = new UDPSendWork(emitter_, ScopedMountNodeSocket(this));
- mount_stream()->EnqueueWork(work);
+ UdpSendWork* work = new UdpSendWork(emitter_, ScopedSocketNode(this));
+ stream()->EnqueueWork(work);
}
-Error MountNodeUDP::Bind(const struct sockaddr* addr, socklen_t len) {
+Error UdpNode::Bind(const struct sockaddr* addr, socklen_t len) {
if (0 == socket_resource_)
return EBADF;
@@ -215,10 +206,9 @@ Error MountNodeUDP::Bind(const struct sockaddr* addr, socklen_t len) {
if (0 == out_addr)
return EINVAL;
- int err = UDPInterface()->Bind(socket_resource_,
- out_addr,
- PP_BlockUntilComplete());
- mount_->ppapi()->ReleaseResource(out_addr);
+ int err =
+ UDPInterface()->Bind(socket_resource_, out_addr, PP_BlockUntilComplete());
+ filesystem_->ppapi()->ReleaseResource(out_addr);
if (err != 0)
return PPErrorToErrno(err);
@@ -235,15 +225,15 @@ Error MountNodeUDP::Bind(const struct sockaddr* addr, socklen_t len) {
return 0;
}
-Error MountNodeUDP::Connect(const HandleAttr& attr,
- const struct sockaddr* addr,
- socklen_t len) {
+Error UdpNode::Connect(const HandleAttr& attr,
+ const struct sockaddr* addr,
+ socklen_t len) {
if (0 == socket_resource_)
return EBADF;
/* Connect for UDP is the default dest, it's legal to change it. */
if (remote_addr_ != 0) {
- mount_->ppapi()->ReleaseResource(remote_addr_);
+ filesystem_->ppapi()->ReleaseResource(remote_addr_);
remote_addr_ = 0;
}
@@ -254,21 +244,20 @@ Error MountNodeUDP::Connect(const HandleAttr& attr,
return 0;
}
-Error MountNodeUDP::Recv_Locked(void* buf,
- size_t len,
- PP_Resource* out_addr,
- int* out_len) {
+Error UdpNode::Recv_Locked(void* buf,
+ size_t len,
+ PP_Resource* out_addr,
+ int* out_len) {
Packet* packet = emitter_->ReadRXPacket_Locked();
*out_len = 0;
*out_addr = 0;
if (packet) {
- int capped_len =
- static_cast<int32_t>(std::min<int>(len, packet->len()));
+ int capped_len = static_cast<int32_t>(std::min<int>(len, packet->len()));
memcpy(buf, packet->buffer(), capped_len);
if (packet->addr() != 0) {
- mount_->ppapi()->AddRefResource(packet->addr());
+ filesystem_->ppapi()->AddRefResource(packet->addr());
*out_addr = packet->addr();
}
@@ -282,10 +271,10 @@ Error MountNodeUDP::Recv_Locked(void* buf,
return EBADF;
}
-Error MountNodeUDP::Send_Locked(const void* buf,
- size_t len,
- PP_Resource addr,
- int* out_len) {
+Error UdpNode::Send_Locked(const void* buf,
+ size_t len,
+ PP_Resource addr,
+ int* out_len) {
if (!IsBound()) {
// Pepper requires a socket to be bound before it can send.
sockaddr_in addr;
@@ -299,9 +288,8 @@ Error MountNodeUDP::Send_Locked(const void* buf,
}
*out_len = 0;
- int capped_len =
- static_cast<int32_t>(std::min<int>(len, kMaxPacketSize));
- Packet* packet = new Packet(mount_->ppapi());
+ int capped_len = static_cast<int32_t>(std::min<int>(len, kMaxPacketSize));
+ Packet* packet = new Packet(filesystem_->ppapi());
packet->Copy(buf, capped_len, addr);
emitter_->WriteTXPacket_Locked(packet);
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_udp.h b/native_client_sdk/src/libraries/nacl_io/socket/udp_node.h
index 95f2889..be8cf05 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_udp.h
+++ b/native_client_sdk/src/libraries/nacl_io/socket/udp_node.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_UDP_H_
-#define LIBRARIES_NACL_IO_MOUNT_NODE_UDP_H_
+#ifndef LIBRARIES_NACL_IO_SOCKET_UDP_NODE_H_
+#define LIBRARIES_NACL_IO_SOCKET_UDP_NODE_H_
#include "nacl_io/ossocket.h"
#ifdef PROVIDES_SOCKET_API
@@ -11,22 +11,21 @@
#include <ppapi/c/pp_resource.h>
#include <ppapi/c/ppb_udp_socket.h>
-#include "nacl_io/event_emitter_udp.h"
-#include "nacl_io/mount_node.h"
-#include "nacl_io/mount_node_socket.h"
+#include "nacl_io/socket/socket_node.h"
+#include "nacl_io/socket/udp_event_emitter.h"
namespace nacl_io {
-class MountNodeUDP : public MountNodeSocket {
+class UdpNode : public SocketNode {
public:
- explicit MountNodeUDP(Mount* mount);
+ explicit UdpNode(Filesystem* filesystem);
protected:
virtual Error Init(int open_flags);
virtual void Destroy();
public:
- virtual EventEmitterUDP* GetEventEmitter();
+ virtual UdpEventEmitter* GetEventEmitter();
virtual void QueueInput();
virtual void QueueOutput();
@@ -47,11 +46,10 @@ class MountNodeUDP : public MountNodeSocket {
PP_Resource addr,
int* out_len);
- ScopedEventEmitterUDP emitter_;
+ ScopedUdpEventEmitter emitter_;
};
-
} // namespace nacl_io
#endif // PROVIDES_SOCKET_API
-#endif // LIBRARIES_NACL_IO_MOUNT_NODE_UDP_H_
+#endif // LIBRARIES_NACL_IO_SOCKET_UDP_NODE_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/event_emitter_stream.cc b/native_client_sdk/src/libraries/nacl_io/stream/stream_event_emitter.cc
index 5c636ab..a36f5d1 100644
--- a/native_client_sdk/src/libraries/nacl_io/event_emitter_stream.cc
+++ b/native_client_sdk/src/libraries/nacl_io/stream/stream_event_emitter.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/event_emitter_stream.h"
+#include "nacl_io/stream/stream_event_emitter.h"
#include <poll.h>
#include <stdint.h>
@@ -13,21 +13,21 @@
namespace nacl_io {
-EventEmitterStream::EventEmitterStream() : stream_(NULL) {}
+StreamEventEmitter::StreamEventEmitter() : stream_(NULL) {}
-void EventEmitterStream::AttachStream(MountNodeStream* stream) {
+void StreamEventEmitter::AttachStream(StreamNode* stream) {
AUTO_LOCK(GetLock());
stream_ = stream;
}
-void EventEmitterStream::DetachStream() {
+void StreamEventEmitter::DetachStream() {
AUTO_LOCK(GetLock());
RaiseEvents_Locked(POLLHUP);
stream_ = NULL;
}
-void EventEmitterStream::UpdateStatus_Locked() {
+void StreamEventEmitter::UpdateStatus_Locked() {
uint32_t status = 0;
if (!in_fifo()->IsEmpty())
status |= POLLIN;
@@ -39,11 +39,11 @@ void EventEmitterStream::UpdateStatus_Locked() {
RaiseEvents_Locked(status);
}
-uint32_t EventEmitterStream::BytesInOutputFIFO() {
+uint32_t StreamEventEmitter::BytesInOutputFIFO() {
return out_fifo()->ReadAvailable();
}
-uint32_t EventEmitterStream::SpaceInInputFIFO() {
+uint32_t StreamEventEmitter::SpaceInInputFIFO() {
return in_fifo()->WriteAvailable();
}
diff --git a/native_client_sdk/src/libraries/nacl_io/event_emitter_stream.h b/native_client_sdk/src/libraries/nacl_io/stream/stream_event_emitter.h
index 1b40b01..9514ad6 100644
--- a/native_client_sdk/src/libraries/nacl_io/event_emitter_stream.h
+++ b/native_client_sdk/src/libraries/nacl_io/stream/stream_event_emitter.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_EVENT_EMITTER_STREAM_H_
-#define LIBRARIES_NACL_IO_EVENT_EMITTER_STREAM_H_
+#ifndef LIBRARIES_NACL_IO_STREAM_STREAM_EVENT_EMITTER_H_
+#define LIBRARIES_NACL_IO_STREAM_STREAM_EVENT_EMITTER_H_
#include "nacl_io/event_emitter.h"
@@ -12,20 +12,20 @@
namespace nacl_io {
-class EventEmitterStream;
class FIFOInterface;
-class MountNodeStream;
+class StreamEventEmitter;
+class StreamNode;
-typedef sdk_util::ScopedRef<EventEmitterStream> ScopedEventEmitterStream;
+typedef sdk_util::ScopedRef<StreamEventEmitter> ScopedStreamEventEmitter;
-class EventEmitterStream : public EventEmitter {
+class StreamEventEmitter : public EventEmitter {
public:
- EventEmitterStream();
+ StreamEventEmitter();
- void AttachStream(MountNodeStream* stream);
+ void AttachStream(StreamNode* stream);
void DetachStream();
- MountNodeStream* stream() { return stream_; }
+ StreamNode* stream() { return stream_; }
uint32_t BytesInOutputFIFO();
uint32_t SpaceInInputFIFO();
@@ -36,11 +36,10 @@ protected:
void UpdateStatus_Locked();
protected:
- MountNodeStream* stream_;
- DISALLOW_COPY_AND_ASSIGN(EventEmitterStream);
+ StreamNode* stream_;
+ DISALLOW_COPY_AND_ASSIGN(StreamEventEmitter);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_EVENT_EMITTER_STREAM_H_
-
+#endif // LIBRARIES_NACL_IO_STREAM_STREAM_EVENT_EMITTER_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_stream.cc b/native_client_sdk/src/libraries/nacl_io/stream/stream_fs.cc
index e7b23ef..03c90d8 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_stream.cc
+++ b/native_client_sdk/src/libraries/nacl_io/stream/stream_fs.cc
@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/ossocket.h"
+#include "nacl_io/stream/stream_fs.h"
#include <errno.h>
-#include "nacl_io/mount_stream.h"
+#include "nacl_io/ossocket.h"
#include "nacl_io/pepper_interface.h"
namespace nacl_io {
void DispatchStart(void* work_ptr, int32_t val) {
- MountStream::Work* work = static_cast<MountStream::Work*>(work_ptr);
+ StreamFs::Work* work = static_cast<StreamFs::Work*>(work_ptr);
// Delete if it fails to Start, Run will never get called.
if (!work->Start(val))
@@ -20,20 +20,20 @@ void DispatchStart(void* work_ptr, int32_t val) {
}
void DispatchRun(void* work_ptr, int32_t val) {
- MountStream::Work* work = static_cast<MountStream::Work*>(work_ptr);
+ StreamFs::Work* work = static_cast<StreamFs::Work*>(work_ptr);
work->Run(val);
delete work;
}
-void* MountStream::StreamThreadThunk(void* mount_ptr) {
- MountStream* mount = static_cast<MountStream*>(mount_ptr);
- mount->StreamThread();
+void* StreamFs::StreamThreadThunk(void* fs_ptr) {
+ StreamFs* filesystem = static_cast<StreamFs*>(fs_ptr);
+ filesystem->StreamThread();
return NULL;
}
// All work is done via completions callbacks from posted work.
-void MountStream::StreamThread() {
+void StreamFs::StreamThread() {
{
AUTO_LOCK(message_lock_)
message_loop_ =
@@ -46,16 +46,16 @@ void MountStream::StreamThread() {
ppapi_->GetMessageLoopInterface()->Run(message_loop_);
}
-PP_CompletionCallback MountStream::GetStartCompletion(Work* work) {
+PP_CompletionCallback StreamFs::GetStartCompletion(Work* work) {
return PP_MakeCompletionCallback(DispatchStart, work);
}
-PP_CompletionCallback MountStream::GetRunCompletion(Work* work) {
+PP_CompletionCallback StreamFs::GetRunCompletion(Work* work) {
return PP_MakeCompletionCallback(DispatchRun, work);
}
// Place enqueue onto the socket thread.
-void MountStream::EnqueueWork(Work* work) {
+void StreamFs::EnqueueWork(Work* work) {
if (message_loop_ == 0) {
AUTO_LOCK(message_lock_);
@@ -72,12 +72,11 @@ void MountStream::EnqueueWork(Work* work) {
ppapi_->GetMessageLoopInterface()->PostWork(message_loop_, cb, 0);
}
-MountStream::MountStream()
- : message_loop_(0) {
+StreamFs::StreamFs() : message_loop_(0) {
pthread_cond_init(&message_cond_, NULL);
}
-MountStream::~MountStream() {
+StreamFs::~StreamFs() {
if (message_loop_) {
ppapi_->GetMessageLoopInterface()->PostQuit(message_loop_, PP_TRUE);
ppapi_->ReleaseResource(message_loop_);
@@ -85,22 +84,20 @@ MountStream::~MountStream() {
pthread_cond_destroy(&message_cond_);
}
-Error MountStream::Access(const Path& path, int a_mode) { return EACCES; }
+Error StreamFs::Access(const Path& path, int a_mode) { return EACCES; }
-Error MountStream::Open(const Path& path,
- int o_flags,
- ScopedMountNode* out_node) { return EACCES; }
+Error StreamFs::Open(const Path& path, int o_flags, ScopedNode* out_node) {
+ return EACCES;
+}
-Error MountStream::Unlink(const Path& path) { return EACCES; }
+Error StreamFs::Unlink(const Path& path) { return EACCES; }
-Error MountStream::Mkdir(const Path& path, int permissions) { return EACCES; }
+Error StreamFs::Mkdir(const Path& path, int permissions) { return EACCES; }
-Error MountStream::Rmdir(const Path& path) { return EACCES; }
+Error StreamFs::Rmdir(const Path& path) { return EACCES; }
-Error MountStream::Remove(const Path& path) { return EACCES; }
+Error StreamFs::Remove(const Path& path) { return EACCES; }
-Error MountStream::Rename(const Path& path, const Path& newpath) {
- return EACCES;
-}
+Error StreamFs::Rename(const Path& path, const Path& newpath) { return EACCES; }
} // namespace nacl_io
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_stream.h b/native_client_sdk/src/libraries/nacl_io/stream/stream_fs.h
index e03abe7..eeec738 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_stream.h
+++ b/native_client_sdk/src/libraries/nacl_io/stream/stream_fs.h
@@ -2,29 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_MOUNT_STREAM_H_
-#define LIBRARIES_NACL_IO_MOUNT_STREAM_H_
+#ifndef LIBRARIES_NACL_IO_STREAM_STREAM_H_
+#define LIBRARIES_NACL_IO_STREAM_STREAM_H_
-#include "nacl_io/mount.h"
+#include "nacl_io/filesystem.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_resource.h"
-
namespace nacl_io {
-// MountStreams provides a "mount point" for stream objects which do not
-// provide a path, such as FDs returned by pipe, socket, and sockpair. It
-// also provides a background thread for dispatching completion callbacks.
+// StreamFs provides a "mount point" for stream objects which do not provide a
+// path, such as FDs returned by pipe, socket, and sockpair. It also provides
+// a background thread for dispatching completion callbacks.
-class MountStream;
-class MountNodeStream;
+class StreamFs;
+class StreamNode;
-class MountStream : public Mount {
+class StreamFs : public Filesystem {
public:
class Work {
public:
- explicit Work(MountStream* mount) : mount_(mount) {}
+ explicit Work(StreamFs* filesystem) : filesystem_(filesystem) {}
virtual ~Work() {}
// Called by adding work the queue, val should be safe to ignore.
@@ -33,18 +32,18 @@ class MountStream : public Mount {
// Called as a completion of work in Start. Value of val depend on
// the function invoked in Start.
virtual void Run(int32_t val) = 0;
- MountStream* mount() { return mount_; }
+ StreamFs* filesystem() { return filesystem_; }
- private:
- MountStream* mount_;
+ private:
+ StreamFs* filesystem_;
};
protected:
- MountStream();
- virtual ~MountStream();
+ StreamFs();
+ virtual ~StreamFs();
public:
- // Enqueue a work object onto this MountStream's thread
+ // Enqueue a work object onto this StreamFs's thread
void EnqueueWork(Work* work);
// Returns a completion callback which will execute the StartWork member
@@ -56,9 +55,7 @@ class MountStream : public Mount {
static PP_CompletionCallback GetRunCompletion(Work* work);
virtual Error Access(const Path& path, int a_mode);
- virtual Error Open(const Path& path,
- int o_flags,
- ScopedMountNode* out_node);
+ virtual Error Open(const Path& path, int o_flags, ScopedNode* out_node);
virtual Error Unlink(const Path& path);
virtual Error Mkdir(const Path& path, int permissions);
virtual Error Rmdir(const Path& path);
@@ -74,9 +71,9 @@ class MountStream : public Mount {
sdk_util::SimpleLock message_lock_;
friend class KernelProxy;
- DISALLOW_COPY_AND_ASSIGN(MountStream);
+ DISALLOW_COPY_AND_ASSIGN(StreamFs);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_MOUNT_STREAM_H_
+#endif // LIBRARIES_NACL_IO_STREAM_STREAM_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/stream/stream_node.cc b/native_client_sdk/src/libraries/nacl_io/stream/stream_node.cc
new file mode 100644
index 0000000..2802213
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/stream/stream_node.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "nacl_io/stream/stream_node.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <string.h>
+
+#include "nacl_io/ioctl.h"
+#include "nacl_io/stream/stream_fs.h"
+#include "sdk_util/atomicops.h"
+
+namespace nacl_io {
+
+StreamNode::StreamNode(Filesystem* fs)
+ : Node(fs),
+ read_timeout_(-1),
+ write_timeout_(-1),
+ stream_state_flags_(0) {}
+
+Error StreamNode::Init(int open_flags) {
+ Node::Init(open_flags);
+ if (open_flags & O_NONBLOCK)
+ SetStreamFlags(SSF_NON_BLOCK);
+
+ return 0;
+}
+
+void StreamNode::SetStreamFlags(uint32_t bits) {
+ sdk_util::AtomicOrFetch(&stream_state_flags_, bits);
+}
+
+void StreamNode::ClearStreamFlags(uint32_t bits) {
+ sdk_util::AtomicAndFetch(&stream_state_flags_, ~bits);
+}
+
+uint32_t StreamNode::GetStreamFlags() { return stream_state_flags_; }
+
+bool StreamNode::TestStreamFlags(uint32_t bits) {
+ return (stream_state_flags_ & bits) == bits;
+}
+
+void StreamNode::QueueInput() {}
+void StreamNode::QueueOutput() {}
+
+StreamFs* StreamNode::stream() { return static_cast<StreamFs*>(filesystem_); }
+
+} // namespace nacl_io
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_stream.h b/native_client_sdk/src/libraries/nacl_io/stream/stream_node.h
index fedd5ab..554fdf3 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_stream.h
+++ b/native_client_sdk/src/libraries/nacl_io/stream/stream_node.h
@@ -2,22 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_STREAM_H_
-#define LIBRARIES_NACL_IO_MOUNT_NODE_STREAM_H_
+#ifndef LIBRARIES_NACL_IO_STREAM_STREAM_NODE_H_
+#define LIBRARIES_NACL_IO_STREAM_STREAM_NODE_H_
#include <map>
#include <string>
-#include "nacl_io/event_emitter_pipe.h"
-#include "nacl_io/mount_node.h"
+#include "nacl_io/node.h"
+#include "nacl_io/pipe/pipe_event_emitter.h"
#include "sdk_util/atomicops.h"
namespace nacl_io {
-class MountNodeStream;
-class MountStream;
+class StreamNode;
+class StreamFs;
-typedef sdk_util::ScopedRef<MountNodeStream> ScopedMountNodeStream;
+typedef sdk_util::ScopedRef<StreamNode> ScopedStreamNode;
enum StreamStateFlags {
SSF_CONNECTING = 0x0001,
@@ -34,10 +34,9 @@ enum StreamStateFlags {
SSF_CLOSED = 0x8000
};
-
-class MountNodeStream : public MountNode {
+class StreamNode : public Node {
public:
- explicit MountNodeStream(Mount* mnt);
+ explicit StreamNode(Filesystem* fs);
virtual Error Init(int open_flags);
@@ -50,7 +49,7 @@ class MountNodeStream : public MountNode {
uint32_t GetStreamFlags();
bool TestStreamFlags(uint32_t bits);
- MountStream* mount_stream();
+ StreamFs* stream();
protected:
int read_timeout_;
@@ -62,4 +61,4 @@ class MountNodeStream : public MountNode {
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_MOUNT_NODE_STREAM_H_
+#endif // LIBRARIES_NACL_IO_STREAM_STREAM_NODE_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/typed_fs_factory.h b/native_client_sdk/src/libraries/nacl_io/typed_fs_factory.h
new file mode 100644
index 0000000..9c1aa1c1
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/typed_fs_factory.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIBRARIES_NACL_IO_TYPED_FS_FACTORY_H_
+#define LIBRARIES_NACL_IO_TYPED_FS_FACTORY_H_
+
+#include "nacl_io/filesystem.h"
+#include "nacl_io/fs_factory.h"
+
+namespace nacl_io {
+
+template <typename T>
+class TypedFsFactory : public FsFactory {
+ public:
+ virtual Error CreateFilesystem(const FsInitArgs& args,
+ ScopedFilesystem* out_fs) {
+ sdk_util::ScopedRef<T> fs(new T());
+ Error error = fs->Init(args);
+ if (error)
+ return error;
+
+ *out_fs = fs;
+ return 0;
+ }
+};
+
+} // namespace nacl_io
+
+#endif // LIBRARIES_NACL_IO_TYPED_FS_FACTORY_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/typed_mount_factory.h b/native_client_sdk/src/libraries/nacl_io/typed_mount_factory.h
deleted file mode 100644
index 805429c..0000000
--- a/native_client_sdk/src/libraries/nacl_io/typed_mount_factory.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIBRARIES_NACL_IO_TYPED_MOUNT_FACTORY_H_
-#define LIBRARIES_NACL_IO_TYPED_MOUNT_FACTORY_H_
-
-#include "nacl_io/mount.h"
-#include "nacl_io/mount_factory.h"
-
-namespace nacl_io {
-
-template <typename T>
-class TypedMountFactory : public MountFactory {
- public:
- virtual Error CreateMount(const MountInitArgs& args,
- ScopedMount* out_mount) {
- sdk_util::ScopedRef<T> mnt(new T());
- Error error = mnt->Init(args);
- if (error)
- return error;
-
- *out_mount = mnt;
- return 0;
- }
-};
-
-} // namespace nacl_io
-
-#endif // LIBRARIES_NACL_IO_TYPED_MOUNT_FACTORY_H_
diff --git a/native_client_sdk/src/tests/nacl_io_test/dev_fs_for_testing.h b/native_client_sdk/src/tests/nacl_io_test/dev_fs_for_testing.h
new file mode 100644
index 0000000..500cf2a
--- /dev/null
+++ b/native_client_sdk/src/tests/nacl_io_test/dev_fs_for_testing.h
@@ -0,0 +1,23 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIBRARIES_NACL_IO_TEST_DEV_FS_FOR_TESTING_H_
+#define LIBRARIES_NACL_IO_TEST_DEV_FS_FOR_TESTING_H_
+
+#include "gmock/gmock.h"
+
+#include "nacl_io/devfs/dev_fs.h"
+#include "nacl_io/filesystem.h"
+
+#define NULL_NODE ((Node*) NULL)
+
+class DevFsForTesting : public nacl_io::DevFs {
+ public:
+ DevFsForTesting() {
+ Init(nacl_io::FsInitArgs(1));
+ }
+ int num_nodes() { return (int) inode_pool_.size(); }
+};
+
+#endif // LIBRARIES_NACL_IO_TEST_DEV_FS_FOR_TESTING_H_
diff --git a/native_client_sdk/src/tests/nacl_io_test/event_test.cc b/native_client_sdk/src/tests/nacl_io_test/event_test.cc
index 92d9e74..76f5359 100644
--- a/native_client_sdk/src/tests/nacl_io_test/event_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/event_test.cc
@@ -20,16 +20,14 @@
#include "nacl_io/kernel_intercept.h"
#include "nacl_io/kernel_proxy.h"
#include "nacl_io/kernel_wrap.h"
-#include "nacl_io/mount_node_pipe.h"
-#include "nacl_io/mount_stream.h"
+#include "nacl_io/pipe/pipe_node.h"
+#include "nacl_io/stream/stream_fs.h"
#include "ppapi_simple/ps.h"
-
using namespace nacl_io;
using namespace sdk_util;
-
class EventListenerTester : public EventListener {
public:
EventListenerTester() : EventListener(), events_(0) {};
@@ -38,18 +36,13 @@ class EventListenerTester : public EventListener {
events_ |= events;
}
- uint32_t Events() {
- return events_;
- }
+ uint32_t Events() { return events_; }
- void Clear() {
- events_ = 0;
- }
+ void Clear() { events_ = 0; }
uint32_t events_;
};
-
TEST(EmitterBasic, SingleThread) {
EventListenerTester listener_a;
EventListenerTester listener_b;
@@ -85,16 +78,14 @@ class EmitterTest : public ::testing::Test {
signaled_ = 0;
}
- void TearDown() {
- pthread_cond_destroy(&multi_cond_);
- }
+ void TearDown() { pthread_cond_destroy(&multi_cond_); }
void CreateThread() {
pthread_t id;
EXPECT_EQ(0, pthread_create(&id, NULL, ThreadThunk, this));
}
- static void* ThreadThunk(void *ptr) {
+ static void* ThreadThunk(void* ptr) {
return static_cast<EmitterTest*>(ptr)->ThreadEntry();
}
@@ -117,17 +108,16 @@ class EmitterTest : public ::testing::Test {
uint32_t signaled_;
};
-
const int NUM_THREADS = 10;
TEST_F(EmitterTest, MultiThread) {
- for (int a=0; a <NUM_THREADS; a++)
+ for (int a = 0; a < NUM_THREADS; a++)
CreateThread();
{
AUTO_LOCK(emitter_.GetLock());
// Wait for all threads to wait
- while(waiting_ < NUM_THREADS)
+ while (waiting_ < NUM_THREADS)
pthread_cond_wait(&multi_cond_, emitter_.GetLock().mutex());
ASSERT_EQ(0, signaled_);
@@ -136,7 +126,7 @@ TEST_F(EmitterTest, MultiThread) {
}
// sleep for 50 milliseconds
- struct timespec sleeptime = { 0, 50 * 1000 * 1000 };
+ struct timespec sleeptime = {0, 50 * 1000 * 1000};
nanosleep(&sleeptime, NULL);
EXPECT_EQ(1, signaled_);
@@ -162,13 +152,9 @@ TEST(EventListenerPollTest, WaitForAny) {
ScopedEventEmitter emitter3(new EventEmitter());
EventListenerPoll listener;
EventRequest requests[3] = {
- { emitter1, 0, 0 },
- { emitter2, 0, 0 },
- { emitter3, 0, 0 },
- };
- Error error = listener.WaitOnAny(requests,
- sizeof(requests)/sizeof(requests[0]),
- 1);
+ {emitter1, 0, 0}, {emitter2, 0, 0}, {emitter3, 0, 0}, };
+ Error error =
+ listener.WaitOnAny(requests, sizeof(requests) / sizeof(requests[0]), 1);
ASSERT_EQ(ETIMEDOUT, error);
}
@@ -176,7 +162,7 @@ TEST(PipeTest, Listener) {
const char hello[] = "Hello World.";
char tmp[64] = "Goodbye";
- EventEmitterPipe pipe(32);
+ PipeEventEmitter pipe(32);
// Expect to time out on input.
{
@@ -202,17 +188,16 @@ TEST(PipeTest, Listener) {
EXPECT_EQ(0, strcmp(hello, tmp));
}
-
-class TestMountStream : public MountStream {
+class StreamFsForTesting : public StreamFs {
public:
- TestMountStream() {}
+ StreamFsForTesting() {}
};
TEST(PipeNodeTest, Basic) {
- ScopedMount mnt(new TestMountStream());
+ ScopedFilesystem fs(new StreamFsForTesting());
- MountNodePipe* pipe_node = new MountNodePipe(mnt.get());
- ScopedRef<MountNodePipe> pipe(pipe_node);
+ PipeNode* pipe_node = new PipeNode(fs.get());
+ ScopedRef<PipeNode> pipe(pipe_node);
EXPECT_EQ(POLLOUT, pipe_node->GetEventStatus());
}
@@ -229,9 +214,7 @@ class SelectPollTest : public ::testing::Test {
memset(&tv, 0, sizeof(tv));
}
- void TearDown() {
- delete kp;
- }
+ void TearDown() { delete kp; }
void SetFDs(int* fds, int cnt) {
FD_ZERO(&rd_set);
@@ -329,4 +312,3 @@ TEST_F(SelectPollTest, SelectMemPipe) {
EXPECT_EQ(0, FD_ISSET(fds[1], &ex_set));
}
-
diff --git a/native_client_sdk/src/tests/nacl_io_test/example.dsc b/native_client_sdk/src/tests/nacl_io_test/example.dsc
index f2a73e1..becde2a 100644
--- a/native_client_sdk/src/tests/nacl_io_test/example.dsc
+++ b/native_client_sdk/src/tests/nacl_io_test/example.dsc
@@ -7,11 +7,12 @@
'NAME' : 'nacl_io_test',
'TYPE' : 'main',
'SOURCES' : [
+ 'dev_fs_for_testing.h',
'event_test.cc',
'fake_core_interface.cc',
'fake_core_interface.h',
- 'fake_pepper_interface_html5fs.cc',
- 'fake_pepper_interface_html5fs.h',
+ 'fake_pepper_interface_html5_fs.cc',
+ 'fake_pepper_interface_html5_fs.h',
'fake_pepper_interface_url_loader.cc',
'fake_pepper_interface_url_loader.h',
'fake_resource_manager.cc',
@@ -19,28 +20,27 @@
'fake_var_interface.cc',
'fake_var_interface.h',
'fifo_test.cc',
+ 'filesystem_test.cc',
+ 'fuse_fs_test.cc',
+ 'html5_fs_test.cc',
+ 'http_fs_test.cc',
'kernel_object_test.cc',
- 'kernel_proxy_mock.cc',
- 'kernel_proxy_mock.h',
'kernel_proxy_test.cc',
'kernel_wrap_test.cc',
'main.cc',
+ 'mem_fs_node_test.cc',
+ 'mock_fs.cc',
+ 'mock_fs.h',
+ 'mock_kernel_proxy.cc',
+ 'mock_kernel_proxy.h',
+ 'mock_node.cc',
+ 'mock_node.h',
'mock_util.h',
- 'mount_dev_mock.h',
- 'mount_fuse_test.cc',
- 'mount_html5fs_test.cc',
- 'mount_http_test.cc',
- 'mount_mock.cc',
- 'mount_mock.h',
- 'mount_node_mock.cc',
- 'mount_node_mock.h',
- 'mount_node_test.cc',
- 'mount_node_tty_test.cc',
- 'mount_test.cc',
'path_test.cc',
'pepper_interface_mock.cc',
'pepper_interface_mock.h',
'socket_test.cc',
+ 'tty_test.cc',
],
'DEPS': ['ppapi_simple', 'nacl_io'],
# Order matters here: gtest has a "main" function that will be used if
diff --git a/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5fs.cc b/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.cc
index 3bc3989..bab795c 100644
--- a/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5fs.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "fake_pepper_interface_html5fs.h"
+#include "fake_pepper_interface_html5_fs.h"
#include <string.h>
diff --git a/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5fs.h b/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.h
index 9903c30..d922a2a 100644
--- a/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5fs.h
+++ b/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_TEST_FAKE_PEPPER_INTERFACE_HTML5FS_H_
-#define LIBRARIES_NACL_IO_TEST_FAKE_PEPPER_INTERFACE_HTML5FS_H_
+#ifndef LIBRARIES_NACL_IO_TEST_FAKE_PEPPER_INTERFACE_HTML5_FS_H_
+#define LIBRARIES_NACL_IO_TEST_FAKE_PEPPER_INTERFACE_HTML5_FS_H_
#include <map>
#include <string>
@@ -197,4 +197,4 @@ class FakePepperInterfaceHtml5Fs : public nacl_io::PepperInterfaceDummy {
DISALLOW_COPY_AND_ASSIGN(FakePepperInterfaceHtml5Fs);
};
-#endif // LIBRARIES_NACL_IO_TEST_FAKE_PEPPER_INTERFACE_HTML5FS_H_
+#endif // LIBRARIES_NACL_IO_TEST_FAKE_PEPPER_INTERFACE_HTML5_FS_H_
diff --git a/native_client_sdk/src/tests/nacl_io_test/fifo_test.cc b/native_client_sdk/src/tests/nacl_io_test/fifo_test.cc
index 8a35634..d54c922 100644
--- a/native_client_sdk/src/tests/nacl_io_test/fifo_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/fifo_test.cc
@@ -15,8 +15,8 @@
#include "nacl_io/fifo_char.h"
#include "nacl_io/fifo_null.h"
-#include "nacl_io/fifo_packet.h"
-#include "nacl_io/packet.h"
+#include "nacl_io/socket/fifo_packet.h"
+#include "nacl_io/socket/packet.h"
#include "ppapi_simple/ps.h"
diff --git a/native_client_sdk/src/tests/nacl_io_test/mount_test.cc b/native_client_sdk/src/tests/nacl_io_test/filesystem_test.cc
index bbea69e..41bdadd 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mount_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/filesystem_test.cc
@@ -8,12 +8,12 @@
#include <sys/stat.h>
#include <string>
+#include "dev_fs_for_testing.h"
#include "gtest/gtest.h"
-#include "mount_dev_mock.h"
+#include "nacl_io/filesystem.h"
#include "nacl_io/ioctl.h"
#include "nacl_io/kernel_handle.h"
-#include "nacl_io/mount.h"
-#include "nacl_io/mount_mem.h"
+#include "nacl_io/memfs/mem_fs.h"
#include "nacl_io/osdirent.h"
#include "nacl_io/osunistd.h"
@@ -21,58 +21,58 @@ using namespace nacl_io;
namespace {
-class MountMemMock : public MountMem {
+class MemFsForTesting : public MemFs {
public:
- MountMemMock() {
- MountInitArgs args(1);
+ MemFsForTesting() {
+ FsInitArgs args(1);
EXPECT_EQ(0, Init(args));
}
- int num_nodes() { return (int) inode_pool_.size(); }
+ int num_nodes() { return (int)inode_pool_.size(); }
};
} // namespace
-TEST(MountTest, Sanity) {
- MountMemMock mnt;
+TEST(FilesystemTest, Sanity) {
+ MemFsForTesting fs;
- ScopedMountNode file;
- ScopedMountNode root;
- ScopedMountNode result_node;
+ ScopedNode file;
+ ScopedNode root;
+ ScopedNode result_node;
size_t result_size = 0;
int result_bytes = 0;
char buf1[1024];
- // A memory mount starts with one directory node: the root.
- EXPECT_EQ(1, mnt.num_nodes());
+ // A memory filesystem starts with one directory node: the root.
+ EXPECT_EQ(1, fs.num_nodes());
// Fail to open non existent file
- EXPECT_EQ(ENOENT, mnt.Access(Path("/foo"), R_OK | W_OK));
- EXPECT_EQ(ENOENT, mnt.Open(Path("/foo"), O_RDWR, &result_node));
+ EXPECT_EQ(ENOENT, fs.Access(Path("/foo"), R_OK | W_OK));
+ EXPECT_EQ(ENOENT, fs.Open(Path("/foo"), O_RDWR, &result_node));
EXPECT_EQ(NULL, result_node.get());
- EXPECT_EQ(1, mnt.num_nodes());
+ EXPECT_EQ(1, fs.num_nodes());
// Create a file
- EXPECT_EQ(0, mnt.Open(Path("/foo"), O_RDWR | O_CREAT, &file));
+ EXPECT_EQ(0, fs.Open(Path("/foo"), O_RDWR | O_CREAT, &file));
ASSERT_NE(NULL_NODE, file.get());
// We now have a directory and a file. The file has a two references
// one returned to the test, one for the name->inode map.
- EXPECT_EQ(2, mnt.num_nodes());
+ EXPECT_EQ(2, fs.num_nodes());
EXPECT_EQ(2, file->RefCount());
- EXPECT_EQ(0, mnt.Access(Path("/foo"), R_OK | W_OK));
- EXPECT_EQ(EACCES, mnt.Access(Path("/foo"), X_OK));
+ EXPECT_EQ(0, fs.Access(Path("/foo"), R_OK | W_OK));
+ EXPECT_EQ(EACCES, fs.Access(Path("/foo"), X_OK));
// All access should be allowed on the root directory.
- EXPECT_EQ(0, mnt.Access(Path("/"), R_OK | W_OK | X_OK));
+ EXPECT_EQ(0, fs.Access(Path("/"), R_OK | W_OK | X_OK));
// Open the root directory for write should fail.
- EXPECT_EQ(EISDIR, mnt.Open(Path("/"), O_RDWR, &root));
- EXPECT_EQ(2, mnt.num_nodes());
+ EXPECT_EQ(EISDIR, fs.Open(Path("/"), O_RDWR, &root));
+ EXPECT_EQ(2, fs.num_nodes());
// Open the root directory, should not create a new file
- EXPECT_EQ(0, mnt.Open(Path("/"), O_RDONLY, &root));
- EXPECT_EQ(2, mnt.num_nodes());
+ EXPECT_EQ(0, fs.Open(Path("/"), O_RDONLY, &root));
+ EXPECT_EQ(2, fs.num_nodes());
ASSERT_NE(NULL_NODE, root.get());
struct dirent dirs[4];
int len;
@@ -82,13 +82,13 @@ TEST(MountTest, Sanity) {
// Fail to re-create the same file
EXPECT_EQ(EEXIST,
- mnt.Open(Path("/foo"), O_RDWR | O_CREAT | O_EXCL, &result_node));
+ fs.Open(Path("/foo"), O_RDWR | O_CREAT | O_EXCL, &result_node));
EXPECT_EQ(NULL_NODE, result_node.get());
- EXPECT_EQ(2, mnt.num_nodes());
+ EXPECT_EQ(2, fs.num_nodes());
// Fail to create a directory with the same name
- EXPECT_EQ(EEXIST, mnt.Mkdir(Path("/foo"), O_RDWR));
- EXPECT_EQ(2, mnt.num_nodes());
+ EXPECT_EQ(EEXIST, fs.Mkdir(Path("/foo"), O_RDWR));
+ EXPECT_EQ(2, fs.num_nodes());
HandleAttr attrs;
@@ -101,188 +101,187 @@ TEST(MountTest, Sanity) {
EXPECT_EQ(sizeof(buf1), result_size);
EXPECT_EQ(0, file->Read(attrs, buf1, sizeof(buf1), &result_bytes));
EXPECT_EQ(sizeof(buf1), result_bytes);
- EXPECT_EQ(2, mnt.num_nodes());
+ EXPECT_EQ(2, fs.num_nodes());
EXPECT_EQ(2, file->RefCount());
// Attempt to open the same file, create another ref to it, but does not
// create a new file.
- EXPECT_EQ(0, mnt.Open(Path("/foo"), O_RDWR | O_CREAT, &result_node));
+ EXPECT_EQ(0, fs.Open(Path("/foo"), O_RDWR | O_CREAT, &result_node));
EXPECT_EQ(3, file->RefCount());
- EXPECT_EQ(2, mnt.num_nodes());
+ EXPECT_EQ(2, fs.num_nodes());
EXPECT_EQ(file.get(), result_node.get());
EXPECT_EQ(0, file->GetSize(&result_size));
EXPECT_EQ(sizeof(buf1), result_size);
- // Remove our references so that only the Mount holds it
+ // Remove our references so that only the Filesystem holds it
file.reset();
result_node.reset();
- EXPECT_EQ(2, mnt.num_nodes());
+ EXPECT_EQ(2, fs.num_nodes());
// This should have deleted the object
- EXPECT_EQ(0, mnt.Unlink(Path("/foo")));
- EXPECT_EQ(1, mnt.num_nodes());
+ EXPECT_EQ(0, fs.Unlink(Path("/foo")));
+ EXPECT_EQ(1, fs.num_nodes());
// We should fail to find it
- EXPECT_EQ(ENOENT, mnt.Unlink(Path("/foo")));
- EXPECT_EQ(1, mnt.num_nodes());
+ EXPECT_EQ(ENOENT, fs.Unlink(Path("/foo")));
+ EXPECT_EQ(1, fs.num_nodes());
// Recreate foo as a directory
- EXPECT_EQ(0, mnt.Mkdir(Path("/foo"), O_RDWR));
- EXPECT_EQ(2, mnt.num_nodes());
+ EXPECT_EQ(0, fs.Mkdir(Path("/foo"), O_RDWR));
+ EXPECT_EQ(2, fs.num_nodes());
// Create a file (exclusively)
- EXPECT_EQ(0, mnt.Open(Path("/foo/bar"), O_RDWR | O_CREAT | O_EXCL, &file));
+ EXPECT_EQ(0, fs.Open(Path("/foo/bar"), O_RDWR | O_CREAT | O_EXCL, &file));
ASSERT_NE(NULL_NODE, file.get());
EXPECT_EQ(2, file->RefCount());
- EXPECT_EQ(3, mnt.num_nodes());
+ EXPECT_EQ(3, fs.num_nodes());
// Attempt to delete the directory and fail
- EXPECT_EQ(ENOTEMPTY, mnt.Rmdir(Path("/foo")));
+ EXPECT_EQ(ENOTEMPTY, fs.Rmdir(Path("/foo")));
EXPECT_EQ(2, root->RefCount());
EXPECT_EQ(2, file->RefCount());
- EXPECT_EQ(3, mnt.num_nodes());
+ EXPECT_EQ(3, fs.num_nodes());
// Unlink the file, we should have the only file ref at this point.
- EXPECT_EQ(0, mnt.Unlink(Path("/foo/bar")));
+ EXPECT_EQ(0, fs.Unlink(Path("/foo/bar")));
EXPECT_EQ(2, root->RefCount());
EXPECT_EQ(1, file->RefCount());
- EXPECT_EQ(3, mnt.num_nodes());
+ EXPECT_EQ(3, fs.num_nodes());
// Deref the file, to make it go away
file.reset();
- EXPECT_EQ(2, mnt.num_nodes());
+ EXPECT_EQ(2, fs.num_nodes());
// Deref the directory
- EXPECT_EQ(0, mnt.Rmdir(Path("/foo")));
- EXPECT_EQ(1, mnt.num_nodes());
+ EXPECT_EQ(0, fs.Rmdir(Path("/foo")));
+ EXPECT_EQ(1, fs.num_nodes());
// Verify the directory is gone
- EXPECT_EQ(ENOENT, mnt.Access(Path("/foo"), F_OK));
- EXPECT_EQ(ENOENT, mnt.Open(Path("/foo"), O_RDWR, &file));
+ EXPECT_EQ(ENOENT, fs.Access(Path("/foo"), F_OK));
+ EXPECT_EQ(ENOENT, fs.Open(Path("/foo"), O_RDWR, &file));
EXPECT_EQ(NULL_NODE, file.get());
}
-TEST(MountTest, OpenMode_TRUNC) {
- MountMemMock mnt;
- ScopedMountNode file;
- ScopedMountNode root;
- ScopedMountNode result_node;
+TEST(FilesystemTest, OpenMode_TRUNC) {
+ MemFsForTesting fs;
+ ScopedNode file;
+ ScopedNode root;
+ ScopedNode result_node;
HandleAttr attrs;
int result_bytes;
// Open a file and write something to it.
const char* buf = "hello";
- ASSERT_EQ(0, mnt.Open(Path("/foo"), O_RDWR|O_CREAT, &file));
+ ASSERT_EQ(0, fs.Open(Path("/foo"), O_RDWR | O_CREAT, &file));
ASSERT_EQ(0, file->Write(attrs, buf, strlen(buf), &result_bytes));
ASSERT_EQ(strlen(buf), result_bytes);
// Open it again with TRUNC and make sure it is empty
char read_buf[10];
- ASSERT_EQ(0, mnt.Open(Path("/foo"), O_RDWR|O_TRUNC, &file));
+ ASSERT_EQ(0, fs.Open(Path("/foo"), O_RDWR | O_TRUNC, &file));
ASSERT_EQ(0, file->Read(attrs, read_buf, sizeof(read_buf), &result_bytes));
ASSERT_EQ(0, result_bytes);
}
-TEST(MountTest, MemMountRemove) {
- MountMemMock mnt;
- ScopedMountNode file;
- ScopedMountNode result_node;
+TEST(FilesystemTest, MemFsRemove) {
+ MemFsForTesting fs;
+ ScopedNode file;
+ ScopedNode result_node;
- ASSERT_EQ(0, mnt.Mkdir(Path("/dir"), O_RDWR));
- ASSERT_EQ(0, mnt.Open(Path("/file"), O_RDWR | O_CREAT | O_EXCL, &file));
+ ASSERT_EQ(0, fs.Mkdir(Path("/dir"), O_RDWR));
+ ASSERT_EQ(0, fs.Open(Path("/file"), O_RDWR | O_CREAT | O_EXCL, &file));
EXPECT_NE(NULL_NODE, file.get());
- EXPECT_EQ(3, mnt.num_nodes());
+ EXPECT_EQ(3, fs.num_nodes());
file.reset();
- EXPECT_EQ(0, mnt.Remove(Path("/dir")));
- EXPECT_EQ(2, mnt.num_nodes());
- EXPECT_EQ(0, mnt.Remove(Path("/file")));
- EXPECT_EQ(1, mnt.num_nodes());
+ EXPECT_EQ(0, fs.Remove(Path("/dir")));
+ EXPECT_EQ(2, fs.num_nodes());
+ EXPECT_EQ(0, fs.Remove(Path("/file")));
+ EXPECT_EQ(1, fs.num_nodes());
- ASSERT_EQ(ENOENT,
- mnt.Open(Path("/dir/foo"), O_CREAT | O_RDWR, &result_node));
+ ASSERT_EQ(ENOENT, fs.Open(Path("/dir/foo"), O_CREAT | O_RDWR, &result_node));
ASSERT_EQ(NULL_NODE, result_node.get());
- ASSERT_EQ(ENOENT, mnt.Open(Path("/file"), O_RDONLY, &result_node));
+ ASSERT_EQ(ENOENT, fs.Open(Path("/file"), O_RDONLY, &result_node));
ASSERT_EQ(NULL_NODE, result_node.get());
}
-TEST(MountTest, MemMountRename) {
- MountMemMock mnt;
- ASSERT_EQ(0, mnt.Mkdir(Path("/dir1"), O_RDWR));
- ASSERT_EQ(0, mnt.Mkdir(Path("/dir2"), O_RDWR));
- ASSERT_EQ(3, mnt.num_nodes());
+TEST(FilesystemTest, MemFsRename) {
+ MemFsForTesting fs;
+ ASSERT_EQ(0, fs.Mkdir(Path("/dir1"), O_RDWR));
+ ASSERT_EQ(0, fs.Mkdir(Path("/dir2"), O_RDWR));
+ ASSERT_EQ(3, fs.num_nodes());
- ScopedMountNode file;
- ASSERT_EQ(0, mnt.Open(Path("/dir1/file"), O_RDWR | O_CREAT | O_EXCL, &file));
- ASSERT_EQ(0, mnt.Access(Path("/dir1/file"), R_OK));
- ASSERT_EQ(4, mnt.num_nodes());
+ ScopedNode file;
+ ASSERT_EQ(0, fs.Open(Path("/dir1/file"), O_RDWR | O_CREAT | O_EXCL, &file));
+ ASSERT_EQ(0, fs.Access(Path("/dir1/file"), R_OK));
+ ASSERT_EQ(4, fs.num_nodes());
// Move from one directory to another should ok
- ASSERT_EQ(0, mnt.Rename(Path("/dir1/file"), Path("/dir2/new_file")));
- ASSERT_NE(0, mnt.Access(Path("/dir1/file"), R_OK));
- ASSERT_EQ(0, mnt.Access(Path("/dir2/new_file"), R_OK));
- ASSERT_EQ(4, mnt.num_nodes());
+ ASSERT_EQ(0, fs.Rename(Path("/dir1/file"), Path("/dir2/new_file")));
+ ASSERT_NE(0, fs.Access(Path("/dir1/file"), R_OK));
+ ASSERT_EQ(0, fs.Access(Path("/dir2/new_file"), R_OK));
+ ASSERT_EQ(4, fs.num_nodes());
// Move within the same directory
- ASSERT_EQ(0, mnt.Rename(Path("/dir2/new_file"), Path("/dir2/new_file2")));
- ASSERT_NE(0, mnt.Access(Path("/dir2/new_file"), R_OK));
- ASSERT_EQ(0, mnt.Access(Path("/dir2/new_file2"), R_OK));
- ASSERT_EQ(4, mnt.num_nodes());
+ ASSERT_EQ(0, fs.Rename(Path("/dir2/new_file"), Path("/dir2/new_file2")));
+ ASSERT_NE(0, fs.Access(Path("/dir2/new_file"), R_OK));
+ ASSERT_EQ(0, fs.Access(Path("/dir2/new_file2"), R_OK));
+ ASSERT_EQ(4, fs.num_nodes());
// Move to another directory but without a filename
- ASSERT_EQ(0, mnt.Rename(Path("/dir2/new_file2"), Path("/dir1")));
- ASSERT_NE(0, mnt.Access(Path("/dir2/new_file2"), R_OK));
- ASSERT_EQ(0, mnt.Access(Path("/dir1/new_file2"), R_OK));
- ASSERT_EQ(4, mnt.num_nodes());
+ ASSERT_EQ(0, fs.Rename(Path("/dir2/new_file2"), Path("/dir1")));
+ ASSERT_NE(0, fs.Access(Path("/dir2/new_file2"), R_OK));
+ ASSERT_EQ(0, fs.Access(Path("/dir1/new_file2"), R_OK));
+ ASSERT_EQ(4, fs.num_nodes());
}
-TEST(MountTest, MemMountRenameDir) {
- MountMemMock mnt;
+TEST(FilesystemTest, MemFsRenameDir) {
+ MemFsForTesting fs;
- ASSERT_EQ(0, mnt.Mkdir(Path("/dir1"), O_RDWR));
- ASSERT_EQ(0, mnt.Mkdir(Path("/dir2"), O_RDWR));
- EXPECT_EQ(3, mnt.num_nodes());
+ ASSERT_EQ(0, fs.Mkdir(Path("/dir1"), O_RDWR));
+ ASSERT_EQ(0, fs.Mkdir(Path("/dir2"), O_RDWR));
+ EXPECT_EQ(3, fs.num_nodes());
// Renaming one directory to another should work
- ASSERT_EQ(0, mnt.Rename(Path("/dir1"), Path("/dir2")));
- ASSERT_NE(0, mnt.Access(Path("/dir1"), R_OK));
- ASSERT_EQ(0, mnt.Access(Path("/dir2"), R_OK));
- EXPECT_EQ(2, mnt.num_nodes());
+ ASSERT_EQ(0, fs.Rename(Path("/dir1"), Path("/dir2")));
+ ASSERT_NE(0, fs.Access(Path("/dir1"), R_OK));
+ ASSERT_EQ(0, fs.Access(Path("/dir2"), R_OK));
+ EXPECT_EQ(2, fs.num_nodes());
// Reset to initial state
- ASSERT_EQ(0, mnt.Mkdir(Path("/dir1"), O_RDWR));
- EXPECT_EQ(3, mnt.num_nodes());
+ ASSERT_EQ(0, fs.Mkdir(Path("/dir1"), O_RDWR));
+ EXPECT_EQ(3, fs.num_nodes());
// Renaming a directory to a new name within another
- ASSERT_EQ(0, mnt.Rename(Path("/dir1"), Path("/dir2/foo")));
- ASSERT_EQ(0, mnt.Access(Path("/dir2"), R_OK));
- ASSERT_EQ(0, mnt.Access(Path("/dir2/foo"), R_OK));
- EXPECT_EQ(3, mnt.num_nodes());
+ ASSERT_EQ(0, fs.Rename(Path("/dir1"), Path("/dir2/foo")));
+ ASSERT_EQ(0, fs.Access(Path("/dir2"), R_OK));
+ ASSERT_EQ(0, fs.Access(Path("/dir2/foo"), R_OK));
+ EXPECT_EQ(3, fs.num_nodes());
// Reset to initial state
- ASSERT_EQ(0, mnt.Rmdir(Path("/dir2/foo")));
- ASSERT_EQ(0, mnt.Mkdir(Path("/dir1"), O_RDWR));
- EXPECT_EQ(3, mnt.num_nodes());
+ ASSERT_EQ(0, fs.Rmdir(Path("/dir2/foo")));
+ ASSERT_EQ(0, fs.Mkdir(Path("/dir1"), O_RDWR));
+ EXPECT_EQ(3, fs.num_nodes());
// Renaming one directory to another should fail if the target is non-empty
- ASSERT_EQ(0, mnt.Mkdir(Path("/dir2/dir3"), O_RDWR));
- ASSERT_EQ(ENOTEMPTY, mnt.Rename(Path("/dir1"), Path("/dir2")));
+ ASSERT_EQ(0, fs.Mkdir(Path("/dir2/dir3"), O_RDWR));
+ ASSERT_EQ(ENOTEMPTY, fs.Rename(Path("/dir1"), Path("/dir2")));
}
-TEST(MountTest, DevAccess) {
+TEST(FilesystemTest, DevAccess) {
// Should not be able to open non-existent file.
- MountDevMock mnt;
- ASSERT_EQ(ENOENT, mnt.Access(Path("/foo"), F_OK));
+ DevFsForTesting fs;
+ ASSERT_EQ(ENOENT, fs.Access(Path("/foo"), F_OK));
}
-TEST(MountTest, DevNull) {
- MountDevMock mnt;
- ScopedMountNode dev_null;
+TEST(FilesystemTest, DevNull) {
+ DevFsForTesting fs;
+ ScopedNode dev_null;
int result_bytes = 0;
- ASSERT_EQ(0, mnt.Access(Path("/null"), R_OK | W_OK));
- ASSERT_EQ(EACCES, mnt.Access(Path("/null"), X_OK));
- ASSERT_EQ(0, mnt.Open(Path("/null"), O_RDWR, &dev_null));
+ ASSERT_EQ(0, fs.Access(Path("/null"), R_OK | W_OK));
+ ASSERT_EQ(EACCES, fs.Access(Path("/null"), X_OK));
+ ASSERT_EQ(0, fs.Open(Path("/null"), O_RDWR, &dev_null));
ASSERT_NE(NULL_NODE, dev_null.get());
// Writing to /dev/null should write everything.
@@ -298,14 +297,14 @@ TEST(MountTest, DevNull) {
EXPECT_EQ(0, result_bytes);
}
-TEST(MountTest, DevZero) {
- MountDevMock mnt;
- ScopedMountNode dev_zero;
+TEST(FilesystemTest, DevZero) {
+ DevFsForTesting fs;
+ ScopedNode dev_zero;
int result_bytes = 0;
- ASSERT_EQ(0, mnt.Access(Path("/zero"), R_OK | W_OK));
- ASSERT_EQ(EACCES, mnt.Access(Path("/zero"), X_OK));
- ASSERT_EQ(0, mnt.Open(Path("/zero"), O_RDWR, &dev_zero));
+ ASSERT_EQ(0, fs.Access(Path("/zero"), R_OK | W_OK));
+ ASSERT_EQ(EACCES, fs.Access(Path("/zero"), X_OK));
+ ASSERT_EQ(0, fs.Open(Path("/zero"), O_RDWR, &dev_zero));
ASSERT_NE(NULL_NODE, dev_zero.get());
// Writing to /dev/zero should write everything.
@@ -328,14 +327,14 @@ TEST(MountTest, DevZero) {
}
// Disabled due to intermittent failures on linux: http://crbug.com/257257
-TEST(MountTest, DISABLED_DevUrandom) {
- MountDevMock mnt;
- ScopedMountNode dev_urandom;
+TEST(FilesystemTest, DISABLED_DevUrandom) {
+ DevFsForTesting fs;
+ ScopedNode dev_urandom;
int result_bytes = 0;
- ASSERT_EQ(0, mnt.Access(Path("/urandom"), R_OK | W_OK));
- ASSERT_EQ(EACCES, mnt.Access(Path("/urandom"), X_OK));
- ASSERT_EQ(0, mnt.Open(Path("/urandom"), O_RDWR, &dev_urandom));
+ ASSERT_EQ(0, fs.Access(Path("/urandom"), R_OK | W_OK));
+ ASSERT_EQ(EACCES, fs.Access(Path("/urandom"), X_OK));
+ ASSERT_EQ(0, fs.Open(Path("/urandom"), O_RDWR, &dev_urandom));
ASSERT_NE(NULL_NODE, dev_urandom.get());
// Writing to /dev/urandom should write everything.
@@ -354,8 +353,8 @@ TEST(MountTest, DISABLED_DevUrandom) {
unsigned char buffer[kSampleBatchSize];
for (int batch = 0; batch < kSampleBatches; ++batch) {
int bytes_read = 0;
- EXPECT_EQ(0, dev_urandom->Read(attrs, &buffer[0], kSampleBatchSize,
- &bytes_read));
+ EXPECT_EQ(
+ 0, dev_urandom->Read(attrs, &buffer[0], kSampleBatchSize, &bytes_read));
EXPECT_EQ(kSampleBatchSize, bytes_read);
for (int i = 0; i < bytes_read; ++i) {
diff --git a/native_client_sdk/src/tests/nacl_io_test/mount_fuse_test.cc b/native_client_sdk/src/tests/nacl_io_test/fuse_fs_test.cc
index a0ac553..8bb42b8 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mount_fuse_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/fuse_fs_test.cc
@@ -10,19 +10,19 @@
#include <vector>
#include "nacl_io/fuse.h"
+#include "nacl_io/fusefs/fuse_fs.h"
#include "nacl_io/kernel_handle.h"
#include "nacl_io/kernel_intercept.h"
#include "nacl_io/kernel_proxy.h"
-#include "nacl_io/mount_fuse.h"
using namespace nacl_io;
namespace {
-class MountFuseForTesting : public MountFuse {
+class FuseFsForTesting : public FuseFs {
public:
- explicit MountFuseForTesting(fuse_operations* fuse_ops) {
- MountInitArgs args;
+ explicit FuseFsForTesting(fuse_operations* fuse_ops) {
+ FsInitArgs args;
args.fuse_ops = fuse_ops;
EXPECT_EQ(0, Init(args));
}
@@ -177,19 +177,19 @@ fuse_operations g_fuse_operations = {
testfs_write, // write
};
-class MountFuseTest : public ::testing::Test {
+class FuseFsTest : public ::testing::Test {
public:
- MountFuseTest();
+ FuseFsTest();
void SetUp();
protected:
- MountFuseForTesting mnt_;
+ FuseFsForTesting fs_;
};
-MountFuseTest::MountFuseTest() : mnt_(&g_fuse_operations) {}
+FuseFsTest::FuseFsTest() : fs_(&g_fuse_operations) {}
-void MountFuseTest::SetUp() {
+void FuseFsTest::SetUp() {
// Reset the filesystem.
g_files.clear();
@@ -205,9 +205,9 @@ void MountFuseTest::SetUp() {
} // namespace
-TEST_F(MountFuseTest, OpenAndRead) {
- ScopedMountNode node;
- ASSERT_EQ(0, mnt_.Open(Path("/hello"), O_RDONLY, &node));
+TEST_F(FuseFsTest, OpenAndRead) {
+ ScopedNode node;
+ ASSERT_EQ(0, fs_.Open(Path("/hello"), O_RDONLY, &node));
char buffer[15] = {0};
int bytes_read = 0;
@@ -218,9 +218,9 @@ TEST_F(MountFuseTest, OpenAndRead) {
ASSERT_STREQ(hello_world, buffer);
}
-TEST_F(MountFuseTest, CreateAndWrite) {
- ScopedMountNode node;
- ASSERT_EQ(0, mnt_.Open(Path("/foobar"), O_RDWR | O_CREAT, &node));
+TEST_F(FuseFsTest, CreateAndWrite) {
+ ScopedNode node;
+ ASSERT_EQ(0, fs_.Open(Path("/foobar"), O_RDWR | O_CREAT, &node));
HandleAttr attr;
const char message[] = "Something interesting";
@@ -237,33 +237,33 @@ TEST_F(MountFuseTest, CreateAndWrite) {
ASSERT_STREQ(message, buffer);
}
-TEST_F(MountFuseTest, GetStat) {
+TEST_F(FuseFsTest, GetStat) {
struct stat statbuf;
- ScopedMountNode node;
+ ScopedNode node;
- ASSERT_EQ(0, mnt_.Open(Path("/hello"), O_RDONLY, &node));
+ ASSERT_EQ(0, fs_.Open(Path("/hello"), O_RDONLY, &node));
EXPECT_EQ(0, node->GetStat(&statbuf));
EXPECT_EQ(S_IFREG, statbuf.st_mode & S_IFMT);
EXPECT_EQ(0666, statbuf.st_mode & ~S_IFMT);
EXPECT_EQ(strlen(hello_world), statbuf.st_size);
- ASSERT_EQ(0, mnt_.Open(Path("/"), O_RDONLY, &node));
+ ASSERT_EQ(0, fs_.Open(Path("/"), O_RDONLY, &node));
EXPECT_EQ(0, node->GetStat(&statbuf));
EXPECT_EQ(S_IFDIR, statbuf.st_mode & S_IFMT);
EXPECT_EQ(0755, statbuf.st_mode & ~S_IFMT);
// Create a file and stat.
- ASSERT_EQ(0, mnt_.Open(Path("/foobar"), O_RDWR | O_CREAT, &node));
+ ASSERT_EQ(0, fs_.Open(Path("/foobar"), O_RDWR | O_CREAT, &node));
EXPECT_EQ(0, node->GetStat(&statbuf));
EXPECT_EQ(S_IFREG, statbuf.st_mode & S_IFMT);
EXPECT_EQ(0666, statbuf.st_mode & ~S_IFMT);
EXPECT_EQ(0, statbuf.st_size);
}
-TEST_F(MountFuseTest, GetDents) {
- ScopedMountNode root;
+TEST_F(FuseFsTest, GetDents) {
+ ScopedNode root;
- ASSERT_EQ(0, mnt_.Open(Path("/"), O_RDONLY, &root));
+ ASSERT_EQ(0, fs_.Open(Path("/"), O_RDONLY, &root));
struct dirent entries[4];
int bytes_read;
@@ -284,8 +284,8 @@ TEST_F(MountFuseTest, GetDents) {
EXPECT_STREQ("hello", entries[1].d_name);
// Add a file and read again.
- ScopedMountNode node;
- ASSERT_EQ(0, mnt_.Open(Path("/foobar"), O_RDWR | O_CREAT, &node));
+ ScopedNode node;
+ ASSERT_EQ(0, fs_.Open(Path("/foobar"), O_RDWR | O_CREAT, &node));
ASSERT_EQ(0, root->GetDents(0, &entries[0], sizeof(entries), &bytes_read));
ASSERT_EQ(4 * sizeof(dirent), bytes_read);
EXPECT_STREQ(".", entries[0].d_name);
@@ -311,7 +311,7 @@ void KernelProxyFuseTest::SetUp() {
ki_init(&kp_);
// Register a fuse filesystem.
- ki_register_mount_type("flatfs", &g_fuse_operations);
+ ki_register_fs_type("flatfs", &g_fuse_operations);
// Unmount the passthrough FS and mount our fuse filesystem.
EXPECT_EQ(0, kp_.umount("/"));
@@ -319,7 +319,7 @@ void KernelProxyFuseTest::SetUp() {
}
void KernelProxyFuseTest::TearDown() {
- ki_unregister_mount_type("flatfs");
+ ki_unregister_fs_type("flatfs");
ki_uninit();
}
diff --git a/native_client_sdk/src/tests/nacl_io_test/mount_html5fs_test.cc b/native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc
index b770892..e29c76e 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mount_html5fs_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc
@@ -18,12 +18,12 @@
#endif
#include "nacl_io/kernel_handle.h"
-#include "nacl_io/mount_html5fs.h"
+#include "nacl_io/html5fs/html5_fs.h"
#include "nacl_io/osdirent.h"
#include "nacl_io/osunistd.h"
#include "nacl_io/pepper_interface_delegate.h"
#include "sdk_util/scoped_ref.h"
-#include "fake_pepper_interface_html5fs.h"
+#include "fake_pepper_interface_html5_fs.h"
#include "mock_util.h"
#include "pepper_interface_mock.h"
@@ -38,10 +38,10 @@ using ::testing::Return;
namespace {
-class MountHtml5FsForTesting : public MountHtml5Fs {
+class Html5FsForTesting : public Html5Fs {
public:
- MountHtml5FsForTesting(StringMap_t& string_map, PepperInterface* ppapi) {
- MountInitArgs args;
+ Html5FsForTesting(StringMap_t& string_map, PepperInterface* ppapi) {
+ FsInitArgs args;
args.string_map = string_map;
args.ppapi = ppapi;
Error error = Init(args);
@@ -49,9 +49,9 @@ class MountHtml5FsForTesting : public MountHtml5Fs {
}
};
-class MountHtml5FsTest : public ::testing::Test {
+class Html5FsTest : public ::testing::Test {
public:
- MountHtml5FsTest();
+ Html5FsTest();
protected:
FakePepperInterfaceHtml5Fs ppapi_html5_;
@@ -59,7 +59,7 @@ class MountHtml5FsTest : public ::testing::Test {
PepperInterfaceDelegate ppapi_;
};
-MountHtml5FsTest::MountHtml5FsTest()
+Html5FsTest::Html5FsTest()
: ppapi_mock_(ppapi_html5_.GetInstance()),
ppapi_(ppapi_html5_.GetInstance()) {
// Default delegation to the html5 pepper interface.
@@ -72,7 +72,7 @@ MountHtml5FsTest::MountHtml5FsTest()
} // namespace
-TEST_F(MountHtml5FsTest, FilesystemType) {
+TEST_F(Html5FsTest, FilesystemType) {
const char* filesystem_type_strings[] = {"", "PERSISTENT", "TEMPORARY", NULL};
PP_FileSystemType filesystem_type_values[] = {
PP_FILESYSTEMTYPE_LOCALPERSISTENT, // Default to persistent.
@@ -111,99 +111,99 @@ TEST_F(MountHtml5FsTest, FilesystemType) {
StringMap_t map;
map["type"] = filesystem_type_string;
map["expected_size"] = expected_size_string;
- ScopedRef<MountHtml5FsForTesting> mnt(
- new MountHtml5FsForTesting(map, &ppapi_));
+ ScopedRef<Html5FsForTesting> fs(
+ new Html5FsForTesting(map, &ppapi_));
Mock::VerifyAndClearExpectations(&filesystem_mock);
}
}
}
-TEST_F(MountHtml5FsTest, Access) {
+TEST_F(Html5FsTest, Access) {
EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile("/foo", NULL));
StringMap_t map;
- ScopedRef<MountHtml5FsForTesting> mnt(
- new MountHtml5FsForTesting(map, &ppapi_));
+ ScopedRef<Html5FsForTesting> fs(
+ new Html5FsForTesting(map, &ppapi_));
- ASSERT_EQ(0, mnt->Access(Path("/foo"), R_OK | W_OK | X_OK));
- ASSERT_EQ(ENOENT, mnt->Access(Path("/bar"), F_OK));
+ ASSERT_EQ(0, fs->Access(Path("/foo"), R_OK | W_OK | X_OK));
+ ASSERT_EQ(ENOENT, fs->Access(Path("/bar"), F_OK));
}
-TEST_F(MountHtml5FsTest, Mkdir) {
+TEST_F(Html5FsTest, Mkdir) {
StringMap_t map;
- ScopedRef<MountHtml5FsForTesting> mnt(
- new MountHtml5FsForTesting(map, &ppapi_));
+ ScopedRef<Html5FsForTesting> fs(
+ new Html5FsForTesting(map, &ppapi_));
// mkdir at the root should return EEXIST, not EACCES.
- EXPECT_EQ(EEXIST, mnt->Mkdir(Path("/"), 0644));
+ EXPECT_EQ(EEXIST, fs->Mkdir(Path("/"), 0644));
Path path("/foo");
- ASSERT_EQ(ENOENT, mnt->Access(path, F_OK));
- ASSERT_EQ(0, mnt->Mkdir(path, 0644));
+ ASSERT_EQ(ENOENT, fs->Access(path, F_OK));
+ ASSERT_EQ(0, fs->Mkdir(path, 0644));
struct stat stat;
- ScopedMountNode node;
- ASSERT_EQ(0, mnt->Open(path, O_RDONLY, &node));
+ ScopedNode node;
+ ASSERT_EQ(0, fs->Open(path, O_RDONLY, &node));
EXPECT_EQ(0, node->GetStat(&stat));
EXPECT_EQ(S_IFDIR, stat.st_mode & S_IFDIR);
}
-TEST_F(MountHtml5FsTest, Remove) {
+TEST_F(Html5FsTest, Remove) {
EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile("/foo", NULL));
StringMap_t map;
- ScopedRef<MountHtml5FsForTesting> mnt(
- new MountHtml5FsForTesting(map, &ppapi_));
+ ScopedRef<Html5FsForTesting> fs(
+ new Html5FsForTesting(map, &ppapi_));
Path path("/foo");
- ASSERT_EQ(0, mnt->Access(path, F_OK));
- ASSERT_EQ(0, mnt->Remove(path));
- EXPECT_EQ(ENOENT, mnt->Access(path, F_OK));
+ ASSERT_EQ(0, fs->Access(path, F_OK));
+ ASSERT_EQ(0, fs->Remove(path));
+ EXPECT_EQ(ENOENT, fs->Access(path, F_OK));
}
// Unlink + Rmdir forward to Remove unconditionally, which will not fail if the
// file type is wrong.
-TEST_F(MountHtml5FsTest, DISABLED_Unlink) {
+TEST_F(Html5FsTest, DISABLED_Unlink) {
EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile("/file", NULL));
EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddDirectory("/dir", NULL));
StringMap_t map;
- ScopedRef<MountHtml5FsForTesting> mnt(
- new MountHtml5FsForTesting(map, &ppapi_));
+ ScopedRef<Html5FsForTesting> fs(
+ new Html5FsForTesting(map, &ppapi_));
- ASSERT_EQ(EISDIR, mnt->Unlink(Path("/dir")));
- EXPECT_EQ(0, mnt->Unlink(Path("/file")));
- EXPECT_EQ(ENOENT, mnt->Access(Path("/file"), F_OK));
- EXPECT_EQ(0, mnt->Access(Path("/dir"), F_OK));
+ ASSERT_EQ(EISDIR, fs->Unlink(Path("/dir")));
+ EXPECT_EQ(0, fs->Unlink(Path("/file")));
+ EXPECT_EQ(ENOENT, fs->Access(Path("/file"), F_OK));
+ EXPECT_EQ(0, fs->Access(Path("/dir"), F_OK));
}
// Unlink + Rmdir forward to Remove unconditionally, which will not fail if the
// file type is wrong.
-TEST_F(MountHtml5FsTest, DISABLED_Rmdir) {
+TEST_F(Html5FsTest, DISABLED_Rmdir) {
EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile("/file", NULL));
EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddDirectory("/dir", NULL));
StringMap_t map;
- ScopedRef<MountHtml5FsForTesting> mnt(
- new MountHtml5FsForTesting(map, &ppapi_));
+ ScopedRef<Html5FsForTesting> fs(
+ new Html5FsForTesting(map, &ppapi_));
- ASSERT_EQ(ENOTDIR, mnt->Rmdir(Path("/file")));
- EXPECT_EQ(0, mnt->Rmdir(Path("/dir")));
- EXPECT_EQ(ENOENT, mnt->Access(Path("/dir"), F_OK));
- EXPECT_EQ(0, mnt->Access(Path("/file"), F_OK));
+ ASSERT_EQ(ENOTDIR, fs->Rmdir(Path("/file")));
+ EXPECT_EQ(0, fs->Rmdir(Path("/dir")));
+ EXPECT_EQ(ENOENT, fs->Access(Path("/dir"), F_OK));
+ EXPECT_EQ(0, fs->Access(Path("/file"), F_OK));
}
-TEST_F(MountHtml5FsTest, OpenForCreate) {
+TEST_F(Html5FsTest, OpenForCreate) {
StringMap_t map;
- ScopedRef<MountHtml5FsForTesting> mnt(
- new MountHtml5FsForTesting(map, &ppapi_));
+ ScopedRef<Html5FsForTesting> fs(
+ new Html5FsForTesting(map, &ppapi_));
Path path("/foo");
- EXPECT_EQ(ENOENT, mnt->Access(path, F_OK));
+ EXPECT_EQ(ENOENT, fs->Access(path, F_OK));
- ScopedMountNode node;
- ASSERT_EQ(0, mnt->Open(path, O_CREAT | O_RDWR, &node));
+ ScopedNode node;
+ ASSERT_EQ(0, fs->Open(path, O_CREAT | O_RDWR, &node));
// Write some data.
char contents[] = "contents";
@@ -213,7 +213,7 @@ TEST_F(MountHtml5FsTest, OpenForCreate) {
EXPECT_EQ(strlen(contents), bytes_written);
// Create again.
- ASSERT_EQ(0, mnt->Open(path, O_CREAT, &node));
+ ASSERT_EQ(0, fs->Open(path, O_CREAT, &node));
// Check that the file still has data.
size_t size;
@@ -221,30 +221,30 @@ TEST_F(MountHtml5FsTest, OpenForCreate) {
EXPECT_EQ(strlen(contents), size);
// Open exclusively.
- EXPECT_EQ(EEXIST, mnt->Open(path, O_CREAT | O_EXCL, &node));
+ EXPECT_EQ(EEXIST, fs->Open(path, O_CREAT | O_EXCL, &node));
// Try to truncate without write access.
- EXPECT_EQ(EINVAL, mnt->Open(path, O_CREAT | O_TRUNC, &node));
+ EXPECT_EQ(EINVAL, fs->Open(path, O_CREAT | O_TRUNC, &node));
// Open and truncate.
- ASSERT_EQ(0, mnt->Open(path, O_CREAT | O_TRUNC | O_WRONLY, &node));
+ ASSERT_EQ(0, fs->Open(path, O_CREAT | O_TRUNC | O_WRONLY, &node));
// File should be empty.
EXPECT_EQ(0, node->GetSize(&size));
EXPECT_EQ(0, size);
}
-TEST_F(MountHtml5FsTest, Read) {
+TEST_F(Html5FsTest, Read) {
const char contents[] = "contents";
ASSERT_TRUE(
ppapi_html5_.filesystem_template()->AddFile("/file", contents, NULL));
ASSERT_TRUE(ppapi_html5_.filesystem_template()->AddDirectory("/dir", NULL));
StringMap_t map;
- ScopedRef<MountHtml5FsForTesting> mnt(
- new MountHtml5FsForTesting(map, &ppapi_));
+ ScopedRef<Html5FsForTesting> fs(
+ new Html5FsForTesting(map, &ppapi_));
- ScopedMountNode node;
- ASSERT_EQ(0, mnt->Open(Path("/file"), O_RDONLY, &node));
+ ScopedNode node;
+ ASSERT_EQ(0, fs->Open(Path("/file"), O_RDONLY, &node));
char buffer[10] = {0};
int bytes_read = 0;
@@ -273,22 +273,22 @@ TEST_F(MountHtml5FsTest, Read) {
ASSERT_EQ(0, bytes_written);
// Reading from a directory should fail.
- ASSERT_EQ(0, mnt->Open(Path("/dir"), O_RDONLY, &node));
+ ASSERT_EQ(0, fs->Open(Path("/dir"), O_RDONLY, &node));
ASSERT_EQ(EISDIR, node->Read(attr, &buffer[0], sizeof(buffer), &bytes_read));
}
-TEST_F(MountHtml5FsTest, Write) {
+TEST_F(Html5FsTest, Write) {
const char contents[] = "contents";
EXPECT_TRUE(
ppapi_html5_.filesystem_template()->AddFile("/file", contents, NULL));
EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddDirectory("/dir", NULL));
StringMap_t map;
- ScopedRef<MountHtml5FsForTesting> mnt(
- new MountHtml5FsForTesting(map, &ppapi_));
+ ScopedRef<Html5FsForTesting> fs(
+ new Html5FsForTesting(map, &ppapi_));
- ScopedMountNode node;
- ASSERT_EQ(0, mnt->Open(Path("/file"), O_WRONLY, &node));
+ ScopedNode node;
+ ASSERT_EQ(0, fs->Open(Path("/file"), O_WRONLY, &node));
// Reading should fail.
char buffer[10];
@@ -298,7 +298,7 @@ TEST_F(MountHtml5FsTest, Write) {
EXPECT_EQ(0, bytes_read);
// Reopen as read-write.
- ASSERT_EQ(0, mnt->Open(Path("/file"), O_RDWR, &node));
+ ASSERT_EQ(0, fs->Open(Path("/file"), O_RDWR, &node));
int bytes_written = 1; // Set to a non-zero value.
attr.offs = 3;
@@ -312,11 +312,11 @@ TEST_F(MountHtml5FsTest, Write) {
EXPECT_STREQ("construct", buffer);
// Writing to a directory should fail.
- EXPECT_EQ(0, mnt->Open(Path("/dir"), O_RDWR, &node));
+ EXPECT_EQ(0, fs->Open(Path("/dir"), O_RDWR, &node));
EXPECT_EQ(EISDIR, node->Write(attr, &buffer[0], sizeof(buffer), &bytes_read));
}
-TEST_F(MountHtml5FsTest, GetStat) {
+TEST_F(Html5FsTest, GetStat) {
const int creation_time = 1000;
const int access_time = 2000;
const int modified_time = 3000;
@@ -338,11 +338,11 @@ TEST_F(MountHtml5FsTest, GetStat) {
fake_node->set_last_modified_time(modified_time);
StringMap_t map;
- ScopedRef<MountHtml5FsForTesting> mnt(
- new MountHtml5FsForTesting(map, &ppapi_));
+ ScopedRef<Html5FsForTesting> fs(
+ new Html5FsForTesting(map, &ppapi_));
- ScopedMountNode node;
- ASSERT_EQ(0, mnt->Open(Path("/file"), O_RDONLY, &node));
+ ScopedNode node;
+ ASSERT_EQ(0, fs->Open(Path("/file"), O_RDONLY, &node));
struct stat statbuf;
EXPECT_EQ(0, node->GetStat(&statbuf));
@@ -363,7 +363,7 @@ TEST_F(MountHtml5FsTest, GetStat) {
EXPECT_FALSE(node->IsaTTY());
// GetStat on a directory...
- EXPECT_EQ(0, mnt->Open(Path("/dir"), O_RDONLY, &node));
+ EXPECT_EQ(0, fs->Open(Path("/dir"), O_RDONLY, &node));
EXPECT_EQ(0, node->GetStat(&statbuf));
EXPECT_EQ(S_IFDIR, statbuf.st_mode & S_IFMT);
EXPECT_EQ(S_IRUSR | S_IRGRP | S_IROTH |
@@ -381,18 +381,18 @@ TEST_F(MountHtml5FsTest, GetStat) {
EXPECT_FALSE(node->IsaTTY());
}
-TEST_F(MountHtml5FsTest, FTruncate) {
+TEST_F(Html5FsTest, FTruncate) {
const char contents[] = "contents";
EXPECT_TRUE(
ppapi_html5_.filesystem_template()->AddFile("/file", contents, NULL));
EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddDirectory("/dir", NULL));
StringMap_t map;
- ScopedRef<MountHtml5FsForTesting> mnt(
- new MountHtml5FsForTesting(map, &ppapi_));
+ ScopedRef<Html5FsForTesting> fs(
+ new Html5FsForTesting(map, &ppapi_));
- ScopedMountNode node;
- ASSERT_EQ(0, mnt->Open(Path("/file"), O_RDWR, &node));
+ ScopedNode node;
+ ASSERT_EQ(0, fs->Open(Path("/file"), O_RDWR, &node));
HandleAttr attr;
char buffer[10] = {0};
@@ -413,24 +413,24 @@ TEST_F(MountHtml5FsTest, FTruncate) {
EXPECT_STREQ("cont\0\0\0\0", buffer);
// Ftruncate should fail for a directory.
- EXPECT_EQ(0, mnt->Open(Path("/dir"), O_RDONLY, &node));
+ EXPECT_EQ(0, fs->Open(Path("/dir"), O_RDONLY, &node));
EXPECT_EQ(EISDIR, node->FTruncate(4));
}
-TEST_F(MountHtml5FsTest, GetDents) {
+TEST_F(Html5FsTest, GetDents) {
const char contents[] = "contents";
EXPECT_TRUE(
ppapi_html5_.filesystem_template()->AddFile("/file", contents, NULL));
StringMap_t map;
- ScopedRef<MountHtml5FsForTesting> mnt(
- new MountHtml5FsForTesting(map, &ppapi_));
+ ScopedRef<Html5FsForTesting> fs(
+ new Html5FsForTesting(map, &ppapi_));
- ScopedMountNode root;
- ASSERT_EQ(0, mnt->Open(Path("/"), O_RDONLY, &root));
+ ScopedNode root;
+ ASSERT_EQ(0, fs->Open(Path("/"), O_RDONLY, &root));
- ScopedMountNode node;
- ASSERT_EQ(0, mnt->Open(Path("/file"), O_RDWR, &node));
+ ScopedNode node;
+ ASSERT_EQ(0, fs->Open(Path("/file"), O_RDWR, &node));
// Should fail for regular files.
const size_t kMaxDirents = 5;
@@ -467,7 +467,7 @@ TEST_F(MountHtml5FsTest, GetDents) {
}
// Add another file...
- ASSERT_EQ(0, mnt->Open(Path("/file2"), O_CREAT, &node));
+ ASSERT_EQ(0, fs->Open(Path("/file2"), O_CREAT, &node));
// Read the root directory again.
memset(&dirents[0], 0, sizeof(dirents));
diff --git a/native_client_sdk/src/tests/nacl_io_test/mount_http_test.cc b/native_client_sdk/src/tests/nacl_io_test/http_fs_test.cc
index a679bbc..76a7050 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mount_http_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/http_fs_test.cc
@@ -12,10 +12,10 @@
#include "fake_pepper_interface_url_loader.h"
+#include "nacl_io/dir_node.h"
+#include "nacl_io/httpfs/http_fs.h"
#include "nacl_io/kernel_handle.h"
#include "nacl_io/kernel_intercept.h"
-#include "nacl_io/mount_http.h"
-#include "nacl_io/mount_node_dir.h"
#include "nacl_io/osdirent.h"
#include "nacl_io/osunistd.h"
@@ -23,18 +23,18 @@ using namespace nacl_io;
namespace {
-class MountHttpForTesting : public MountHttp {
+class HttpFsForTesting : public HttpFs {
public:
- MountHttpForTesting(StringMap_t map, PepperInterface* ppapi) {
- MountInitArgs args(1);
+ HttpFsForTesting(StringMap_t map, PepperInterface* ppapi) {
+ FsInitArgs args(1);
args.string_map = map;
args.ppapi = ppapi;
EXPECT_EQ(0, Init(args));
}
- using MountHttp::GetNodeCacheForTesting;
- using MountHttp::ParseManifest;
- using MountHttp::FindOrCreateDir;
+ using HttpFs::GetNodeCacheForTesting;
+ using HttpFs::ParseManifest;
+ using HttpFs::FindOrCreateDir;
};
enum {
@@ -60,39 +60,36 @@ StringMap_t MakeStringMap(StringMapParam param) {
return smap;
}
-class MountHttpTest : public ::testing::TestWithParam<StringMapParam> {
+class HttpFsTest : public ::testing::TestWithParam<StringMapParam> {
public:
- MountHttpTest();
+ HttpFsTest();
protected:
FakePepperInterfaceURLLoader ppapi_;
- MountHttpForTesting mnt_;
+ HttpFsForTesting fs_;
};
-MountHttpTest::MountHttpTest() :
- mnt_(MakeStringMap(GetParam()), &ppapi_) {
-}
+HttpFsTest::HttpFsTest() : fs_(MakeStringMap(GetParam()), &ppapi_) {}
} // namespace
-
-TEST_P(MountHttpTest, Access) {
+TEST_P(HttpFsTest, Access) {
ASSERT_TRUE(ppapi_.server_template()->AddEntity("foo", "", NULL));
- ASSERT_EQ(0, mnt_.Access(Path("/foo"), R_OK));
- ASSERT_EQ(EACCES, mnt_.Access(Path("/foo"), W_OK));
- ASSERT_EQ(EACCES, mnt_.Access(Path("/foo"), X_OK));
- ASSERT_EQ(ENOENT, mnt_.Access(Path("/bar"), F_OK));
+ ASSERT_EQ(0, fs_.Access(Path("/foo"), R_OK));
+ ASSERT_EQ(EACCES, fs_.Access(Path("/foo"), W_OK));
+ ASSERT_EQ(EACCES, fs_.Access(Path("/foo"), X_OK));
+ ASSERT_EQ(ENOENT, fs_.Access(Path("/bar"), F_OK));
}
-TEST_P(MountHttpTest, OpenAndCloseServerError) {
+TEST_P(HttpFsTest, OpenAndCloseServerError) {
EXPECT_TRUE(ppapi_.server_template()->AddError("file", 500));
- ScopedMountNode node;
- ASSERT_EQ(EIO, mnt_.Open(Path("/file"), O_RDONLY, &node));
+ ScopedNode node;
+ ASSERT_EQ(EIO, fs_.Open(Path("/file"), O_RDONLY, &node));
}
-TEST_P(MountHttpTest, ReadPartial) {
+TEST_P(HttpFsTest, ReadPartial) {
const char contents[] = "0123456789abcdefg";
ASSERT_TRUE(ppapi_.server_template()->AddEntity("file", contents, NULL));
ppapi_.server_template()->set_allow_partial(true);
@@ -102,8 +99,8 @@ TEST_P(MountHttpTest, ReadPartial) {
char buf[10];
memset(&buf[0], 0, sizeof(buf));
- ScopedMountNode node;
- ASSERT_EQ(0, mnt_.Open(Path("/file"), O_RDONLY, &node));
+ ScopedNode node;
+ ASSERT_EQ(0, fs_.Open(Path("/file"), O_RDONLY, &node));
HandleAttr attr;
EXPECT_EQ(0, node->Read(attr, buf, sizeof(buf) - 1, &result_bytes));
EXPECT_EQ(sizeof(buf) - 1, result_bytes);
@@ -122,7 +119,7 @@ TEST_P(MountHttpTest, ReadPartial) {
EXPECT_EQ(0, result_bytes);
}
-TEST_P(MountHttpTest, ReadPartialNoServerSupport) {
+TEST_P(HttpFsTest, ReadPartialNoServerSupport) {
const char contents[] = "0123456789abcdefg";
ASSERT_TRUE(ppapi_.server_template()->AddEntity("file", contents, NULL));
ppapi_.server_template()->set_allow_partial(false);
@@ -132,8 +129,8 @@ TEST_P(MountHttpTest, ReadPartialNoServerSupport) {
char buf[10];
memset(&buf[0], 0, sizeof(buf));
- ScopedMountNode node;
- ASSERT_EQ(0, mnt_.Open(Path("/file"), O_RDONLY, &node));
+ ScopedNode node;
+ ASSERT_EQ(0, fs_.Open(Path("/file"), O_RDONLY, &node));
HandleAttr attr;
EXPECT_EQ(0, node->Read(attr, buf, sizeof(buf) - 1, &result_bytes));
EXPECT_EQ(sizeof(buf) - 1, result_bytes);
@@ -152,12 +149,12 @@ TEST_P(MountHttpTest, ReadPartialNoServerSupport) {
EXPECT_EQ(0, result_bytes);
}
-TEST_P(MountHttpTest, Write) {
+TEST_P(HttpFsTest, Write) {
const char contents[] = "contents";
ASSERT_TRUE(ppapi_.server_template()->AddEntity("file", contents, NULL));
- ScopedMountNode node;
- ASSERT_EQ(0, mnt_.Open(Path("/file"), O_WRONLY, &node));
+ ScopedNode node;
+ ASSERT_EQ(0, fs_.Open(Path("/file"), O_WRONLY, &node));
// Writing always fails.
HandleAttr attr;
@@ -167,12 +164,12 @@ TEST_P(MountHttpTest, Write) {
EXPECT_EQ(0, bytes_written);
}
-TEST_P(MountHttpTest, GetStat) {
+TEST_P(HttpFsTest, GetStat) {
const char contents[] = "contents";
ASSERT_TRUE(ppapi_.server_template()->AddEntity("file", contents, NULL));
- ScopedMountNode node;
- ASSERT_EQ(0, mnt_.Open(Path("/file"), O_RDONLY, &node));
+ ScopedNode node;
+ ASSERT_EQ(0, fs_.Open(Path("/file"), O_RDONLY, &node));
struct stat statbuf;
EXPECT_EQ(0, node->GetStat(&statbuf));
@@ -185,108 +182,108 @@ TEST_P(MountHttpTest, GetStat) {
EXPECT_EQ(0, statbuf.st_mtime);
}
-TEST_P(MountHttpTest, FTruncate) {
+TEST_P(HttpFsTest, FTruncate) {
const char contents[] = "contents";
ASSERT_TRUE(ppapi_.server_template()->AddEntity("file", contents, NULL));
- ScopedMountNode node;
- ASSERT_EQ(0, mnt_.Open(Path("/file"), O_RDWR, &node));
+ ScopedNode node;
+ ASSERT_EQ(0, fs_.Open(Path("/file"), O_RDWR, &node));
EXPECT_EQ(EACCES, node->FTruncate(4));
}
// Instantiate the above tests for all caching types.
INSTANTIATE_TEST_CASE_P(
Default,
- MountHttpTest,
+ HttpFsTest,
::testing::Values((uint32_t)kStringMapParamCacheNone,
(uint32_t)kStringMapParamCacheContent,
(uint32_t)kStringMapParamCacheStat,
(uint32_t)kStringMapParamCacheContentStat));
-TEST(MountHttpDirTest, Mkdir) {
+TEST(HttpFsDirTest, Mkdir) {
StringMap_t args;
- MountHttpForTesting mnt(args, NULL);
+ HttpFsForTesting fs(args, NULL);
char manifest[] = "-r-- 123 /mydir/foo\n-rw- 234 /thatdir/bar\n";
- ASSERT_EQ(0, mnt.ParseManifest(manifest));
+ ASSERT_EQ(0, fs.ParseManifest(manifest));
// mkdir of existing directories should give "File exists".
- EXPECT_EQ(EEXIST, mnt.Mkdir(Path("/"), 0));
- EXPECT_EQ(EEXIST, mnt.Mkdir(Path("/mydir"), 0));
+ EXPECT_EQ(EEXIST, fs.Mkdir(Path("/"), 0));
+ EXPECT_EQ(EEXIST, fs.Mkdir(Path("/mydir"), 0));
// mkdir of non-existent directories should give "Permission denied".
- EXPECT_EQ(EACCES, mnt.Mkdir(Path("/non_existent"), 0));
+ EXPECT_EQ(EACCES, fs.Mkdir(Path("/non_existent"), 0));
}
-TEST(MountHttpDirTest, Rmdir) {
+TEST(HttpFsDirTest, Rmdir) {
StringMap_t args;
- MountHttpForTesting mnt(args, NULL);
+ HttpFsForTesting fs(args, NULL);
char manifest[] = "-r-- 123 /mydir/foo\n-rw- 234 /thatdir/bar\n";
- ASSERT_EQ(0, mnt.ParseManifest(manifest));
+ ASSERT_EQ(0, fs.ParseManifest(manifest));
// Rmdir on existing dirs should give "Permission Denied"
- EXPECT_EQ(EACCES, mnt.Rmdir(Path("/")));
- EXPECT_EQ(EACCES, mnt.Rmdir(Path("/mydir")));
+ EXPECT_EQ(EACCES, fs.Rmdir(Path("/")));
+ EXPECT_EQ(EACCES, fs.Rmdir(Path("/mydir")));
// Rmdir on existing files should give "Not a direcotory"
- EXPECT_EQ(ENOTDIR, mnt.Rmdir(Path("/mydir/foo")));
+ EXPECT_EQ(ENOTDIR, fs.Rmdir(Path("/mydir/foo")));
// Rmdir on non-existent files should give "No such file or directory"
- EXPECT_EQ(ENOENT, mnt.Rmdir(Path("/non_existent")));
+ EXPECT_EQ(ENOENT, fs.Rmdir(Path("/non_existent")));
}
-TEST(MountHttpDirTest, Unlink) {
+TEST(HttpFsDirTest, Unlink) {
StringMap_t args;
- MountHttpForTesting mnt(args, NULL);
+ HttpFsForTesting fs(args, NULL);
char manifest[] = "-r-- 123 /mydir/foo\n-rw- 234 /thatdir/bar\n";
- ASSERT_EQ(0, mnt.ParseManifest(manifest));
+ ASSERT_EQ(0, fs.ParseManifest(manifest));
// Unlink of existing files should give "Permission Denied"
- EXPECT_EQ(EACCES, mnt.Unlink(Path("/mydir/foo")));
+ EXPECT_EQ(EACCES, fs.Unlink(Path("/mydir/foo")));
// Unlink of existing directory should give "Is a directory"
- EXPECT_EQ(EISDIR, mnt.Unlink(Path("/mydir")));
+ EXPECT_EQ(EISDIR, fs.Unlink(Path("/mydir")));
// Unlink of non-existent files should give "No such file or directory"
- EXPECT_EQ(ENOENT, mnt.Unlink(Path("/non_existent")));
+ EXPECT_EQ(ENOENT, fs.Unlink(Path("/non_existent")));
}
-TEST(MountHttpDirTest, Remove) {
+TEST(HttpFsDirTest, Remove) {
StringMap_t args;
- MountHttpForTesting mnt(args, NULL);
+ HttpFsForTesting fs(args, NULL);
char manifest[] = "-r-- 123 /mydir/foo\n-rw- 234 /thatdir/bar\n";
- ASSERT_EQ(0, mnt.ParseManifest(manifest));
+ ASSERT_EQ(0, fs.ParseManifest(manifest));
// Remove of existing files should give "Permission Denied"
- EXPECT_EQ(EACCES, mnt.Remove(Path("/mydir/foo")));
+ EXPECT_EQ(EACCES, fs.Remove(Path("/mydir/foo")));
// Remove of existing directory should give "Permission Denied"
- EXPECT_EQ(EACCES, mnt.Remove(Path("/mydir")));
+ EXPECT_EQ(EACCES, fs.Remove(Path("/mydir")));
// Unlink of non-existent files should give "No such file or directory"
- EXPECT_EQ(ENOENT, mnt.Remove(Path("/non_existent")));
+ EXPECT_EQ(ENOENT, fs.Remove(Path("/non_existent")));
}
-TEST(MountHttpDirTest, ParseManifest) {
+TEST(HttpFsDirTest, ParseManifest) {
StringMap_t args;
size_t result_size = 0;
- MountHttpForTesting mnt(args, NULL);
+ HttpFsForTesting fs(args, NULL);
// Multiple consecutive newlines or spaces should be ignored.
char manifest[] = "-r-- 123 /mydir/foo\n\n-rw- 234 /thatdir/bar\n";
- ASSERT_EQ(0, mnt.ParseManifest(manifest));
+ ASSERT_EQ(0, fs.ParseManifest(manifest));
- ScopedMountNode root;
- EXPECT_EQ(0, mnt.FindOrCreateDir(Path("/"), &root));
- ASSERT_NE((MountNode*)NULL, root.get());
+ ScopedNode root;
+ EXPECT_EQ(0, fs.FindOrCreateDir(Path("/"), &root));
+ ASSERT_NE((Node*)NULL, root.get());
EXPECT_EQ(2, root->ChildCount());
- ScopedMountNode dir;
- EXPECT_EQ(0, mnt.FindOrCreateDir(Path("/mydir"), &dir));
- ASSERT_NE((MountNode*)NULL, dir.get());
+ ScopedNode dir;
+ EXPECT_EQ(0, fs.FindOrCreateDir(Path("/mydir"), &dir));
+ ASSERT_NE((Node*)NULL, dir.get());
EXPECT_EQ(1, dir->ChildCount());
- MountNode* node = (*mnt.GetNodeCacheForTesting())["/mydir/foo"].get();
- EXPECT_NE((MountNode*)NULL, node);
+ Node* node = (*fs.GetNodeCacheForTesting())["/mydir/foo"].get();
+ EXPECT_NE((Node*)NULL, node);
EXPECT_EQ(0, node->GetSize(&result_size));
EXPECT_EQ(123, result_size);
// Since these files are cached thanks to the manifest, we can open them
// without accessing the PPAPI URL API.
- ScopedMountNode foo;
- ASSERT_EQ(0, mnt.Open(Path("/mydir/foo"), O_RDONLY, &foo));
+ ScopedNode foo;
+ ASSERT_EQ(0, fs.Open(Path("/mydir/foo"), O_RDONLY, &foo));
- ScopedMountNode bar;
- ASSERT_EQ(0, mnt.Open(Path("/thatdir/bar"), O_RDWR, &bar));
+ ScopedNode bar;
+ ASSERT_EQ(0, fs.Open(Path("/thatdir/bar"), O_RDWR, &bar));
struct stat sfoo;
struct stat sbar;
diff --git a/native_client_sdk/src/tests/nacl_io_test/kernel_object_test.cc b/native_client_sdk/src/tests/nacl_io_test/kernel_object_test.cc
index 67e70f4..cfa1ca4 100644
--- a/native_client_sdk/src/tests/nacl_io_test/kernel_object_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/kernel_object_test.cc
@@ -12,27 +12,27 @@
#include "gtest/gtest.h"
+#include "nacl_io/filesystem.h"
#include "nacl_io/kernel_handle.h"
#include "nacl_io/kernel_object.h"
-#include "nacl_io/mount.h"
#include "nacl_io/path.h"
using namespace nacl_io;
namespace {
-class MountNodeRefMock : public MountNode {
+class NodeForTesting : public Node {
public:
- MountNodeRefMock(Mount* mnt) : MountNode(mnt) {}
+ explicit NodeForTesting(Filesystem* fs) : Node(fs) {}
};
-class MountRefMock : public Mount {
+class FilesystemForTesting : public Filesystem {
public:
- MountRefMock() {}
+ FilesystemForTesting() {}
public:
Error Access(const Path& path, int a_mode) { return ENOSYS; }
- Error Open(const Path& path, int mode, ScopedMountNode* out_node) {
+ Error Open(const Path& path, int mode, ScopedNode* out_node) {
out_node->reset(NULL);
return ENOSYS;
}
@@ -43,70 +43,67 @@ class MountRefMock : public Mount {
Error Rename(const Path& path, const Path& newpath) { return 0; }
};
-class KernelHandleRefMock : public KernelHandle {
+class KernelHandleForTesting : public KernelHandle {
public:
- KernelHandleRefMock(const ScopedMount& mnt, const ScopedMountNode& node)
- : KernelHandle(mnt, node) {}
+ KernelHandleForTesting(const ScopedFilesystem& fs, const ScopedNode& node)
+ : KernelHandle(fs, node) {}
};
class KernelObjectTest : public ::testing::Test {
public:
void SetUp() {
- mnt.reset(new MountRefMock());
- node.reset(new MountNodeRefMock(mnt.get()));
+ fs.reset(new FilesystemForTesting());
+ node.reset(new NodeForTesting(fs.get()));
}
void TearDown() {
- // mnt is ref-counted, it doesn't need to be explicitly deleted.
+ // fs is ref-counted, it doesn't need to be explicitly deleted.
node.reset(NULL);
- mnt.reset(NULL);
+ fs.reset(NULL);
}
KernelObject proxy;
- ScopedMount mnt;
- ScopedMountNode node;
+ ScopedFilesystem fs;
+ ScopedNode node;
};
} // namespace
-#include <nacl_io/mount_mem.h>
-#include <nacl_io/mount_http.h>
-
TEST_F(KernelObjectTest, Referencing) {
- // The mount and node should have 1 ref count at this point
- EXPECT_EQ(1, mnt->RefCount());
+ // The filesystem and node should have 1 ref count at this point
+ EXPECT_EQ(1, fs->RefCount());
EXPECT_EQ(1, node->RefCount());
- // Pass the mount and node into a KernelHandle
- KernelHandle* raw_handle = new KernelHandleRefMock(mnt, node);
+ // Pass the filesystem and node into a KernelHandle
+ KernelHandle* raw_handle = new KernelHandleForTesting(fs, node);
ScopedKernelHandle handle_a(raw_handle);
- // The mount and node should have 1 ref count at this point
+ // The filesystem and node should have 1 ref count at this point
EXPECT_EQ(1, handle_a->RefCount());
- EXPECT_EQ(2, mnt->RefCount());
+ EXPECT_EQ(2, fs->RefCount());
EXPECT_EQ(2, node->RefCount());
ScopedKernelHandle handle_b = handle_a;
- // There should be two references to the KernelHandle, the mount and node
+ // There should be two references to the KernelHandle, the filesystem and node
// should be unchanged.
EXPECT_EQ(2, handle_a->RefCount());
EXPECT_EQ(2, handle_b->RefCount());
EXPECT_EQ(handle_a.get(), handle_b.get());
- EXPECT_EQ(2, mnt->RefCount());
+ EXPECT_EQ(2, fs->RefCount());
EXPECT_EQ(2, node->RefCount());
// Allocating an FD should cause the KernelProxy to ref the handle and
- // the node and mount should be unchanged.
+ // the node and filesystem should be unchanged.
int fd1 = proxy.AllocateFD(handle_a);
EXPECT_EQ(3, handle_a->RefCount());
- EXPECT_EQ(2, mnt->RefCount());
+ EXPECT_EQ(2, fs->RefCount());
EXPECT_EQ(2, node->RefCount());
// If we "dup" the handle, we should bump the ref count on the handle
int fd2 = proxy.AllocateFD(handle_b);
EXPECT_EQ(4, handle_a->RefCount());
- EXPECT_EQ(2, mnt->RefCount());
+ EXPECT_EQ(2, fs->RefCount());
EXPECT_EQ(2, node->RefCount());
// Handles are expected to come out in order
@@ -116,7 +113,7 @@ TEST_F(KernelObjectTest, Referencing) {
// Now we "free" the handles, since the proxy should hold them.
handle_a.reset(NULL);
handle_b.reset(NULL);
- EXPECT_EQ(2, mnt->RefCount());
+ EXPECT_EQ(2, fs->RefCount());
EXPECT_EQ(2, node->RefCount());
// We should find the handle by either fd
@@ -126,7 +123,7 @@ TEST_F(KernelObjectTest, Referencing) {
EXPECT_EQ(raw_handle, handle_b.get());
EXPECT_EQ(4, handle_a->RefCount());
- EXPECT_EQ(2, mnt->RefCount());
+ EXPECT_EQ(2, fs->RefCount());
EXPECT_EQ(2, node->RefCount());
// A non existent fd should fail, and handleA should decrement as handleB
@@ -144,37 +141,37 @@ TEST_F(KernelObjectTest, Referencing) {
handle_b.reset();
EXPECT_EQ(2, raw_handle->RefCount());
- EXPECT_EQ(2, mnt->RefCount());
+ EXPECT_EQ(2, fs->RefCount());
EXPECT_EQ(2, node->RefCount());
proxy.FreeFD(fd2);
EXPECT_EQ(1, raw_handle->RefCount());
- EXPECT_EQ(2, mnt->RefCount());
+ EXPECT_EQ(2, fs->RefCount());
EXPECT_EQ(2, node->RefCount());
proxy.FreeFD(fd1);
- EXPECT_EQ(1, mnt->RefCount());
+ EXPECT_EQ(1, fs->RefCount());
EXPECT_EQ(1, node->RefCount());
}
TEST_F(KernelObjectTest, FreeAndReassignFD) {
- // The mount and node should have 1 ref count at this point
- EXPECT_EQ(1, mnt->RefCount());
+ // The filesystem and node should have 1 ref count at this point
+ EXPECT_EQ(1, fs->RefCount());
EXPECT_EQ(1, node->RefCount());
- KernelHandle* raw_handle = new KernelHandleRefMock(mnt, node);
+ KernelHandle* raw_handle = new KernelHandleForTesting(fs, node);
ScopedKernelHandle handle(raw_handle);
- EXPECT_EQ(2, mnt->RefCount());
+ EXPECT_EQ(2, fs->RefCount());
EXPECT_EQ(2, node->RefCount());
EXPECT_EQ(1, raw_handle->RefCount());
proxy.AllocateFD(handle);
- EXPECT_EQ(2, mnt->RefCount());
+ EXPECT_EQ(2, fs->RefCount());
EXPECT_EQ(2, node->RefCount());
EXPECT_EQ(2, raw_handle->RefCount());
proxy.FreeAndReassignFD(5, handle);
- EXPECT_EQ(2, mnt->RefCount());
+ EXPECT_EQ(2, fs->RefCount());
EXPECT_EQ(2, node->RefCount());
EXPECT_EQ(3, raw_handle->RefCount());
diff --git a/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc b/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc
index 2707ad4..44c158d 100644
--- a/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc
@@ -14,16 +14,16 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#include "mount_mock.h"
-#include "mount_node_mock.h"
+#include "mock_fs.h"
+#include "mock_node.h"
+#include "nacl_io/filesystem.h"
#include "nacl_io/kernel_intercept.h"
#include "nacl_io/kernel_proxy.h"
-#include "nacl_io/mount.h"
-#include "nacl_io/mount_mem.h"
+#include "nacl_io/memfs/mem_fs.h"
#include "nacl_io/osmman.h"
#include "nacl_io/path.h"
-#include "nacl_io/typed_mount_factory.h"
+#include "nacl_io/typed_fs_factory.h"
using namespace nacl_io;
using namespace sdk_util;
@@ -39,14 +39,14 @@ using ::testing::WithArgs;
namespace {
-class KernelProxyFriend : public KernelProxy {
+class KernelProxyTest_KernelProxy : public KernelProxy {
public:
- Mount* RootMount() {
- ScopedMount mnt;
+ Filesystem* RootFs() {
+ ScopedFilesystem fs;
Path path;
- AcquireMountAndRelPath("/", &mnt, &path);
- return mnt.get();
+ AcquireFsAndRelPath("/", &fs, &path);
+ return fs.get();
}
};
@@ -61,12 +61,10 @@ class KernelProxyTest : public ::testing::Test {
EXPECT_EQ(0, kp_.mount("", "/", "memfs", 0, NULL));
}
- void TearDown() {
- ki_uninit();
- }
+ void TearDown() { ki_uninit(); }
protected:
- KernelProxyFriend kp_;
+ KernelProxyTest_KernelProxy kp_;
};
} // namespace
@@ -83,7 +81,7 @@ static int ki_fcntl_wrapper(int fd, int request, ...) {
* Test for fcntl commands F_SETFD and F_GETFD. This
* is tested here rather than in the mount_node tests
* since the fd flags are not stored in the kernel_handle
- * or the mount node but directly in the FD mapping.
+ * or the filesystem node but directly in the FD mapping.
*/
TEST_F(KernelProxyTest, Fcntl_GETFD) {
int fd = ki_open("/test", O_RDWR | O_CREAT);
@@ -95,7 +93,7 @@ TEST_F(KernelProxyTest, Fcntl_GETFD) {
// Check that setting FD_CLOEXEC works
int flags = FD_CLOEXEC;
ASSERT_EQ(0, ki_fcntl_wrapper(fd, F_SETFD, flags))
- << "fcntl failed with: " << strerror(errno);
+ << "fcntl failed with: " << strerror(errno);
ASSERT_EQ(FD_CLOEXEC, ki_fcntl_wrapper(fd, F_GETFD));
// Check that setting invalid flag causes EINVAL
@@ -109,10 +107,10 @@ TEST_F(KernelProxyTest, FileLeak) {
char filename[128];
int garbage[buffer_size];
- MountMem* mount = (MountMem*)kp_.RootMount();
- ScopedMountNode root;
+ MemFs* filesystem = (MemFs*)kp_.RootFs();
+ ScopedNode root;
- ASSERT_EQ(0, mount->Open(Path("/"), O_RDONLY, &root));
+ ASSERT_EQ(0, filesystem->Open(Path("/"), O_RDONLY, &root));
ASSERT_EQ(0, root->ChildCount());
for (int file_num = 0; file_num < 4096; file_num++) {
@@ -128,9 +126,7 @@ TEST_F(KernelProxyTest, FileLeak) {
}
static bool g_handler_called = false;
-static void sighandler(int) {
- g_handler_called = true;
-}
+static void sighandler(int) { g_handler_called = true; }
TEST_F(KernelProxyTest, Sigaction) {
struct sigaction action;
@@ -424,24 +420,24 @@ namespace {
StringMap_t g_string_map;
-class MountMockInit : public MountMem {
+class KernelProxyMountTest_Filesystem : public MemFs {
public:
- using MountMem::Init;
+ using MemFs::Init;
- virtual Error Init(const MountInitArgs& args) {
+ virtual Error Init(const FsInitArgs& args) {
g_string_map = args.string_map;
if (g_string_map.find("false") != g_string_map.end())
return EINVAL;
return 0;
}
- friend class TypedMountFactory<MountMockInit>;
+ friend class TypedFsFactory<KernelProxyMountTest_Filesystem>;
};
-class KernelProxyMountMock : public KernelProxy {
+class KernelProxyMountTest_KernelProxy : public KernelProxy {
virtual Error Init(PepperInterface* ppapi) {
KernelProxy::Init(NULL);
- factories_["initfs"] = new TypedMountFactory<MountMockInit>;
+ factories_["initfs"] = new TypedFsFactory<KernelProxyMountTest_Filesystem>;
return 0;
}
};
@@ -450,16 +446,12 @@ class KernelProxyMountTest : public ::testing::Test {
public:
KernelProxyMountTest() {}
- void SetUp() {
- ki_init(&kp_);
- }
+ void SetUp() { ki_init(&kp_); }
- void TearDown() {
- ki_uninit();
- }
+ void TearDown() { ki_uninit(); }
private:
- KernelProxyMountMock kp_;
+ KernelProxyMountTest_KernelProxy kp_;
};
} // namespace
@@ -480,9 +472,10 @@ namespace {
int g_MMapCount = 0;
-class MountNodeMockMMap : public MountNode {
+class KernelProxyMMapTest_Node : public Node {
public:
- MountNodeMockMMap(Mount* mount) : MountNode(mount), node_mmap_count_(0) {
+ KernelProxyMMapTest_Node(Filesystem* filesystem)
+ : Node(filesystem), node_mmap_count_(0) {
EXPECT_EQ(0, Init(0));
}
@@ -514,15 +507,15 @@ class MountNodeMockMMap : public MountNode {
int node_mmap_count_;
};
-class MountMockMMap : public Mount {
+class KernelProxyMMapTest_Filesystem : public Filesystem {
public:
virtual Error Access(const Path& path, int a_mode) { return 0; }
- virtual Error Open(const Path& path, int mode, ScopedMountNode* out_node) {
- out_node->reset(new MountNodeMockMMap(this));
+ virtual Error Open(const Path& path, int mode, ScopedNode* out_node) {
+ out_node->reset(new KernelProxyMMapTest_Node(this));
return 0;
}
- virtual Error OpenResource(const Path& path, ScopedMountNode* out_node) {
+ virtual Error OpenResource(const Path& path, ScopedNode* out_node) {
out_node->reset(NULL);
return ENOSYS;
}
@@ -532,13 +525,13 @@ class MountMockMMap : public Mount {
virtual Error Remove(const Path& path) { return ENOSYS; }
virtual Error Rename(const Path& path, const Path& newpath) { return ENOSYS; }
- friend class TypedMountFactory<MountMockMMap>;
+ friend class TypedFsFactory<KernelProxyMMapTest_Filesystem>;
};
-class KernelProxyMockMMap : public KernelProxy {
+class KernelProxyMMapTest_KernelProxy : public KernelProxy {
virtual Error Init(PepperInterface* ppapi) {
KernelProxy::Init(NULL);
- factories_["mmapfs"] = new TypedMountFactory<MountMockMMap>;
+ factories_["mmapfs"] = new TypedFsFactory<KernelProxyMMapTest_Filesystem>;
return 0;
}
};
@@ -547,16 +540,12 @@ class KernelProxyMMapTest : public ::testing::Test {
public:
KernelProxyMMapTest() {}
- void SetUp() {
- ki_init(&kp_);
- }
+ void SetUp() { ki_init(&kp_); }
- void TearDown() {
- ki_uninit();
- }
+ void TearDown() { ki_uninit(); }
private:
- KernelProxyMockMMap kp_;
+ KernelProxyMMapTest_KernelProxy kp_;
};
} // namespace
@@ -589,36 +578,36 @@ TEST_F(KernelProxyMMapTest, MMap) {
namespace {
-class SingletonMountFactory : public MountFactory {
+class SingletonFsFactory : public FsFactory {
public:
- SingletonMountFactory(const ScopedMount& mount) : mount_(mount) {}
+ SingletonFsFactory(const ScopedFilesystem& filesystem) : mount_(filesystem) {}
- virtual Error CreateMount(const MountInitArgs& args,
- ScopedMount* out_mount) {
- *out_mount = mount_;
+ virtual Error CreateFilesystem(const FsInitArgs& args,
+ ScopedFilesystem* out_fs) {
+ *out_fs = mount_;
return 0;
}
private:
- ScopedMount mount_;
+ ScopedFilesystem mount_;
};
-class KernelProxyError : public KernelProxy {
+class KernelProxyErrorTest_KernelProxy : public KernelProxy {
public:
- KernelProxyError() : mnt_(new MountMock) {}
+ KernelProxyErrorTest_KernelProxy() : fs_(new MockFs) {}
virtual Error Init(PepperInterface* ppapi) {
KernelProxy::Init(ppapi);
- factories_["testfs"] = new SingletonMountFactory(mnt_);
+ factories_["testfs"] = new SingletonFsFactory(fs_);
- EXPECT_CALL(*mnt_, Destroy()).Times(1);
+ EXPECT_CALL(*fs_, Destroy()).Times(1);
return 0;
}
- ScopedRef<MountMock> mnt() { return mnt_; }
+ ScopedRef<MockFs> fs() { return fs_; }
private:
- ScopedRef<MountMock> mnt_;
+ ScopedRef<MockFs> fs_;
};
class KernelProxyErrorTest : public ::testing::Test {
@@ -632,22 +621,20 @@ class KernelProxyErrorTest : public ::testing::Test {
EXPECT_EQ(0, kp_.mount("", "/", "testfs", 0, NULL));
}
- void TearDown() {
- ki_uninit();
- }
+ void TearDown() { ki_uninit(); }
- ScopedRef<MountMock> mnt() { return kp_.mnt(); }
+ ScopedRef<MockFs> fs() { return kp_.fs(); }
private:
- KernelProxyError kp_;
+ KernelProxyErrorTest_KernelProxy kp_;
};
} // namespace
TEST_F(KernelProxyErrorTest, WriteError) {
- ScopedRef<MountMock> mock_mnt(mnt());
- ScopedRef<MountNodeMock> mock_node(new MountNodeMock(&*mock_mnt));
- EXPECT_CALL(*mock_mnt, Open(_, _, _))
+ ScopedRef<MockFs> mock_fs(fs());
+ ScopedRef<MockNode> mock_node(new MockNode(&*mock_fs));
+ EXPECT_CALL(*mock_fs, Open(_, _, _))
.WillOnce(DoAll(SetArgPointee<2>(mock_node), Return(0)));
EXPECT_CALL(*mock_node, Write(_, _, _, _))
@@ -661,15 +648,15 @@ TEST_F(KernelProxyErrorTest, WriteError) {
char buf[20];
EXPECT_EQ(-1, ki_write(fd, &buf[0], 20));
- // The Mount should be able to return whatever error it wants and have it
+ // The Filesystem should be able to return whatever error it wants and have it
// propagate through.
EXPECT_EQ(1234, errno);
}
TEST_F(KernelProxyErrorTest, ReadError) {
- ScopedRef<MountMock> mock_mnt(mnt());
- ScopedRef<MountNodeMock> mock_node(new MountNodeMock(&*mock_mnt));
- EXPECT_CALL(*mock_mnt, Open(_, _, _))
+ ScopedRef<MockFs> mock_fs(fs());
+ ScopedRef<MockNode> mock_node(new MockNode(&*mock_fs));
+ EXPECT_CALL(*mock_fs, Open(_, _, _))
.WillOnce(DoAll(SetArgPointee<2>(mock_node), Return(0)));
EXPECT_CALL(*mock_node, Read(_, _, _, _))
@@ -683,7 +670,7 @@ TEST_F(KernelProxyErrorTest, ReadError) {
char buf[20];
EXPECT_EQ(-1, ki_read(fd, &buf[0], 20));
- // The Mount should be able to return whatever error it wants and have it
+ // The Filesystem should be able to return whatever error it wants and have it
// propagate through.
EXPECT_EQ(1234, errno);
}
diff --git a/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc b/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc
index 2eb474b..1ba70ca 100644
--- a/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc
@@ -12,7 +12,7 @@
#include <vector>
#include "gtest/gtest.h"
-#include "kernel_proxy_mock.h"
+#include "mock_kernel_proxy.h"
#include "nacl_io/kernel_intercept.h"
#include "nacl_io/kernel_wrap.h"
#include "nacl_io/osmman.h"
@@ -123,7 +123,7 @@ class KernelWrapTest : public ::testing::Test {
virtual void TearDown() { ki_uninit(); }
- KernelProxyMock mock;
+ MockKernelProxy mock;
};
} // namespace
diff --git a/native_client_sdk/src/tests/nacl_io_test/mount_node_test.cc b/native_client_sdk/src/tests/nacl_io_test/mem_fs_node_test.cc
index efa9c80..e6ea301 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mount_node_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/mem_fs_node_test.cc
@@ -10,60 +10,64 @@
#include "gtest/gtest.h"
+#include "nacl_io/devfs/dev_fs.h"
+#include "nacl_io/dir_node.h"
#include "nacl_io/error.h"
#include "nacl_io/ioctl.h"
#include "nacl_io/kernel_handle.h"
#include "nacl_io/kernel_proxy.h"
-#include "nacl_io/mount_dev.h"
-#include "nacl_io/mount_mem.h"
-#include "nacl_io/mount_node.h"
-#include "nacl_io/mount_node_dir.h"
-#include "nacl_io/mount_node_mem.h"
+#include "nacl_io/memfs/mem_fs.h"
+#include "nacl_io/memfs/mem_fs_node.h"
+#include "nacl_io/node.h"
#include "nacl_io/osdirent.h"
-#define NULL_NODE ((MountNode*) NULL)
+#define NULL_NODE ((Node*)NULL)
using namespace nacl_io;
-static int s_AllocNum = 0;
+static int s_alloc_num = 0;
-class MockMount : public MountMem {
+namespace {
+
+class MemFsForTesting : public MemFs {
public:
- MockMount() {
- MountInitArgs args(1);
+ MemFsForTesting() {
+ FsInitArgs args(1);
EXPECT_EQ(0, Init(args));
}
int num_nodes() { return inode_pool_.size(); }
};
-class MockNode : public MountNodeMem {
+class MemFsNodeForTesting : public MemFsNode {
public:
- MockNode() : MountNodeMem(NULL) { s_AllocNum++; }
+ MemFsNodeForTesting() : MemFsNode(NULL) { s_alloc_num++; }
- ~MockNode() { s_AllocNum--; }
+ ~MemFsNodeForTesting() { s_alloc_num--; }
- using MountNodeMem::Init;
- using MountNodeMem::AddChild;
- using MountNodeMem::RemoveChild;
- using MountNodeMem::FindChild;
+ using MemFsNode::Init;
+ using MemFsNode::AddChild;
+ using MemFsNode::RemoveChild;
+ using MemFsNode::FindChild;
};
-class MockDir : public MountNodeDir {
+class DirNodeForTesting : public DirNode {
public:
- MockDir() : MountNodeDir(NULL) { s_AllocNum++; }
+ DirNodeForTesting() : DirNode(NULL) { s_alloc_num++; }
- ~MockDir() { s_AllocNum--; }
+ ~DirNodeForTesting() { s_alloc_num--; }
- using MountNodeDir::Init;
- using MountNodeDir::AddChild;
- using MountNodeDir::RemoveChild;
- using MountNodeDir::FindChild;
+ using DirNode::Init;
+ using DirNode::AddChild;
+ using DirNode::RemoveChild;
+ using DirNode::FindChild;
};
-TEST(MountNodeTest, File) {
- MockNode file;
- ScopedMountNode result_node;
+} // namespace
+
+TEST(MemFsNodeTest, File) {
+ MemFsNodeForTesting file;
+ ScopedNode result_node;
size_t result_size = 0;
int result_bytes = 0;
@@ -114,8 +118,8 @@ TEST(MountNodeTest, File) {
EXPECT_EQ(NULL_NODE, result_node.get());
}
-TEST(MountNodeTest, FTruncate) {
- MockNode file;
+TEST(MemFsNodeTest, FTruncate) {
+ MemFsNodeForTesting file;
size_t result_size = 0;
int result_bytes = 0;
@@ -161,11 +165,11 @@ TEST(MountNodeTest, FTruncate) {
EXPECT_EQ(0, memcmp(buffer, data, 100));
}
-TEST(MountNodeTest, Fcntl_GETFL) {
- MockNode* node = new MockNode();
- ScopedMount mnt(new MockMount());
- ScopedMountNode file(node);
- KernelHandle handle(mnt, file);
+TEST(MemFsNodeTest, Fcntl_GETFL) {
+ MemFsNodeForTesting* node = new MemFsNodeForTesting();
+ ScopedFilesystem fs(new MemFsForTesting());
+ ScopedNode file(node);
+ KernelHandle handle(fs, file);
ASSERT_EQ(0, handle.Init(O_CREAT | O_APPEND));
// Test invalid fcntl command.
@@ -189,10 +193,10 @@ TEST(MountNodeTest, Fcntl_GETFL) {
ASSERT_EQ(EPERM, handle.Fcntl(F_SETFL, NULL, flags));
}
-TEST(MountNodeTest, Directory) {
- s_AllocNum = 0;
- MockDir root;
- ScopedMountNode result_node;
+TEST(MemFsNodeTest, Directory) {
+ s_alloc_num = 0;
+ DirNodeForTesting root;
+ ScopedNode result_node;
size_t result_size = 0;
int result_bytes = 0;
@@ -217,9 +221,9 @@ TEST(MountNodeTest, Directory) {
EXPECT_EQ(EISDIR, root.Write(attr, buf1, sizeof(buf1), &result_bytes));
// Test directory operations
- MockNode* raw_file = new MockNode;
+ MemFsNodeForTesting* raw_file = new MemFsNodeForTesting;
EXPECT_EQ(0, raw_file->Init(0));
- ScopedMountNode file(raw_file);
+ ScopedNode file(raw_file);
EXPECT_EQ(0, root.RefCount());
EXPECT_EQ(1, file->RefCount());
@@ -261,7 +265,7 @@ TEST(MountNodeTest, Directory) {
EXPECT_EQ(2, file->GetLinks());
EXPECT_EQ(3, file->RefCount());
- EXPECT_EQ(2, s_AllocNum);
+ EXPECT_EQ(2, s_alloc_num);
EXPECT_EQ(0, root.FindChild("F1", &result_node));
EXPECT_NE(NULL_NODE, result_node.get());
EXPECT_EQ(0, root.FindChild("F2", &result_node));
@@ -269,23 +273,23 @@ TEST(MountNodeTest, Directory) {
EXPECT_EQ(ENOENT, root.FindChild("F3", &result_node));
EXPECT_EQ(NULL_NODE, result_node.get());
- EXPECT_EQ(2, s_AllocNum);
+ EXPECT_EQ(2, s_alloc_num);
EXPECT_EQ(0, root.RemoveChild("F1"));
EXPECT_EQ(1, file->GetLinks());
EXPECT_EQ(2, file->RefCount());
EXPECT_EQ(0, root.RemoveChild("F2"));
EXPECT_EQ(0, file->GetLinks());
EXPECT_EQ(1, file->RefCount());
- EXPECT_EQ(2, s_AllocNum);
+ EXPECT_EQ(2, s_alloc_num);
file.reset();
- EXPECT_EQ(1, s_AllocNum);
+ EXPECT_EQ(1, s_alloc_num);
}
-TEST(MountNodeTest, OpenMode) {
- MockNode* node = new MockNode();
- ScopedMount mnt(new MockMount());
- ScopedMountNode file(node);
+TEST(MemFsNodeTest, OpenMode) {
+ MemFsNodeForTesting* node = new MemFsNodeForTesting();
+ ScopedFilesystem fs(new MemFsForTesting());
+ ScopedNode file(node);
const char write_buf[] = "hello world";
char read_buf[10];
@@ -293,7 +297,7 @@ TEST(MountNodeTest, OpenMode) {
// Write some data to the file
{
- KernelHandle handle(mnt, file);
+ KernelHandle handle(fs, file);
ASSERT_EQ(0, handle.Init(O_CREAT | O_WRONLY));
ASSERT_EQ(0, handle.Write(write_buf, strlen(write_buf), &byte_count));
ASSERT_EQ(byte_count, strlen(write_buf));
@@ -302,7 +306,7 @@ TEST(MountNodeTest, OpenMode) {
// Reading from the O_WRONLY handle should be impossible
{
byte_count = 0;
- KernelHandle handle(mnt, file);
+ KernelHandle handle(fs, file);
ASSERT_EQ(0, handle.Init(O_WRONLY));
ASSERT_EQ(EACCES, handle.Read(read_buf, 10, &byte_count));
ASSERT_EQ(0, handle.Write(write_buf, strlen(write_buf), &byte_count));
@@ -312,7 +316,7 @@ TEST(MountNodeTest, OpenMode) {
// Writing to a O_RDONLY handle should fail
{
byte_count = 0;
- KernelHandle handle(mnt, file);
+ KernelHandle handle(fs, file);
ASSERT_EQ(0, handle.Init(O_RDONLY));
ASSERT_EQ(EACCES, handle.Write(write_buf, strlen(write_buf), &byte_count));
ASSERT_EQ(0, handle.Read(read_buf, sizeof(read_buf), &byte_count));
diff --git a/native_client_sdk/src/tests/nacl_io_test/mount_mock.cc b/native_client_sdk/src/tests/nacl_io_test/mock_fs.cc
index 1006822..6d7f4b1 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mount_mock.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/mock_fs.cc
@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "mount_mock.h"
+#include "mock_fs.h"
-MountMock::MountMock() {}
-
-MountMock::~MountMock() {}
+MockFs::MockFs() {}
+MockFs::~MockFs() {}
diff --git a/native_client_sdk/src/tests/nacl_io_test/mount_mock.h b/native_client_sdk/src/tests/nacl_io_test/mock_fs.h
index cde3bbb..e0dd5e8 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mount_mock.h
+++ b/native_client_sdk/src/tests/nacl_io_test/mock_fs.h
@@ -2,30 +2,30 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_TEST_MOUNT_MOCK_H_
-#define LIBRARIES_NACL_IO_TEST_MOUNT_MOCK_H_
+#ifndef LIBRARIES_NACL_IO_TEST_MOCK_FS_H_
+#define LIBRARIES_NACL_IO_TEST_MOCK_FS_H_
#include "gmock/gmock.h"
-#include "nacl_io/mount.h"
+#include "nacl_io/filesystem.h"
-class MountMock : public nacl_io::Mount {
+class MockFs : public nacl_io::Filesystem {
public:
typedef nacl_io::Error Error;
- typedef nacl_io::MountInitArgs MountInitArgs;
+ typedef nacl_io::FsInitArgs FsInitArgs;
typedef nacl_io::Path Path;
typedef nacl_io::PepperInterface PepperInterface;
- typedef nacl_io::ScopedMountNode ScopedMountNode;
+ typedef nacl_io::ScopedNode ScopedNode;
typedef nacl_io::StringMap_t StringMap_t;
- MountMock();
- virtual ~MountMock();
+ MockFs();
+ virtual ~MockFs();
- MOCK_METHOD1(Init, Error(const MountInitArgs&));
+ MOCK_METHOD1(Init, Error(const FsInitArgs&));
MOCK_METHOD0(Destroy, void());
MOCK_METHOD2(Access, Error(const Path&, int));
- MOCK_METHOD3(Open, Error(const Path&, int, ScopedMountNode*));
- MOCK_METHOD2(OpenResource, Error(const Path&, ScopedMountNode*));
+ MOCK_METHOD3(Open, Error(const Path&, int, ScopedNode*));
+ MOCK_METHOD2(OpenResource, Error(const Path&, ScopedNode*));
MOCK_METHOD1(Unlink, Error(const Path&));
MOCK_METHOD2(Mkdir, Error(const Path&, int));
MOCK_METHOD1(Rmdir, Error(const Path&));
@@ -33,4 +33,4 @@ class MountMock : public nacl_io::Mount {
MOCK_METHOD2(Rename, Error(const Path&, const Path&));
};
-#endif // LIBRARIES_NACL_IO_TEST_MOUNT_MOCK_H_
+#endif // LIBRARIES_NACL_IO_TEST_MOCK_FS_H_
diff --git a/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.cc b/native_client_sdk/src/tests/nacl_io_test/mock_kernel_proxy.cc
index e3791fa..08c41a0 100644
--- a/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/mock_kernel_proxy.cc
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "kernel_proxy_mock.h"
+#include "mock_kernel_proxy.h"
#include "nacl_io/kernel_intercept.h"
-KernelProxyMock::KernelProxyMock() {}
+MockKernelProxy::MockKernelProxy() {}
-KernelProxyMock::~KernelProxyMock() {
+MockKernelProxy::~MockKernelProxy() {
// Uninitialize the kernel proxy so wrapped functions passthrough to their
// unwrapped versions.
ki_uninit();
diff --git a/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.h b/native_client_sdk/src/tests/nacl_io_test/mock_kernel_proxy.h
index 3c26039..d8b35c3 100644
--- a/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.h
+++ b/native_client_sdk/src/tests/nacl_io_test/mock_kernel_proxy.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_TEST_KERNEL_PROXY_MOCK_H_
-#define LIBRARIES_NACL_IO_TEST_KERNEL_PROXY_MOCK_H_
+#ifndef LIBRARIES_NACL_IO_TEST_MOCK_KERNEL_PROXY_H_
+#define LIBRARIES_NACL_IO_TEST_MOCK_KERNEL_PROXY_H_
#include <sys/types.h>
#include <sys/stat.h>
@@ -14,10 +14,10 @@
#include "nacl_io/ossocket.h"
#include "nacl_io/ostermios.h"
-class KernelProxyMock : public nacl_io::KernelProxy {
+class MockKernelProxy : public nacl_io::KernelProxy {
public:
- KernelProxyMock();
- virtual ~KernelProxyMock();
+ MockKernelProxy();
+ virtual ~MockKernelProxy();
MOCK_METHOD2(access, int(const char*, int));
MOCK_METHOD1(chdir, int(const char*));
@@ -99,4 +99,4 @@ class KernelProxyMock : public nacl_io::KernelProxy {
};
-#endif // LIBRARIES_NACL_IO_TEST_KERNEL_PROXY_MOCK_H_
+#endif // LIBRARIES_NACL_IO_TEST_MOCK_KERNEL_PROXY_H_
diff --git a/native_client_sdk/src/tests/nacl_io_test/mount_node_mock.cc b/native_client_sdk/src/tests/nacl_io_test/mock_node.cc
index 695af3a..1cc21f7 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mount_node_mock.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/mock_node.cc
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "mount_node_mock.h"
+#include "mock_node.h"
-MountNodeMock::MountNodeMock(nacl_io::Mount* mount) : MountNode(mount) {}
+MockNode::MockNode(nacl_io::Filesystem* mount) : Node(mount) {}
-MountNodeMock::~MountNodeMock() {}
+MockNode::~MockNode() {}
diff --git a/native_client_sdk/src/tests/nacl_io_test/mount_node_mock.h b/native_client_sdk/src/tests/nacl_io_test/mock_node.h
index 2edd767..c1113be 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mount_node_mock.h
+++ b/native_client_sdk/src/tests/nacl_io_test/mock_node.h
@@ -2,22 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_TEST_MOUNT_NODE_MOCK_H_
-#define LIBRARIES_NACL_IO_TEST_MOUNT_NODE_MOCK_H_
+#ifndef LIBRARIES_NACL_IO_TEST_MOCK_NODE_H_
+#define LIBRARIES_NACL_IO_TEST_MOCK_NODE_H_
#include "gmock/gmock.h"
+#include "nacl_io/filesystem.h"
#include "nacl_io/kernel_handle.h"
-#include "nacl_io/mount.h"
-class MountNodeMock : public nacl_io::MountNode {
+class MockNode : public nacl_io::Node {
public:
typedef nacl_io::Error Error;
typedef nacl_io::HandleAttr HandleAttr;
- typedef nacl_io::ScopedMountNode ScopedMountNode;
+ typedef nacl_io::ScopedNode ScopedNode;
- explicit MountNodeMock(nacl_io::Mount*);
- virtual ~MountNodeMock();
+ explicit MockNode(nacl_io::Filesystem*);
+ virtual ~MockNode();
MOCK_METHOD1(Init, Error(int));
MOCK_METHOD0(Destroy, void());
@@ -37,11 +37,11 @@ class MountNodeMock : public nacl_io::MountNode {
MOCK_METHOD0(IsaFile, bool());
MOCK_METHOD0(IsaTTY, bool());
MOCK_METHOD0(ChildCount, int());
- MOCK_METHOD2(AddChild, Error(const std::string&, const ScopedMountNode&));
+ MOCK_METHOD2(AddChild, Error(const std::string&, const ScopedNode&));
MOCK_METHOD1(RemoveChild, Error(const std::string&));
- MOCK_METHOD2(FindChild, Error(const std::string&, ScopedMountNode*));
+ MOCK_METHOD2(FindChild, Error(const std::string&, ScopedNode*));
MOCK_METHOD0(Link, void());
MOCK_METHOD0(Unlink, void());
};
-#endif // LIBRARIES_NACL_IO_TEST_MOUNT_NODE_MOCK_H_
+#endif // LIBRARIES_NACL_IO_TEST_MOCK_NODE_H_
diff --git a/native_client_sdk/src/tests/nacl_io_test/mount_dev_mock.h b/native_client_sdk/src/tests/nacl_io_test/mount_dev_mock.h
deleted file mode 100644
index 72ef88c..0000000
--- a/native_client_sdk/src/tests/nacl_io_test/mount_dev_mock.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIBRARIES_NACL_IO_TEST_MOUNT_NODE_MOCK_H_
-#define LIBRARIES_NACL_IO_TEST_MOUNT_NODE_MOCK_H_
-
-#include "gmock/gmock.h"
-
-#include "nacl_io/mount.h"
-#include "nacl_io/mount_dev.h"
-
-#define NULL_NODE ((MountNode*) NULL)
-
-class MountDevMock : public nacl_io::MountDev {
- public:
- MountDevMock() {
- Init(nacl_io::MountInitArgs(1));
- }
- int num_nodes() { return (int) inode_pool_.size(); }
-};
-
-#endif // LIBRARIES_NACL_IO_TEST_MOUNT_NODE_MOCK_H_
diff --git a/native_client_sdk/src/tests/nacl_io_test/mount_node_tty_test.cc b/native_client_sdk/src/tests/nacl_io_test/tty_test.cc
index 04cd84f..d79d8ea 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mount_node_tty_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/tty_test.cc
@@ -11,14 +11,13 @@
#include <sys/time.h>
#include <string>
+#include "dev_fs_for_testing.h"
#include "gtest/gtest.h"
-#include "mount_dev_mock.h"
+#include "nacl_io/devfs/dev_fs.h"
+#include "nacl_io/filesystem.h"
#include "nacl_io/ioctl.h"
#include "nacl_io/kernel_intercept.h"
#include "nacl_io/kernel_proxy.h"
-#include "nacl_io/mount.h"
-#include "nacl_io/mount_dev.h"
-#include "nacl_io/mount_mem.h"
#include "nacl_io/osdirent.h"
using namespace nacl_io;
@@ -29,9 +28,9 @@ class TtyTest : public ::testing::Test {
public:
void SetUp() {
ki_init(&kp_);
- ASSERT_EQ(0, mnt_.Access(Path("/tty"), R_OK | W_OK));
- ASSERT_EQ(EACCES, mnt_.Access(Path("/tty"), X_OK));
- ASSERT_EQ(0, mnt_.Open(Path("/tty"), O_RDWR, &dev_tty_));
+ ASSERT_EQ(0, fs_.Access(Path("/tty"), R_OK | W_OK));
+ ASSERT_EQ(EACCES, fs_.Access(Path("/tty"), X_OK));
+ ASSERT_EQ(0, fs_.Open(Path("/tty"), O_RDWR, &dev_tty_));
ASSERT_NE(NULL_NODE, dev_tty_.get());
}
@@ -41,8 +40,8 @@ class TtyTest : public ::testing::Test {
protected:
KernelProxy kp_;
- MountDevMock mnt_;
- ScopedMountNode dev_tty_;
+ DevFsForTesting fs_;
+ ScopedNode dev_tty_;
};
TEST_F(TtyTest, InvalidIoctl) {