summaryrefslogtreecommitdiffstats
path: root/native_client_sdk
diff options
context:
space:
mode:
authoryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-14 02:13:00 +0000
committeryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-14 02:13:00 +0000
commit5712f4a82bc23ab8174576c68129009351ca8453 (patch)
treec6ff2d9baa42b2ba65d2efd90a780e4854f252a9 /native_client_sdk
parent8c2a9d7db3bc82767b066c665466b386bbe5640d (diff)
downloadchromium_src-5712f4a82bc23ab8174576c68129009351ca8453.zip
chromium_src-5712f4a82bc23ab8174576c68129009351ca8453.tar.gz
chromium_src-5712f4a82bc23ab8174576c68129009351ca8453.tar.bz2
Revert 240799 "[NaCl SDK] nacl_io: Rename Mount -> Filesystem, M..."
Speculative revert to fix 32-bit NaCl failures. > [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 TBR=binji@chromium.org Review URL: https://codereview.chromium.org/115713002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240844 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rw-r--r--native_client_sdk/src/libraries/nacl_io/char_node.h21
-rw-r--r--native_client_sdk/src/libraries/nacl_io/dir_node.h70
-rw-r--r--native_client_sdk/src/libraries/nacl_io/event_emitter_pipe.cc (renamed from native_client_sdk/src/libraries/nacl_io/devfs/tty_event_emitter.cc)12
-rw-r--r--native_client_sdk/src/libraries/nacl_io/event_emitter_pipe.h (renamed from native_client_sdk/src/libraries/nacl_io/pipe/pipe_event_emitter.h)19
-rw-r--r--native_client_sdk/src/libraries/nacl_io/event_emitter_stream.cc (renamed from native_client_sdk/src/libraries/nacl_io/stream/stream_event_emitter.cc)14
-rw-r--r--native_client_sdk/src/libraries/nacl_io/event_emitter_stream.h (renamed from native_client_sdk/src/libraries/nacl_io/stream/stream_event_emitter.h)25
-rw-r--r--native_client_sdk/src/libraries/nacl_io/event_emitter_tcp.cc (renamed from native_client_sdk/src/libraries/nacl_io/socket/tcp_event_emitter.cc)33
-rw-r--r--native_client_sdk/src/libraries/nacl_io/event_emitter_tcp.h (renamed from native_client_sdk/src/libraries/nacl_io/socket/tcp_event_emitter.h)22
-rw-r--r--native_client_sdk/src/libraries/nacl_io/event_emitter_tty.cc (renamed from native_client_sdk/src/libraries/nacl_io/pipe/pipe_event_emitter.cc)12
-rw-r--r--native_client_sdk/src/libraries/nacl_io/event_emitter_tty.h (renamed from native_client_sdk/src/libraries/nacl_io/devfs/tty_event_emitter.h)19
-rw-r--r--native_client_sdk/src/libraries/nacl_io/event_emitter_udp.cc (renamed from native_client_sdk/src/libraries/nacl_io/socket/udp_event_emitter.cc)16
-rw-r--r--native_client_sdk/src/libraries/nacl_io/event_emitter_udp.h (renamed from native_client_sdk/src/libraries/nacl_io/socket/udp_event_emitter.h)21
-rw-r--r--native_client_sdk/src/libraries/nacl_io/fifo_packet.cc (renamed from native_client_sdk/src/libraries/nacl_io/socket/fifo_packet.cc)4
-rw-r--r--native_client_sdk/src/libraries/nacl_io/fifo_packet.h (renamed from native_client_sdk/src/libraries/nacl_io/socket/fifo_packet.h)0
-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_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/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/mount.cc (renamed from native_client_sdk/src/libraries/nacl_io/filesystem.cc)22
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount.h (renamed from native_client_sdk/src/libraries/nacl_io/filesystem.h)58
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_dev.cc (renamed from native_client_sdk/src/libraries/nacl_io/devfs/dev_fs.cc)88
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_dev.h (renamed from native_client_sdk/src/libraries/nacl_io/devfs/dev_fs.h)28
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_factory.h29
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_fuse.cc (renamed from native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.cc)145
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_fuse.h (renamed from native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.h)69
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_html5fs.cc (renamed from native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc)68
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_html5fs.h (renamed from native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.h)22
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_http.cc (renamed from native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.cc)88
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_http.h (renamed from native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.h)29
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_mem.cc (renamed from native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.cc)78
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_mem.h (renamed from native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.h)32
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node.cc (renamed from native_client_sdk/src/libraries/nacl_io/node.cc)88
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node.h (renamed from native_client_sdk/src/libraries/nacl_io/node.h)52
-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.cc (renamed from native_client_sdk/src/libraries/nacl_io/dir_node.cc)42
-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_html5fs.cc (renamed from native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc)137
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_html5fs.h (renamed from native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.h)20
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_http.cc (renamed from native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.cc)140
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_http.h (renamed from native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.h)16
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_mem.cc (renamed from native_client_sdk/src/libraries/nacl_io/memfs/mem_fs_node.cc)27
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_mem.h (renamed from native_client_sdk/src/libraries/nacl_io/memfs/mem_fs_node.h)16
-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_socket.cc (renamed from native_client_sdk/src/libraries/nacl_io/socket/socket_node.cc)222
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_socket.h (renamed from native_client_sdk/src/libraries/nacl_io/socket/socket_node.h)28
-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_node_stream.h (renamed from native_client_sdk/src/libraries/nacl_io/stream/stream_node.h)23
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_tcp.cc (renamed from native_client_sdk/src/libraries/nacl_io/socket/tcp_node.cc)231
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_tcp.h (renamed from native_client_sdk/src/libraries/nacl_io/socket/tcp_node.h)26
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_tty.cc (renamed from native_client_sdk/src/libraries/nacl_io/devfs/tty_node.cc)67
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_tty.h (renamed from native_client_sdk/src/libraries/nacl_io/devfs/tty_node.h)17
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_udp.cc (renamed from native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc)138
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_udp.h (renamed from native_client_sdk/src/libraries/nacl_io/socket/udp_node.h)20
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_passthrough.cc (renamed from native_client_sdk/src/libraries/nacl_io/passthroughfs/passthrough_fs.cc)41
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_passthrough.h37
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_stream.cc (renamed from native_client_sdk/src/libraries/nacl_io/stream/stream_fs.cc)47
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_stream.h (renamed from native_client_sdk/src/libraries/nacl_io/stream/stream_fs.h)41
-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/packet.cc (renamed from native_client_sdk/src/libraries/nacl_io/socket/packet.cc)2
-rw-r--r--native_client_sdk/src/libraries/nacl_io/packet.h (renamed from native_client_sdk/src/libraries/nacl_io/socket/packet.h)6
-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_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/stream/stream_node.cc51
-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_html5fs.cc (renamed from native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.cc)2
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5fs.h (renamed from native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.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/kernel_object_test.cc77
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.cc (renamed from native_client_sdk/src/tests/nacl_io_test/mock_kernel_proxy.cc)6
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.h (renamed from native_client_sdk/src/tests/nacl_io_test/mock_kernel_proxy.h)12
-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/mount_dev_mock.h23
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mount_fuse_test.cc (renamed from native_client_sdk/src/tests/nacl_io_test/fuse_fs_test.cc)54
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mount_html5fs_test.cc (renamed from native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc)174
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mount_http_test.cc (renamed from native_client_sdk/src/tests/nacl_io_test/http_fs_test.cc)155
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mount_mock.cc (renamed from native_client_sdk/src/tests/nacl_io_test/mock_fs.cc)7
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mount_mock.h (renamed from native_client_sdk/src/tests/nacl_io_test/mock_fs.h)24
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mount_node_mock.cc (renamed from native_client_sdk/src/tests/nacl_io_test/mock_node.cc)6
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mount_node_mock.h (renamed from native_client_sdk/src/tests/nacl_io_test/mock_node.h)20
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mount_node_test.cc (renamed from native_client_sdk/src/tests/nacl_io_test/mem_fs_node_test.cc)106
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mount_node_tty_test.cc (renamed from native_client_sdk/src/tests/nacl_io_test/tty_test.cc)17
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mount_test.cc (renamed from native_client_sdk/src/tests/nacl_io_test/filesystem_test.cc)273
101 files changed, 2539 insertions, 2404 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
deleted file mode 100644
index 9b996a4..0000000
--- a/native_client_sdk/src/libraries/nacl_io/char_node.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_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/dir_node.h b/native_client_sdk/src/libraries/nacl_io/dir_node.h
deleted file mode 100644
index ff7cc81..0000000
--- a/native_client_sdk/src/libraries/nacl_io/dir_node.h
+++ /dev/null
@@ -1,70 +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_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/devfs/tty_event_emitter.cc b/native_client_sdk/src/libraries/nacl_io/event_emitter_pipe.cc
index 5ebc36f..2c5308e 100644
--- a/native_client_sdk/src/libraries/nacl_io/devfs/tty_event_emitter.cc
+++ b/native_client_sdk/src/libraries/nacl_io/event_emitter_pipe.cc
@@ -2,25 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/devfs/tty_event_emitter.h"
+#include <poll.h>
+#include <stdint.h>
+#include <stdlib.h>
-#include <algorithm>
+#include "nacl_io/event_emitter_pipe.h"
namespace nacl_io {
-TtyEventEmitter::TtyEventEmitter(size_t size)
+EventEmitterPipe::EventEmitterPipe(size_t size)
: fifo_(std::max<size_t>(1, size)) {
UpdateStatus_Locked();
}
-size_t TtyEventEmitter::Read_Locked(char* data, size_t len) {
+size_t EventEmitterPipe::Read_Locked(char* data, size_t len) {
size_t out_len = fifo_.Read(data, len);
UpdateStatus_Locked();
return out_len;
}
-size_t TtyEventEmitter::Write_Locked(const char* data, size_t len) {
+size_t EventEmitterPipe::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/pipe/pipe_event_emitter.h b/native_client_sdk/src/libraries/nacl_io/event_emitter_pipe.h
index 5c731db..a357bea 100644
--- a/native_client_sdk/src/libraries/nacl_io/pipe/pipe_event_emitter.h
+++ b/native_client_sdk/src/libraries/nacl_io/event_emitter_pipe.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_PIPE_PIPE_EVENT_EMITTER_H_
-#define LIBRARIES_NACL_IO_PIPE_PIPE_EVENT_EMITTER_H_
+#ifndef LIBRARIES_NACL_IO_EVENT_EMITTER_PIPE_H_
+#define LIBRARIES_NACL_IO_EVENT_EMITTER_PIPE_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 PipeEventEmitter;
-typedef sdk_util::ScopedRef<PipeEventEmitter> ScopedPipeEventEmitter;
+class EventEmitterPipe;
+typedef sdk_util::ScopedRef<EventEmitterPipe> ScopedEventEmitterPipe;
-class PipeEventEmitter : public StreamEventEmitter {
+class EventEmitterPipe : public EventEmitterStream {
public:
- PipeEventEmitter(size_t size);
+ EventEmitterPipe(size_t size);
size_t Read_Locked(char* data, size_t len);
size_t Write_Locked(const char* data, size_t len);
@@ -33,9 +33,10 @@ class PipeEventEmitter : public StreamEventEmitter {
private:
FIFOChar fifo_;
- DISALLOW_COPY_AND_ASSIGN(PipeEventEmitter);
+ DISALLOW_COPY_AND_ASSIGN(EventEmitterPipe);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_PIPE_PIPE_EVENT_EMITTER_H_
+#endif // LIBRARIES_NACL_IO_EVENT_EMITTER_PIPE_H_
+
diff --git a/native_client_sdk/src/libraries/nacl_io/stream/stream_event_emitter.cc b/native_client_sdk/src/libraries/nacl_io/event_emitter_stream.cc
index a36f5d1..5c636ab 100644
--- a/native_client_sdk/src/libraries/nacl_io/stream/stream_event_emitter.cc
+++ b/native_client_sdk/src/libraries/nacl_io/event_emitter_stream.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/stream/stream_event_emitter.h"
+#include "nacl_io/event_emitter_stream.h"
#include <poll.h>
#include <stdint.h>
@@ -13,21 +13,21 @@
namespace nacl_io {
-StreamEventEmitter::StreamEventEmitter() : stream_(NULL) {}
+EventEmitterStream::EventEmitterStream() : stream_(NULL) {}
-void StreamEventEmitter::AttachStream(StreamNode* stream) {
+void EventEmitterStream::AttachStream(MountNodeStream* stream) {
AUTO_LOCK(GetLock());
stream_ = stream;
}
-void StreamEventEmitter::DetachStream() {
+void EventEmitterStream::DetachStream() {
AUTO_LOCK(GetLock());
RaiseEvents_Locked(POLLHUP);
stream_ = NULL;
}
-void StreamEventEmitter::UpdateStatus_Locked() {
+void EventEmitterStream::UpdateStatus_Locked() {
uint32_t status = 0;
if (!in_fifo()->IsEmpty())
status |= POLLIN;
@@ -39,11 +39,11 @@ void StreamEventEmitter::UpdateStatus_Locked() {
RaiseEvents_Locked(status);
}
-uint32_t StreamEventEmitter::BytesInOutputFIFO() {
+uint32_t EventEmitterStream::BytesInOutputFIFO() {
return out_fifo()->ReadAvailable();
}
-uint32_t StreamEventEmitter::SpaceInInputFIFO() {
+uint32_t EventEmitterStream::SpaceInInputFIFO() {
return in_fifo()->WriteAvailable();
}
diff --git a/native_client_sdk/src/libraries/nacl_io/stream/stream_event_emitter.h b/native_client_sdk/src/libraries/nacl_io/event_emitter_stream.h
index 9514ad6..1b40b01 100644
--- a/native_client_sdk/src/libraries/nacl_io/stream/stream_event_emitter.h
+++ b/native_client_sdk/src/libraries/nacl_io/event_emitter_stream.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_STREAM_STREAM_EVENT_EMITTER_H_
-#define LIBRARIES_NACL_IO_STREAM_STREAM_EVENT_EMITTER_H_
+#ifndef LIBRARIES_NACL_IO_EVENT_EMITTER_STREAM_H_
+#define LIBRARIES_NACL_IO_EVENT_EMITTER_STREAM_H_
#include "nacl_io/event_emitter.h"
@@ -12,20 +12,20 @@
namespace nacl_io {
+class EventEmitterStream;
class FIFOInterface;
-class StreamEventEmitter;
-class StreamNode;
+class MountNodeStream;
-typedef sdk_util::ScopedRef<StreamEventEmitter> ScopedStreamEventEmitter;
+typedef sdk_util::ScopedRef<EventEmitterStream> ScopedEventEmitterStream;
-class StreamEventEmitter : public EventEmitter {
+class EventEmitterStream : public EventEmitter {
public:
- StreamEventEmitter();
+ EventEmitterStream();
- void AttachStream(StreamNode* stream);
+ void AttachStream(MountNodeStream* stream);
void DetachStream();
- StreamNode* stream() { return stream_; }
+ MountNodeStream* stream() { return stream_; }
uint32_t BytesInOutputFIFO();
uint32_t SpaceInInputFIFO();
@@ -36,10 +36,11 @@ protected:
void UpdateStatus_Locked();
protected:
- StreamNode* stream_;
- DISALLOW_COPY_AND_ASSIGN(StreamEventEmitter);
+ MountNodeStream* stream_;
+ DISALLOW_COPY_AND_ASSIGN(EventEmitterStream);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_STREAM_STREAM_EVENT_EMITTER_H_
+#endif // LIBRARIES_NACL_IO_EVENT_EMITTER_STREAM_H_
+
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/tcp_event_emitter.cc b/native_client_sdk/src/libraries/nacl_io/event_emitter_tcp.cc
index 9f5778a..cce6359 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/tcp_event_emitter.cc
+++ b/native_client_sdk/src/libraries/nacl_io/event_emitter_tcp.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/socket/tcp_event_emitter.h"
+#include "nacl_io/event_emitter_tcp.h"
#include <poll.h>
#include <stdint.h>
@@ -13,20 +13,21 @@
namespace nacl_io {
-TcpEventEmitter::TcpEventEmitter(size_t rsize, size_t wsize)
+EventEmitterTCP::EventEmitterTCP(size_t rsize, size_t wsize)
: in_fifo_(rsize),
out_fifo_(wsize),
error_(false),
listening_(false),
- accepted_socket_(0) {}
+ accepted_socket_(0) {
+}
-uint32_t TcpEventEmitter::ReadIn_Locked(char* data, uint32_t len) {
+uint32_t EventEmitterTCP::ReadIn_Locked(char* data, uint32_t len) {
uint32_t count = in_fifo_.Read(data, len);
UpdateStatus_Locked();
return count;
}
-void TcpEventEmitter::UpdateStatus_Locked() {
+void EventEmitterTCP::UpdateStatus_Locked() {
if (error_) {
RaiseEvents_Locked(POLLIN | POLLOUT);
return;
@@ -38,53 +39,55 @@ void TcpEventEmitter::UpdateStatus_Locked() {
return;
}
- StreamEventEmitter::UpdateStatus_Locked();
+ EventEmitterStream::UpdateStatus_Locked();
}
-void TcpEventEmitter::SetListening_Locked() {
+void EventEmitterTCP::SetListening_Locked() {
listening_ = true;
UpdateStatus_Locked();
}
-uint32_t TcpEventEmitter::WriteIn_Locked(const char* data, uint32_t len) {
+uint32_t EventEmitterTCP::WriteIn_Locked(const char* data, uint32_t len) {
uint32_t count = in_fifo_.Write(data, len);
UpdateStatus_Locked();
return count;
}
-uint32_t TcpEventEmitter::ReadOut_Locked(char* data, uint32_t len) {
+uint32_t EventEmitterTCP::ReadOut_Locked(char* data, uint32_t len) {
uint32_t count = out_fifo_.Read(data, len);
UpdateStatus_Locked();
return count;
}
-uint32_t TcpEventEmitter::WriteOut_Locked(const char* data, uint32_t len) {
+uint32_t EventEmitterTCP::WriteOut_Locked(const char* data, uint32_t len) {
uint32_t count = out_fifo_.Write(data, len);
UpdateStatus_Locked();
return count;
}
-void TcpEventEmitter::ConnectDone_Locked() {
+void EventEmitterTCP::ConnectDone_Locked() {
RaiseEvents_Locked(POLLOUT);
UpdateStatus_Locked();
}
-bool TcpEventEmitter::GetError_Locked() { return error_; }
+bool EventEmitterTCP::GetError_Locked() {
+ return error_;
+}
-void TcpEventEmitter::SetError_Locked() {
+void EventEmitterTCP::SetError_Locked() {
error_ = true;
UpdateStatus_Locked();
}
-void TcpEventEmitter::SetAcceptedSocket_Locked(PP_Resource socket) {
+void EventEmitterTCP::SetAcceptedSocket_Locked(PP_Resource socket) {
accepted_socket_ = socket;
UpdateStatus_Locked();
}
-PP_Resource TcpEventEmitter::GetAcceptedSocket_Locked() {
+PP_Resource EventEmitterTCP::GetAcceptedSocket_Locked() {
int rtn = accepted_socket_;
accepted_socket_ = 0;
UpdateStatus_Locked();
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/tcp_event_emitter.h b/native_client_sdk/src/libraries/nacl_io/event_emitter_tcp.h
index 1e17a95..0d49f15 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/tcp_event_emitter.h
+++ b/native_client_sdk/src/libraries/nacl_io/event_emitter_tcp.h
@@ -2,27 +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_SOCKET_TCP_EVENT_EMITTER_H_
-#define LIBRARIES_NACL_IO_SOCKET_TCP_EVENT_EMITTER_H_
+#ifndef LIBRARIES_NACL_IO_EVENT_EMITTER_TCP_H_
+#define LIBRARIES_NACL_IO_EVENT_EMITTER_TCP_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 TcpEventEmitter;
-class Node;
+class EventEmitterTCP;
+class MountNode;
-typedef sdk_util::ScopedRef<TcpEventEmitter> ScopedTcpEventEmitter;
+typedef sdk_util::ScopedRef<EventEmitterTCP> ScopedEventEmitterTCP;
-class TcpEventEmitter : public StreamEventEmitter {
+class EventEmitterTCP : public EventEmitterStream {
public:
- TcpEventEmitter(size_t rsize, size_t wsize);
+ EventEmitterTCP(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);
@@ -48,9 +49,10 @@ class TcpEventEmitter : public StreamEventEmitter {
bool error_;
bool listening_;
PP_Resource accepted_socket_;
- DISALLOW_COPY_AND_ASSIGN(TcpEventEmitter);
+ DISALLOW_COPY_AND_ASSIGN(EventEmitterTCP);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_SOCKET_TCP_EVENT_EMITTER_H_
+#endif // LIBRARIES_NACL_IO_EVENT_EMITTER_TCP_H_
+
diff --git a/native_client_sdk/src/libraries/nacl_io/pipe/pipe_event_emitter.cc b/native_client_sdk/src/libraries/nacl_io/event_emitter_tty.cc
index 542068f..7df065a 100644
--- a/native_client_sdk/src/libraries/nacl_io/pipe/pipe_event_emitter.cc
+++ b/native_client_sdk/src/libraries/nacl_io/event_emitter_tty.cc
@@ -2,25 +2,27 @@
// 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_event_emitter.h"
+#include <poll.h>
+#include <stdint.h>
+#include <stdlib.h>
-#include <algorithm>
+#include "nacl_io/event_emitter_tty.h"
namespace nacl_io {
-PipeEventEmitter::PipeEventEmitter(size_t size)
+EventEmitterTTY::EventEmitterTTY(size_t size)
: fifo_(std::max<size_t>(1, size)) {
UpdateStatus_Locked();
}
-size_t PipeEventEmitter::Read_Locked(char* data, size_t len) {
+size_t EventEmitterPipe::Read_Locked(char* data, size_t len) {
size_t out_len = fifo_.Read(data, len);
UpdateStatus_Locked();
return out_len;
}
-size_t PipeEventEmitter::Write_Locked(const char* data, size_t len) {
+size_t EventEmitterPipe::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/devfs/tty_event_emitter.h b/native_client_sdk/src/libraries/nacl_io/event_emitter_tty.h
index c42f7c4..d3fbd89 100644
--- a/native_client_sdk/src/libraries/nacl_io/devfs/tty_event_emitter.h
+++ b/native_client_sdk/src/libraries/nacl_io/event_emitter_tty.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_DEVFS_TTY_EVENT_EMITTER_H_
-#define LIBRARIES_NACL_IO_DEVFS_TTY_EVENT_EMITTER_H_
+#ifndef LIBRARIES_NACL_IO_EVENT_EMITTER_TTY_H_
+#define LIBRARIES_NACL_IO_EVENT_EMITTER_TTY_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 TtyEventEmitter;
-typedef sdk_util::ScopedRef<TtyEventEmitter> ScopedTtyEventEmitter;
+class EventEmitterTTY;
+typedef sdk_util::ScopedRef<EventEmitterTTY> ScopedEventEmitterTTY;
-class TtyEventEmitter : public StreamEventEmitter {
+class EventEmitterTTY : public EventEmitterStream {
public:
- explicit TtyEventEmitter(size_t size);
+ explicit EventEmitterTTY(size_t size);
size_t Read_Locked(char* data, size_t len);
size_t Write_Locked(const char* data, size_t len);
@@ -35,9 +35,10 @@ class TtyEventEmitter : public StreamEventEmitter {
private:
FIFOChar fifo_;
FIFONull null_;
- DISALLOW_COPY_AND_ASSIGN(TtyEventEmitter);
+ DISALLOW_COPY_AND_ASSIGN(EventEmitterTTY);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_DEVFS_TTY_EVENT_EMITTER_H_
+#endif // LIBRARIES_NACL_IO_EVENT_EMITTER_PIPE_H_
+
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/udp_event_emitter.cc b/native_client_sdk/src/libraries/nacl_io/event_emitter_udp.cc
index 3c88d03..8b64526a 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/udp_event_emitter.cc
+++ b/native_client_sdk/src/libraries/nacl_io/event_emitter_udp.cc
@@ -2,39 +2,43 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/socket/udp_event_emitter.h"
+#include "nacl_io/event_emitter_udp.h"
+
+#include <poll.h>
+#include <stdint.h>
+#include <stdlib.h>
#include "sdk_util/auto_lock.h"
namespace nacl_io {
-UdpEventEmitter::UdpEventEmitter(size_t rsize, size_t wsize)
+EventEmitterUDP::EventEmitterUDP(size_t rsize, size_t wsize)
: in_fifo_(rsize),
out_fifo_(wsize) {
UpdateStatus_Locked();
}
-Packet* UdpEventEmitter::ReadRXPacket_Locked() {
+Packet* EventEmitterUDP::ReadRXPacket_Locked() {
Packet* packet = in_fifo_.ReadPacket();
UpdateStatus_Locked();
return packet;
}
-void UdpEventEmitter::WriteRXPacket_Locked(Packet* packet) {
+void EventEmitterUDP::WriteRXPacket_Locked(Packet* packet) {
in_fifo_.WritePacket(packet);
UpdateStatus_Locked();
}
-Packet* UdpEventEmitter::ReadTXPacket_Locked() {
+Packet* EventEmitterUDP::ReadTXPacket_Locked() {
Packet* packet = out_fifo_.ReadPacket();
UpdateStatus_Locked();
return packet;
}
-void UdpEventEmitter::WriteTXPacket_Locked(Packet* packet) {
+void EventEmitterUDP::WriteTXPacket_Locked(Packet* packet) {
out_fifo_.WritePacket(packet);
UpdateStatus_Locked();
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/udp_event_emitter.h b/native_client_sdk/src/libraries/nacl_io/event_emitter_udp.h
index 33013c5..cb64fbc 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/udp_event_emitter.h
+++ b/native_client_sdk/src/libraries/nacl_io/event_emitter_udp.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_SOCKET_UDP_EVENT_EMITTER_H_
-#define LIBRARIES_NACL_IO_SOCKET_UDP_EVENT_EMITTER_H_
+#ifndef LIBRARIES_NACL_IO_EVENT_EMITTER_UDP_H_
+#define LIBRARIES_NACL_IO_EVENT_EMITTER_UDP_H_
-#include "nacl_io/socket/fifo_packet.h"
-#include "nacl_io/stream/stream_event_emitter.h"
+#include "nacl_io/event_emitter_stream.h"
+#include "nacl_io/fifo_packet.h"
#include "sdk_util/macros.h"
#include "sdk_util/scoped_ref.h"
namespace nacl_io {
-class UdpEventEmitter;
-typedef sdk_util::ScopedRef<UdpEventEmitter> ScopedUdpEventEmitter;
+class EventEmitterUDP;
+typedef sdk_util::ScopedRef<EventEmitterUDP> ScopedEventEmitterUDP;
-class UdpEventEmitter : public StreamEventEmitter {
+class EventEmitterUDP : public EventEmitterStream {
public:
- UdpEventEmitter(size_t rsize, size_t wsize);
+ EventEmitterUDP(size_t rsize, size_t wsize);
// Takes or gives away ownership of the packet.
Packet* ReadRXPacket_Locked();
@@ -34,9 +34,10 @@ protected:
private:
FIFOPacket in_fifo_;
FIFOPacket out_fifo_;
- DISALLOW_COPY_AND_ASSIGN(UdpEventEmitter);
+ DISALLOW_COPY_AND_ASSIGN(EventEmitterUDP);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_SOCKET_UDP_EVENT_EMITTER_H_
+#endif // LIBRARIES_NACL_IO_EVENT_EMITTER_UDP_H_
+
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/fifo_packet.cc b/native_client_sdk/src/libraries/nacl_io/fifo_packet.cc
index c2b3540..94354af 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/fifo_packet.cc
+++ b/native_client_sdk/src/libraries/nacl_io/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/socket/fifo_packet.h"
+#include "nacl_io/fifo_packet.h"
#include <stdlib.h>
#include <string.h>
#include <algorithm>
-#include "nacl_io/socket/packet.h"
+#include "nacl_io/packet.h"
namespace nacl_io {
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/fifo_packet.h b/native_client_sdk/src/libraries/nacl_io/fifo_packet.h
index b9e5c44..b9e5c44 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/fifo_packet.h
+++ b/native_client_sdk/src/libraries/nacl_io/fifo_packet.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
deleted file mode 100644
index cc9bbaa..0000000
--- a/native_client_sdk/src/libraries/nacl_io/fs_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_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 feb90cd..b7f52d4 100644
--- a/native_client_sdk/src/libraries/nacl_io/fuse.h
+++ b/native_client_sdk/src/libraries/nacl_io/fuse.h
@@ -56,17 +56,16 @@ typedef int (*fuse_fill_dir_t)(void* buf,
const struct stat* stbuf,
off_t off);
-// This structure defines the interface to create a user filesystem. Pass this
-// to
-// nacl_io_register_fs_type(). (see nacl_io.h)
+// This structure defines the interface to create a user mount. Pass this to
+// nacl_io_register_mount_type(). (see nacl_io.h)
//
// Example:
//
// struct fuse_operations g_my_fuse_operations = { ... };
// ...
-// nacl_io_register_fs_type("myfusefs", &g_my_fuse_operations);
+// nacl_io_register_mount_type("myfusefs", &g_my_fuse_operations);
// ...
-// mount("", "/fs/fuse", "myfusefs", 0, NULL);
+// mount("", "/mnt/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
@@ -87,9 +86,9 @@ struct fuse_operations {
unsigned int flag_nopath : 1;
unsigned int flag_reserved : 31;
- // Called when a filesystem of this type is initialized.
+ // Called when a mount of this type is initialized.
void* (*init)(struct fuse_conn_info* conn);
- // Called when a filesystem of this type is unmounted.
+ // Called when a mount 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
new file mode 100644
index 0000000..c527883
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/fuse_mount_factory.cc
@@ -0,0 +1,28 @@
+// 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
new file mode 100644
index 0000000..24ab4e4
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/fuse_mount_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_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/fusefs/fuse_fs_factory.cc b/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs_factory.cc
deleted file mode 100644
index aaa9eea..0000000
--- a/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs_factory.cc
+++ /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.
-
-#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
deleted file mode 100644
index 47afd3d..0000000
--- a/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs_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_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/kernel_handle.cc b/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc
index 18b5c5a..5736a3a 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/filesystem.h"
-#include "nacl_io/node.h"
+#include "nacl_io/mount.h"
+#include "nacl_io/mount_node.h"
+#include "nacl_io/mount_node_socket.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()
- : filesystem_(NULL), node_(NULL) {}
+ : mount_(NULL), node_(NULL) {}
-KernelHandle::KernelHandle(const ScopedFilesystem& fs, const ScopedNode& node)
- : filesystem_(fs), node_(node) {}
+KernelHandle::KernelHandle(const ScopedMount& mnt, const ScopedMountNode& node)
+ : mount_(mnt), node_(node) {}
KernelHandle::~KernelHandle() {
- // Force release order for cases where filesystem_ is not ref'd by mounting.
+ // Force release order for cases where mount_ is not ref'd by mounting.
node_.reset(NULL);
- filesystem_.reset(NULL);
+ mount_.reset(NULL);
}
-// Returns the SocketNode* if this node is a socket.
-SocketNode* KernelHandle::socket_node() {
+// Returns the MountNodeSocket* if this node is a socket.
+MountNodeSocket* KernelHandle::socket_node() {
if (node_.get() && node_->IsaSock())
- return reinterpret_cast<SocketNode*>(node_.get());
+ return reinterpret_cast<MountNodeSocket*>(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) {
- SocketNode* sock = socket_node();
+ MountNodeSocket* 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) {
- SocketNode* sock = socket_node();
+ MountNodeSocket* 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) {
- SocketNode* sock = socket_node();
+ MountNodeSocket* 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) {
- SocketNode* sock = socket_node();
+ MountNodeSocket* 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) {
- SocketNode* sock = socket_node();
+ MountNodeSocket* 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) {
- SocketNode* sock = socket_node();
+ MountNodeSocket* 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 5d62117..d445f40 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/filesystem.h"
-#include "nacl_io/node.h"
+#include "nacl_io/mount.h"
+#include "nacl_io/mount_node.h"
#include "nacl_io/ossocket.h"
#include "nacl_io/ostypes.h"
@@ -22,9 +22,9 @@
namespace nacl_io {
-class SocketNode;
+class MountNodeSocket;
-// HandleAttr struct is passed the Node in calls
+// HandleAttr struct is passed the MountNode 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 filesystem, node, access type and offset.
+// file information, such as it's mount, 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 ScopedFilesystem& fs, const ScopedNode& node);
+ KernelHandle(const ScopedMount& mnt, const ScopedMountNode& 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 ScopedNode& node() { return node_; }
- const ScopedFilesystem& filesystem() { return filesystem_; }
+ const ScopedMountNode& node() { return node_; }
+ const ScopedMount& mount() { return mount_; }
const HandleAttr& Attr() { return handle_attr_; }
int OpenMode() { return handle_attr_.flags & 3; }
private:
- // Returns the SocketNode* if this node is a socket otherwise returns
+ // Returns the MountNodeSocket* if this node is a socket otherwise returns
// NULL.
- SocketNode* socket_node();
+ MountNodeSocket* socket_node();
- ScopedFilesystem filesystem_;
- ScopedNode node_;
+ ScopedMount mount_;
+ ScopedMountNode 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 71e8edf..b5f894c 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_fs_type(const char* fs_type,
+int ki_register_mount_type(const char* mount_type,
struct fuse_operations* fuse_ops) {
- return s_kp->RegisterFsType(fs_type, fuse_ops);
+ return s_kp->RegisterMountType(mount_type, fuse_ops);
}
-int ki_unregister_fs_type(const char* fs_type) {
- return s_kp->UnregisterFsType(fs_type);
+int ki_unregister_mount_type(const char* mount_type) {
+ return s_kp->UnregisterMountType(mount_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 3e3479a..b135213 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_fs_type(const char* fs_type,
+int ki_register_mount_type(const char* mount_type,
struct fuse_operations* fuse_ops);
-int ki_unregister_fs_type(const char* fs_type);
+int ki_unregister_mount_type(const char* mount_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 fccc5c85..566bf90 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/node.h"
+#include "nacl_io/mount.h"
+#include "nacl_io/mount_node.h"
#include "sdk_util/auto_lock.h"
#include "sdk_util/ref_object.h"
@@ -24,59 +24,61 @@
namespace nacl_io {
-KernelObject::KernelObject() { cwd_ = "/"; }
+KernelObject::KernelObject() {
+ cwd_ = "/";
+}
KernelObject::~KernelObject() {};
-Error KernelObject::AttachFsAtPath(const ScopedFilesystem& fs,
- const std::string& path) {
+Error KernelObject::AttachMountAtPath(const ScopedMount& mnt,
+ const std::string& path) {
std::string abs_path = GetAbsParts(path).Join();
- AUTO_LOCK(fs_lock_);
- if (filesystems_.find(abs_path) != filesystems_.end())
+ AUTO_LOCK(mount_lock_);
+ if (mounts_.find(abs_path) != mounts_.end())
return EBUSY;
- filesystems_[abs_path] = fs;
+ mounts_[abs_path] = mnt;
return 0;
}
-Error KernelObject::DetachFsAtPath(const std::string& path) {
+Error KernelObject::DetachMountAtPath(const std::string& path) {
std::string abs_path = GetAbsParts(path).Join();
- AUTO_LOCK(fs_lock_);
- FsMap_t::iterator it = filesystems_.find(abs_path);
- if (filesystems_.end() == it)
+ AUTO_LOCK(mount_lock_);
+ MountMap_t::iterator it = mounts_.find(abs_path);
+ if (mounts_.end() == it)
return EINVAL;
// It is only legal to unmount if there are no open references
if (it->second->RefCount() != 1)
return EBUSY;
- filesystems_.erase(it);
+ mounts_.erase(it);
return 0;
}
-// 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) {
+// 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) {
Path abs_parts = GetAbsParts(path);
- out_fs->reset(NULL);
+ out_mount->reset(NULL);
*rel_parts = Path();
- AUTO_LOCK(fs_lock_);
+ AUTO_LOCK(mount_lock_);
// Find longest prefix
size_t max = abs_parts.Size();
for (size_t len = 0; len < abs_parts.Size(); len++) {
- FsMap_t::iterator it = filesystems_.find(abs_parts.Range(0, max - len));
- if (it != filesystems_.end()) {
+ MountMap_t::iterator it = mounts_.find(abs_parts.Range(0, max - len));
+ if (it != mounts_.end()) {
rel_parts->Set("/");
rel_parts->Append(abs_parts.Range(max - len, max));
- *out_fs = it->second;
+ *out_mount = it->second;
return 0;
}
}
@@ -84,20 +86,20 @@ Error KernelObject::AcquireFsAndRelPath(const std::string& path,
return ENOTDIR;
}
-// Given a path, acquire the associated filesystem and node, creating the
+// Given a path, acquire the associated mount and node, creating the
// node if needed based on the provided flags.
-Error KernelObject::AcquireFsAndNode(const std::string& path,
- int oflags,
- ScopedFilesystem* out_fs,
- ScopedNode* out_node) {
+Error KernelObject::AcquireMountAndNode(const std::string& path,
+ int oflags,
+ ScopedMount* out_mount,
+ ScopedMountNode* out_node) {
Path rel_parts;
- out_fs->reset(NULL);
+ out_mount->reset(NULL);
out_node->reset(NULL);
- Error error = AcquireFsAndRelPath(path, out_fs, &rel_parts);
+ Error error = AcquireMountAndRelPath(path, out_mount, &rel_parts);
if (error)
return error;
- error = (*out_fs)->Open(rel_parts, oflags, out_node);
+ error = (*out_mount)->Open(rel_parts, oflags, out_node);
if (error)
return error;
@@ -128,10 +130,10 @@ std::string KernelObject::GetCWD() {
Error KernelObject::SetCWD(const std::string& path) {
std::string abs_path = GetAbsParts(path).Join();
- ScopedFilesystem fs;
- ScopedNode node;
+ ScopedMount mnt;
+ ScopedMountNode node;
- Error error = AcquireFsAndNode(abs_path, O_RDONLY, &fs, &node);
+ Error error = AcquireMountAndNode(abs_path, O_RDONLY, &mnt, &node);
if (error)
return error;
@@ -173,8 +175,7 @@ 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 1bf714a..df6dba2 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/node.h"
+#include "nacl_io/mount.h"
+#include "nacl_io/mount_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, ScopedFilesystem> FsMap_t;
+ typedef std::map<std::string, ScopedMount> MountMap_t;
KernelObject();
virtual ~KernelObject();
- // Attach the given Filesystem object at the specified path.
- Error AttachFsAtPath(const ScopedFilesystem& fs, const std::string& path);
+ // Attach the given Mount object at the specified path.
+ Error AttachMountAtPath(const ScopedMount& mnt, const std::string& path);
- // Unmap the Filesystem object from the specified path and release it.
- Error DetachFsAtPath(const std::string& path);
+ // Unmap the Mount object from the specified path and release it.
+ Error DetachMountAtPath(const std::string& path);
- // 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,
+ // 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,
Path* rel_path);
- // Find the filesystem and node for the given path, acquiring/creating it as
+ // Find the mount and node for the given path, acquiring/creating it as
// specified by the |oflags|.
- // Assumes |out_fs| and |out_node| are non-NULL.
- Error AcquireFsAndNode(const std::string& path,
+ // Assumes |out_mount| and |out_node| are non-NULL.
+ Error AcquireMountAndNode(const std::string& path,
int oflags,
- ScopedFilesystem* out_fs,
- ScopedNode* out_node);
+ ScopedMount* out_mount,
+ ScopedMountNode* 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 filesystem.
+ // ref counting the handle and associated mount.
// 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_;
- FsMap_t filesystems_;
+ MountMap_t mounts_;
// Lock to protect free_fds_ and handle_map_.
sdk_util::SimpleLock handle_lock_;
- // Lock to protect filesystems_.
- sdk_util::SimpleLock fs_lock_;
+ // Lock to protect handle_map_.
+ sdk_util::SimpleLock mount_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 0ca2c39..b18f2ad 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/devfs/dev_fs.h"
-#include "nacl_io/filesystem.h"
-#include "nacl_io/fusefs/fuse_fs_factory.h"
+#include "nacl_io/fuse_mount_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/memfs/mem_fs.h"
-#include "nacl_io/node.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/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/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 "nacl_io/typed_mount_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 (FsFactoryMap_t::iterator i = factories_.begin();
+ for (MountFactoryMap_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 TypedFsFactory<MemFs>;
- factories_["dev"] = new TypedFsFactory<DevFs>;
- factories_["html5fs"] = new TypedFsFactory<Html5Fs>;
- factories_["httpfs"] = new TypedFsFactory<HttpFs>;
- factories_["passthroughfs"] = new TypedFsFactory<PassthroughFs>;
+ 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>;
int result;
result = mount("", "/", "passthroughfs", 0, NULL);
@@ -112,10 +112,10 @@ Error KernelProxy::Init(PepperInterface* ppapi) {
host_resolver_.Init(ppapi_);
#endif
- FsInitArgs args;
+ MountInitArgs args;
args.dev = dev_++;
args.ppapi = ppapi_;
- stream_mount_.reset(new StreamFs());
+ stream_mount_.reset(new MountStream());
result = stream_mount_->Init(args);
if (result != 0) {
assert(false);
@@ -125,18 +125,18 @@ Error KernelProxy::Init(PepperInterface* ppapi) {
return rtn;
}
-bool KernelProxy::RegisterFsType(const char* fs_type,
+bool KernelProxy::RegisterMountType(const char* mount_type,
fuse_operations* fuse_ops) {
- FsFactoryMap_t::iterator iter = factories_.find(fs_type);
+ MountFactoryMap_t::iterator iter = factories_.find(mount_type);
if (iter != factories_.end())
return false;
- factories_[fs_type] = new FuseFsFactory(fuse_ops);
+ factories_[mount_type] = new FuseMountFactory(fuse_ops);
return true;
}
-bool KernelProxy::UnregisterFsType(const char* fs_type) {
- FsFactoryMap_t::iterator iter = factories_.find(fs_type);
+bool KernelProxy::UnregisterMountType(const char* mount_type) {
+ MountFactoryMap_t::iterator iter = factories_.find(mount_type);
if (iter == factories_.end())
return false;
@@ -146,27 +146,27 @@ bool KernelProxy::UnregisterFsType(const char* fs_type) {
}
int KernelProxy::open_resource(const char* path) {
- ScopedFilesystem fs;
+ ScopedMount mnt;
Path rel;
- Error error = AcquireFsAndRelPath(path, &fs, &rel);
+ Error error = AcquireMountAndRelPath(path, &mnt, &rel);
if (error) {
errno = error;
return -1;
}
- ScopedNode node;
- error = fs->OpenResource(rel, &node);
+ ScopedMountNode node;
+ error = mnt->OpenResource(rel, &node);
if (error) {
// OpenResource failed, try Open().
- error = fs->Open(rel, O_RDONLY, &node);
+ error = mnt->Open(rel, O_RDONLY, &node);
if (error) {
errno = error;
return -1;
}
}
- ScopedKernelHandle handle(new KernelHandle(fs, node));
+ ScopedKernelHandle handle(new KernelHandle(mnt, 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) {
- ScopedFilesystem fs;
- ScopedNode node;
+ ScopedMount mnt;
+ ScopedMountNode node;
- Error error = AcquireFsAndNode(path, open_flags, &fs, &node);
+ Error error = AcquireMountAndNode(path, open_flags, &mnt, &node);
if (error) {
errno = error;
return -1;
}
- ScopedKernelHandle handle(new KernelHandle(fs, node));
+ ScopedKernelHandle handle(new KernelHandle(mnt, 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]) {
- PipeNode* pipe = new PipeNode(stream_mount_.get());
- ScopedNode node(pipe);
+ MountNodePipe* pipe = new MountNodePipe(stream_mount_.get());
+ ScopedMountNode 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) {
- ScopedFilesystem fs;
+ ScopedMount mnt;
Path rel;
- Error error = AcquireFsAndRelPath(path, &fs, &rel);
+ Error error = AcquireMountAndRelPath(path, &mnt, &rel);
if (error) {
errno = error;
return -1;
}
- error = fs->Mkdir(rel, mode);
+ error = mnt->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) {
- ScopedFilesystem fs;
+ ScopedMount mnt;
Path rel;
- Error error = AcquireFsAndRelPath(path, &fs, &rel);
+ Error error = AcquireMountAndRelPath(path, &mnt, &rel);
if (error) {
errno = error;
return -1;
}
- error = fs->Rmdir(rel);
+ error = mnt->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
- FsFactoryMap_t::iterator factory = factories_.find(filesystemtype);
+ MountFactoryMap_t::iterator factory = factories_.find(filesystemtype);
if (factory == factories_.end()) {
errno = ENODEV;
return -1;
@@ -415,19 +415,19 @@ int KernelProxy::mount(const char* source,
}
}
- FsInitArgs args;
+ MountInitArgs args;
args.dev = dev_++;
args.string_map = smap;
args.ppapi = ppapi_;
- ScopedFilesystem fs;
- Error error = factory->second->CreateFilesystem(args, &fs);
+ ScopedMount mnt;
+ Error error = factory->second->CreateMount(args, &mnt);
if (error) {
errno = error;
return -1;
}
- error = AttachFsAtPath(fs, abs_path);
+ error = AttachMountAtPath(mnt, 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 = DetachFsAtPath(path);
+ Error error = DetachMountAtPath(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) {
- ScopedFilesystem fs;
+ ScopedMount mnt;
Path rel;
- Error error = AcquireFsAndRelPath(path, &fs, &rel);
+ Error error = AcquireMountAndRelPath(path, &mnt, &rel);
if (error) {
errno = error;
return -1;
}
- error = fs->Unlink(rel);
+ error = mnt->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) {
- ScopedFilesystem fs;
+ ScopedMount mnt;
Path rel;
- Error error = AcquireFsAndRelPath(path, &fs, &rel);
+ Error error = AcquireMountAndRelPath(path, &mnt, &rel);
if (error) {
errno = error;
return -1;
}
- ScopedFilesystem newfs;
+ ScopedMount newmnt;
Path newrel;
- error = AcquireFsAndRelPath(newpath, &newfs, &newrel);
+ error = AcquireMountAndRelPath(newpath, &newmnt, &newrel);
if (error) {
errno = error;
return -1;
}
- if (newfs.get() != fs.get()) {
+ if (newmnt.get() != mnt.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 = fs->Rename(rel, newrel);
+ error = mnt->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) {
- ScopedFilesystem fs;
+ ScopedMount mnt;
Path rel;
- Error error = AcquireFsAndRelPath(path, &fs, &rel);
+ Error error = AcquireMountAndRelPath(path, &mnt, &rel);
if (error) {
errno = error;
return -1;
}
- error = fs->Remove(rel);
+ error = mnt->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) {
- ScopedFilesystem fs;
+ ScopedMount mnt;
Path rel;
- Error error = AcquireFsAndRelPath(path, &fs, &rel);
+ Error error = AcquireMountAndRelPath(path, &mnt, &rel);
if (error) {
errno = error;
return -1;
}
- error = fs->Access(rel, amode);
+ error = mnt->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;
}
- SocketNode* sock = new TcpNode(stream_mount_.get(), new_sock);
+ MountNodeSocket* sock = new MountNodeTCP(stream_mount_.get(), new_sock);
- // The SocketNode now holds a reference to the new socket
+ // The MountNodeSocket 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;
}
- ScopedNode node(sock);
+ ScopedMountNode 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;
}
- SocketNode* sock = NULL;
+ MountNodeSocket* sock = NULL;
switch (type) {
case SOCK_DGRAM:
- sock = new UdpNode(stream_mount_.get());
+ sock = new MountNodeUDP(stream_mount_.get());
break;
case SOCK_STREAM:
- sock = new TcpNode(stream_mount_.get());
+ sock = new MountNodeTCP(stream_mount_.get());
break;
case SOCK_SEQPACKET:
@@ -1550,7 +1550,7 @@ int KernelProxy::socket(int domain, int type, int protocol) {
return -1;
}
- ScopedNode node(sock);
+ ScopedMountNode 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 a0232753..e037110 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 Filesystem and Node objects.
+// proxy will result in IO access to the provided Mount and MountNode 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 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.
+// 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.
//
// 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, FsFactory*> FsFactoryMap_t;
+ typedef std::map<std::string, MountFactory*> MountFactoryMap_t;
KernelProxy();
virtual ~KernelProxy();
// Takes ownership of |ppapi|.
- // |ppapi| may be NULL. If so, no filesystem that uses pepper calls can be
- // mounted.
+ // |ppapi| may be NULL. If so, no mount that uses pepper calls can be mounted.
virtual Error Init(PepperInterface* ppapi);
- // 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);
+ // 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);
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 filesystem-specific)
+ // Path related System calls handled by KernelProxy (not mount-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 filesystem'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 mount'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 filesystem the file
+ // The kernel proxy will determine to which mount the file
// descriptor's corresponding file handle belongs. The
- // associated filesystem's function will be called.
+ // associated mount'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 filesystem's Stat() to determine whether or not the
+ // lseek() relies on the mount'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 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.
+ // 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.
virtual int remove(const char* path);
- // unlink() is a simple wrapper around the filesystem's Unlink function.
+ // unlink() is a simple wrapper around the mount'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 Filesystem's Stat().
+ // access() uses the Mount'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:
- FsFactoryMap_t factories_;
- sdk_util::ScopedRef<StreamFs> stream_mount_;
+ MountFactoryMap_t factories_;
+ sdk_util::ScopedRef<MountStream> 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 e76ecd8..abddc64 100644
--- a/native_client_sdk/src/libraries/nacl_io/library.dsc
+++ b/native_client_sdk/src/libraries/nacl_io/library.dsc
@@ -12,23 +12,18 @@
'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",
- "filesystem.cc",
- "fusefs/fuse_fs.cc",
- "fusefs/fuse_fs_factory.cc",
+ "fifo_packet.cc",
+ "fuse_mount_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",
@@ -38,27 +33,31 @@
"kernel_wrap_glibc.cc",
"kernel_wrap_newlib.cc",
"kernel_wrap_win.cc",
- "memfs/mem_fs.cc",
- "memfs/mem_fs_node.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",
"nacl_io.cc",
- "node.cc",
- "passthroughfs/passthrough_fs.cc",
+ "packet.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",
@@ -153,29 +152,22 @@
'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",
- "filesystem.h",
- "fs_factory.h",
- "fusefs/fuse_fs_factory.h",
- "fusefs/fuse_fs.h",
+ "fifo_packet.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",
@@ -184,40 +176,46 @@
"kernel_proxy.h",
"kernel_wrap.h",
"kernel_wrap_real.h",
- "memfs/mem_fs.h",
- "memfs/mem_fs_node.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",
"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",
- "passthroughfs/passthrough_fs.h",
+ "ostermios.h",
+ "packet.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",
- "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",
+ "typed_mount_factory.h",
],
'DEST': 'include/nacl_io',
},
diff --git a/native_client_sdk/src/libraries/nacl_io/filesystem.cc b/native_client_sdk/src/libraries/nacl_io/mount.cc
index f7a5c8c..3c0d7a2 100644
--- a/native_client_sdk/src/libraries/nacl_io/filesystem.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount.cc
@@ -2,14 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/filesystem.h"
+#include "nacl_io/mount.h"
#include <errno.h>
#include <fcntl.h>
#include <string>
-#include "nacl_io/dir_node.h"
-#include "nacl_io/node.h"
+#include "nacl_io/mount_node.h"
+#include "nacl_io/mount_node_dir.h"
+#include "nacl_io/mount_node_mem.h"
#include "nacl_io/osstat.h"
#include "nacl_io/path.h"
#include "sdk_util/auto_lock.h"
@@ -21,31 +22,32 @@
namespace nacl_io {
-Filesystem::Filesystem() : dev_(0) {}
+Mount::Mount() : dev_(0) {}
-Filesystem::~Filesystem() {}
+Mount::~Mount() {}
-Error Filesystem::Init(const FsInitArgs& args) {
+Error Mount::Init(const MountInitArgs& args) {
dev_ = args.dev;
ppapi_ = args.ppapi;
return 0;
}
-void Filesystem::Destroy() {}
+void Mount::Destroy() {}
-Error Filesystem::OpenResource(const Path& path, ScopedNode* out_node) {
+Error Mount::OpenResource(const Path& path, ScopedMountNode* out_node) {
out_node->reset(NULL);
return EINVAL;
}
-void Filesystem::OnNodeCreated(Node* node) {
+void Mount::OnNodeCreated(MountNode* node) {
node->stat_.st_ino = inode_pool_.Acquire();
node->stat_.st_dev = dev_;
}
-void Filesystem::OnNodeDestroyed(Node* node) {
+void Mount::OnNodeDestroyed(MountNode* 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/filesystem.h b/native_client_sdk/src/libraries/nacl_io/mount.h
index 6be2c73..a99c1fa 100644
--- a/native_client_sdk/src/libraries/nacl_io/filesystem.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount.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_FILESYSTEM_H_
-#define LIBRARIES_NACL_IO_FILESYSTEM_H_
+#ifndef LIBRARIES_NACL_IO_MOUNT_H_
+#define LIBRARIES_NACL_IO_MOUNT_H_
#include <map>
#include <string>
#include "nacl_io/error.h"
#include "nacl_io/inode_pool.h"
-#include "nacl_io/node.h"
+#include "nacl_io/mount_node.h"
#include "nacl_io/path.h"
#include "sdk_util/macros.h"
@@ -21,19 +21,19 @@ struct fuse_operations;
namespace nacl_io {
-class Filesystem;
-class Node;
+class Mount;
+class MountNode;
class PepperInterface;
-typedef sdk_util::ScopedRef<Filesystem> ScopedFilesystem;
+typedef sdk_util::ScopedRef<Mount> ScopedMount;
typedef std::map<std::string, std::string> StringMap_t;
-// 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) {}
+// 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) {}
// Device number of the new filesystem.
int dev;
@@ -44,16 +44,16 @@ struct FsInitArgs {
// 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 Filesystem : public sdk_util::RefObject {
+class Mount : public sdk_util::RefObject {
protected:
// The protected functions are only used internally and will not
- // acquire or release the filesystem's lock.
- Filesystem();
- virtual ~Filesystem();
+ // acquire or release the mount's lock.
+ Mount();
+ virtual ~Mount();
- // 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);
+ // 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);
virtual void Destroy();
public:
@@ -66,16 +66,16 @@ class Filesystem : 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
- // Node is created with a ref count of 1.
+ // MountNode is created with a ref count of 1.
// Assumes that |out_node| is non-NULL.
virtual Error Open(const Path& path,
int open_flags,
- ScopedNode* out_node) = 0;
+ ScopedMountNode* out_node) = 0;
- // OpenResource is only used to read files from the NaCl NMF file. No
- // filesystem except PassthroughFs should implement it.
+ // OpenResource is only used to read files from the NaCl NMF file. No mount
+ // except MountPassthrough should implement it.
// Assumes that |out_node| is non-NULL.
- virtual Error OpenResource(const Path& path, ScopedNode* out_node);
+ virtual Error OpenResource(const Path& path, ScopedMountNode* out_node);
// Unlink, Mkdir, Rmdir will affect the both the RefCount
// and the nlink number in the stat object.
@@ -86,13 +86,13 @@ class Filesystem : public sdk_util::RefObject {
virtual Error Rename(const Path& path, const Path& newpath) = 0;
// Assumes that |node| is non-NULL.
- void OnNodeCreated(Node* node);
+ void OnNodeCreated(MountNode* node);
// Assumes that |node| is non-NULL.
- void OnNodeDestroyed(Node* node);
+ void OnNodeDestroyed(MountNode* node);
protected:
- // Device number for the filesystem.
+ // Device number for the mount.
int dev_;
PepperInterface* ppapi_; // Weak reference.
INodePool inode_pool_;
@@ -102,9 +102,9 @@ class Filesystem : public sdk_util::RefObject {
// lock is held, so we make it private.
friend class KernelObject;
friend class KernelProxy;
- DISALLOW_COPY_AND_ASSIGN(Filesystem);
+ DISALLOW_COPY_AND_ASSIGN(Mount);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_FILESYSTEM_H_
+#endif // LIBRARIES_NACL_IO_MOUNT_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/devfs/dev_fs.cc b/native_client_sdk/src/libraries/nacl_io/mount_dev.cc
index 8bde062..38eb86b 100644
--- a/native_client_sdk/src/libraries/nacl_io/devfs/dev_fs.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_dev.cc
@@ -6,17 +6,16 @@
#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/node.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/osunistd.h"
#include "nacl_io/pepper_interface.h"
#include "sdk_util/auto_lock.h"
@@ -31,9 +30,9 @@ namespace nacl_io {
namespace {
-class RealNode : public Node {
+class RealNode : public MountNode {
public:
- RealNode(Filesystem* filesystem, int fd);
+ RealNode(Mount* mount, int fd);
virtual Error Read(const HandleAttr& attr,
void* buf,
@@ -49,9 +48,9 @@ class RealNode : public Node {
int fd_;
};
-class NullNode : public CharNode {
+class NullNode : public MountNodeCharDevice {
public:
- explicit NullNode(Filesystem* filesystem) : CharNode(filesystem) {}
+ explicit NullNode(Mount* mount) : MountNodeCharDevice(mount) {}
virtual Error Read(const HandleAttr& attr,
void* buf,
@@ -63,9 +62,9 @@ class NullNode : public CharNode {
int* out_bytes);
};
-class ConsoleNode : public CharNode {
+class ConsoleNode : public MountNodeCharDevice {
public:
- ConsoleNode(Filesystem* filesystem, PP_LogLevel level);
+ ConsoleNode(Mount* mount, PP_LogLevel level);
virtual Error Write(const HandleAttr& attr,
const void* buf,
@@ -76,9 +75,9 @@ class ConsoleNode : public CharNode {
PP_LogLevel level_;
};
-class ZeroNode : public Node {
+class ZeroNode : public MountNode {
public:
- explicit ZeroNode(Filesystem* filesystem);
+ explicit ZeroNode(Mount* mount);
virtual Error Read(const HandleAttr& attr,
void* buf,
@@ -90,9 +89,9 @@ class ZeroNode : public Node {
int* out_bytes);
};
-class UrandomNode : public Node {
+class UrandomNode : public MountNode {
public:
- explicit UrandomNode(Filesystem* filesystem);
+ explicit UrandomNode(Mount* mount);
virtual Error Read(const HandleAttr& attr,
void* buf,
@@ -110,7 +109,7 @@ class UrandomNode : public Node {
#endif
};
-RealNode::RealNode(Filesystem* filesystem, int fd) : Node(filesystem), fd_(fd) {
+RealNode::RealNode(Mount* mount, int fd) : MountNode(mount), fd_(fd) {
SetType(S_IFCHR);
}
@@ -162,8 +161,9 @@ Error NullNode::Write(const HandleAttr& attr,
return 0;
}
-ConsoleNode::ConsoleNode(Filesystem* filesystem, PP_LogLevel level)
- : CharNode(filesystem), level_(level) {}
+ConsoleNode::ConsoleNode(Mount* mount, PP_LogLevel level)
+ : MountNodeCharDevice(mount), 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 = filesystem_->ppapi()->GetConsoleInterface();
- VarInterface* var_intr = filesystem_->ppapi()->GetVarInterface();
+ ConsoleInterface* con_intr = mount_->ppapi()->GetConsoleInterface();
+ VarInterface* var_intr = mount_->ppapi()->GetVarInterface();
if (!(var_intr && con_intr))
return ENOSYS;
@@ -180,15 +180,13 @@ 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(filesystem_->ppapi()->GetInstance(), level_, val);
+ con_intr->Log(mount_->ppapi()->GetInstance(), level_, val);
*out_bytes = count;
return 0;
}
-ZeroNode::ZeroNode(Filesystem* filesystem) : Node(filesystem) {
- SetType(S_IFCHR);
-}
+ZeroNode::ZeroNode(Mount* mount) : MountNode(mount) { SetType(S_IFCHR); }
Error ZeroNode::Read(const HandleAttr& attr,
void* buf,
@@ -207,7 +205,7 @@ Error ZeroNode::Write(const HandleAttr& attr,
return 0;
}
-UrandomNode::UrandomNode(Filesystem* filesystem) : Node(filesystem) {
+UrandomNode::UrandomNode(Mount* mount) : MountNode(mount) {
SetType(S_IFCHR);
#if defined(__native_client__)
size_t result = nacl_interface_query(
@@ -262,8 +260,8 @@ Error UrandomNode::Write(const HandleAttr& attr,
} // namespace
-Error DevFs::Access(const Path& path, int a_mode) {
- ScopedNode node;
+Error MountDev::Access(const Path& path, int a_mode) {
+ ScopedMountNode node;
int error = root_->FindChild(path.Join(), &node);
if (error)
return error;
@@ -275,7 +273,9 @@ Error DevFs::Access(const Path& path, int a_mode) {
return 0;
}
-Error DevFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
+Error MountDev::Open(const Path& path,
+ int open_flags,
+ ScopedMountNode* out_node) {
out_node->reset(NULL);
// Don't allow creating any files.
@@ -285,34 +285,34 @@ Error DevFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
return root_->FindChild(path.Join(), out_node);
}
-Error DevFs::Unlink(const Path& path) { return EPERM; }
+Error MountDev::Unlink(const Path& path) { return EPERM; }
-Error DevFs::Mkdir(const Path& path, int permissions) { return EPERM; }
+Error MountDev::Mkdir(const Path& path, int permissions) { return EPERM; }
-Error DevFs::Rmdir(const Path& path) { return EPERM; }
+Error MountDev::Rmdir(const Path& path) { return EPERM; }
-Error DevFs::Remove(const Path& path) { return EPERM; }
+Error MountDev::Remove(const Path& path) { return EPERM; }
-Error DevFs::Rename(const Path& path, const Path& newpath) { return EPERM; }
+Error MountDev::Rename(const Path& path, const Path& newpath) { return EPERM; }
-DevFs::DevFs() {}
+MountDev::MountDev() {}
-#define INITIALIZE_DEV_NODE(path, klass) \
- error = root_->AddChild(path, ScopedNode(new klass(this))); \
- if (error) \
+#define INITIALIZE_DEV_NODE(path, klass) \
+ error = root_->AddChild(path, ScopedMountNode(new klass(this))); \
+ if (error) \
return error;
-#define INITIALIZE_DEV_NODE_1(path, klass, arg) \
- error = root_->AddChild(path, ScopedNode(new klass(this, arg))); \
- if (error) \
+#define INITIALIZE_DEV_NODE_1(path, klass, arg) \
+ error = root_->AddChild(path, ScopedMountNode(new klass(this, arg))); \
+ if (error) \
return error;
-Error DevFs::Init(const FsInitArgs& args) {
- Error error = Filesystem::Init(args);
+Error MountDev::Init(const MountInitArgs& args) {
+ Error error = Mount::Init(args);
if (error)
return error;
- root_.reset(new DirNode(this));
+ root_.reset(new MountNodeDir(this));
INITIALIZE_DEV_NODE("/null", NullNode);
INITIALIZE_DEV_NODE("/zero", ZeroNode);
@@ -321,7 +321,7 @@ Error DevFs::Init(const FsInitArgs& 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", TtyNode);
+ INITIALIZE_DEV_NODE("/tty", MountNodeTty);
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/devfs/dev_fs.h b/native_client_sdk/src/libraries/nacl_io/mount_dev.h
index c446109..110c8fd 100644
--- a/native_client_sdk/src/libraries/nacl_io/devfs/dev_fs.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount_dev.h
@@ -2,20 +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_DEVFS_DEV_FS_H_
-#define LIBRARIES_NACL_IO_DEVFS_DEV_FS_H_
+#ifndef LIBRARIES_NACL_IO_MOUNT_DEV_H_
+#define LIBRARIES_NACL_IO_MOUNT_DEV_H_
-#include "nacl_io/filesystem.h"
-#include "nacl_io/typed_fs_factory.h"
+#include "nacl_io/mount.h"
+#include "nacl_io/typed_mount_factory.h"
namespace nacl_io {
-class Node;
+class MountNode;
-class DevFs : public Filesystem {
+class MountDev : public Mount {
public:
virtual Error Access(const Path& path, int a_mode);
- virtual Error Open(const Path& path, int open_flags, ScopedNode* out_node);
+ virtual Error Open(const Path& path,
+ int open_flags,
+ ScopedMountNode* out_node);
virtual Error Unlink(const Path& path);
virtual Error Mkdir(const Path& path, int permissions);
virtual Error Rmdir(const Path& path);
@@ -23,17 +25,17 @@ class DevFs : public Filesystem {
virtual Error Rename(const Path& path, const Path& newpath);
protected:
- DevFs();
+ MountDev();
- virtual Error Init(const FsInitArgs& args);
+ virtual Error Init(const MountInitArgs& args);
private:
- ScopedNode root_;
+ ScopedMountNode root_;
- friend class TypedFsFactory<DevFs>;
- DISALLOW_COPY_AND_ASSIGN(DevFs);
+ friend class TypedMountFactory<MountDev>;
+ DISALLOW_COPY_AND_ASSIGN(MountDev);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_DEVFS_DEV_FS_H_
+#endif // LIBRARIES_NACL_IO_MOUNT_DEV_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
new file mode 100644
index 0000000..48842ba
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/mount_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_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/fusefs/fuse_fs.cc b/native_client_sdk/src/libraries/nacl_io/mount_fuse.cc
index d84895d..8bf7664 100644
--- a/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_fuse.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// 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.
-#include "nacl_io/fusefs/fuse_fs.h"
+#include "nacl_io/mount_fuse.h"
#include <errno.h>
#include <fcntl.h>
@@ -14,6 +14,7 @@
#include "nacl_io/kernel_handle.h"
#include "sdk_util/macros.h"
+
namespace nacl_io {
namespace {
@@ -29,10 +30,10 @@ struct FillDirInfo {
} // namespace
-FuseFs::FuseFs() : fuse_ops_(NULL), fuse_user_data_(NULL) {}
+MountFuse::MountFuse() : fuse_ops_(NULL), fuse_user_data_(NULL) {}
-Error FuseFs::Init(const FsInitArgs& args) {
- Error error = Filesystem::Init(args);
+Error MountFuse::Init(const MountInitArgs& args) {
+ Error error = Mount::Init(args);
if (error)
return error;
@@ -48,12 +49,12 @@ Error FuseFs::Init(const FsInitArgs& args) {
return 0;
}
-void FuseFs::Destroy() {
+void MountFuse::Destroy() {
if (fuse_ops_ && fuse_ops_->destroy)
fuse_ops_->destroy(fuse_user_data_);
}
-Error FuseFs::Access(const Path& path, int a_mode) {
+Error MountFuse::Access(const Path& path, int a_mode) {
if (!fuse_ops_->access)
return ENOSYS;
@@ -64,7 +65,9 @@ Error FuseFs::Access(const Path& path, int a_mode) {
return 0;
}
-Error FuseFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
+Error MountFuse::Open(const Path& path,
+ int open_flags,
+ ScopedMountNode* out_node) {
std::string path_str = path.Join();
const char* path_cstr = path_str.c_str();
int result = 0;
@@ -99,7 +102,8 @@ Error FuseFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
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.
- ScopedNode node(new DirFuseFsNode(this, fuse_ops_, fi, path_cstr));
+ ScopedMountNode node(
+ new MountNodeFuseDir(this, fuse_ops_, fi, path_cstr));
Error error = node->Init(open_flags);
if (error)
return error;
@@ -121,13 +125,13 @@ Error FuseFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
}
if (!fuse_ops_->open)
- return ENOSYS;
+ return ENOSYS;
result = fuse_ops_->open(path_cstr, &fi);
if (result < 0)
return -result;
}
- ScopedNode node(new FileFuseFsNode(this, fuse_ops_, fi, path_cstr));
+ ScopedMountNode node(new MountNodeFuseFile(this, fuse_ops_, fi, path_cstr));
Error error = node->Init(open_flags);
if (error)
return error;
@@ -136,7 +140,7 @@ Error FuseFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
return 0;
}
-Error FuseFs::Unlink(const Path& path) {
+Error MountFuse::Unlink(const Path& path) {
if (!fuse_ops_->unlink)
return ENOSYS;
@@ -147,7 +151,7 @@ Error FuseFs::Unlink(const Path& path) {
return 0;
}
-Error FuseFs::Mkdir(const Path& path, int perm) {
+Error MountFuse::Mkdir(const Path& path, int perm) {
if (!fuse_ops_->mkdir)
return ENOSYS;
@@ -158,7 +162,7 @@ Error FuseFs::Mkdir(const Path& path, int perm) {
return 0;
}
-Error FuseFs::Rmdir(const Path& path) {
+Error MountFuse::Rmdir(const Path& path) {
if (!fuse_ops_->rmdir)
return ENOSYS;
@@ -169,8 +173,8 @@ Error FuseFs::Rmdir(const Path& path) {
return 0;
}
-Error FuseFs::Remove(const Path& path) {
- ScopedNode node;
+Error MountFuse::Remove(const Path& path) {
+ ScopedMountNode node;
Error error = Open(path, O_RDONLY, &node);
if (error)
return error;
@@ -189,7 +193,7 @@ Error FuseFs::Remove(const Path& path) {
}
}
-Error FuseFs::Rename(const Path& path, const Path& newpath) {
+Error MountFuse::Rename(const Path& path, const Path& newpath) {
if (!fuse_ops_->rename)
return ENOSYS;
@@ -200,24 +204,27 @@ Error FuseFs::Rename(const Path& path, const Path& newpath) {
return 0;
}
-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) {}
+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) {}
-bool FuseFsNode::CanOpen(int open_flags) {
+bool MountNodeFuse::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 Node::CanOpen,
+ // GetStat cached the mode in stat_.st_mode. Forward to MountNode::CanOpen,
// which will check this mode against open_flags.
- return Node::CanOpen(open_flags);
+ return MountNode::CanOpen(open_flags);
}
-Error FuseFsNode::GetStat(struct stat* stat) {
+Error MountNodeFuse::GetStat(struct stat* stat) {
int result;
if (fuse_ops_->fgetattr) {
result = fuse_ops_->fgetattr(path_.c_str(), stat, &info_);
@@ -236,28 +243,28 @@ Error FuseFsNode::GetStat(struct stat* stat) {
return 0;
}
-Error FuseFsNode::VIoctl(int request, va_list args) {
+Error MountNodeFuse::VIoctl(int request, va_list args) {
// TODO(binji): implement
return ENOSYS;
}
-Error FuseFsNode::Tcflush(int queue_selector) {
+Error MountNodeFuse::Tcflush(int queue_selector) {
// TODO(binji): use ioctl for this?
return ENOSYS;
}
-Error FuseFsNode::Tcgetattr(struct termios* termios_p) {
+Error MountNodeFuse::Tcgetattr(struct termios* termios_p) {
// TODO(binji): use ioctl for this?
return ENOSYS;
}
-Error FuseFsNode::Tcsetattr(int optional_actions,
- const struct termios* termios_p) {
+Error MountNodeFuse::Tcsetattr(int optional_actions,
+ const struct termios* termios_p) {
// TODO(binji): use ioctl for this?
return ENOSYS;
}
-Error FuseFsNode::GetSize(size_t* out_size) {
+Error MountNodeFuse::GetSize(size_t* out_size) {
struct stat statbuf;
Error error = GetStat(&statbuf);
if (error)
@@ -267,19 +274,19 @@ Error FuseFsNode::GetSize(size_t* out_size) {
return 0;
}
-FileFuseFsNode::FileFuseFsNode(Filesystem* filesystem,
- struct fuse_operations* fuse_ops,
- struct fuse_file_info& info,
- const std::string& path)
- : FuseFsNode(filesystem, fuse_ops, info, path) {}
+MountNodeFuseFile::MountNodeFuseFile(Mount* mount,
+ struct fuse_operations* fuse_ops,
+ struct fuse_file_info& info,
+ const std::string& path)
+ : MountNodeFuse(mount, fuse_ops, info, path) {}
-void FileFuseFsNode::Destroy() {
+void MountNodeFuseFile::Destroy() {
if (!fuse_ops_->release)
return;
fuse_ops_->release(path_.c_str(), &info_);
}
-Error FileFuseFsNode::FSync() {
+Error MountNodeFuseFile::FSync() {
if (!fuse_ops_->fsync)
return ENOSYS;
@@ -290,7 +297,7 @@ Error FileFuseFsNode::FSync() {
return 0;
}
-Error FileFuseFsNode::FTruncate(off_t length) {
+Error MountNodeFuseFile::FTruncate(off_t length) {
if (!fuse_ops_->ftruncate)
return ENOSYS;
@@ -300,10 +307,10 @@ Error FileFuseFsNode::FTruncate(off_t length) {
return 0;
}
-Error FileFuseFsNode::Read(const HandleAttr& attr,
- void* buf,
- size_t count,
- int* out_bytes) {
+Error MountNodeFuseFile::Read(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes) {
if (!fuse_ops_->read)
return ENOSYS;
@@ -314,7 +321,7 @@ Error FileFuseFsNode::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 filesystem flag is set.
+ // (padding with zeroes) unless the direct_io mount flag is set.
// TODO(binji): support the direct_io flag
if (static_cast<size_t>(result) < count)
memset(&cbuf[result], 0, count - result);
@@ -323,10 +330,10 @@ Error FileFuseFsNode::Read(const HandleAttr& attr,
return 0;
}
-Error FileFuseFsNode::Write(const HandleAttr& attr,
- const void* buf,
- size_t count,
- int* out_bytes) {
+Error MountNodeFuseFile::Write(const HandleAttr& attr,
+ const void* buf,
+ size_t count,
+ int* out_bytes) {
if (!fuse_ops_->write)
return ENOSYS;
@@ -336,26 +343,26 @@ Error FileFuseFsNode::Write(const HandleAttr& attr,
return -result;
// Fuse docs say that a write() call will always write the entire buffer
- // unless the direct_io filesystem flag is set.
+ // unless the direct_io mount 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;
}
-DirFuseFsNode::DirFuseFsNode(Filesystem* filesystem,
- struct fuse_operations* fuse_ops,
- struct fuse_file_info& info,
- const std::string& path)
- : FuseFsNode(filesystem, fuse_ops, info, path) {}
+MountNodeFuseDir::MountNodeFuseDir(Mount* mount,
+ struct fuse_operations* fuse_ops,
+ struct fuse_file_info& info,
+ const std::string& path)
+ : MountNodeFuse(mount, fuse_ops, info, path) {}
-void DirFuseFsNode::Destroy() {
+void MountNodeFuseDir::Destroy() {
if (!fuse_ops_->releasedir)
return;
fuse_ops_->releasedir(path_.c_str(), &info_);
}
-Error DirFuseFsNode::FSync() {
+Error MountNodeFuseDir::FSync() {
if (!fuse_ops_->fsyncdir)
return ENOSYS;
@@ -366,10 +373,10 @@ Error DirFuseFsNode::FSync() {
return 0;
}
-Error DirFuseFsNode::GetDents(size_t offs,
- struct dirent* pdir,
- size_t count,
- int* out_bytes) {
+Error MountNodeFuseDir::GetDents(size_t offs,
+ struct dirent* pdir,
+ size_t count,
+ int* out_bytes) {
if (!fuse_ops_->readdir)
return ENOSYS;
@@ -388,8 +395,11 @@ Error DirFuseFsNode::GetDents(size_t offs,
Error error = 0;
GetDentsHelper getdents;
FillDirInfo fill_info(&getdents, count);
- result = fuse_ops_->readdir(
- path_.c_str(), &fill_info, &DirFuseFsNode::FillDirCallback, offs, &info_);
+ result = fuse_ops_->readdir(path_.c_str(),
+ &fill_info,
+ &MountNodeFuseDir::FillDirCallback,
+ offs,
+ &info_);
if (result < 0)
goto fail;
@@ -417,10 +427,10 @@ fail:
return -result;
}
-int DirFuseFsNode::FillDirCallback(void* buf,
- const char* name,
- const struct stat* stbuf,
- off_t off) {
+int MountNodeFuseDir::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
@@ -448,4 +458,5 @@ int DirFuseFsNode::FillDirCallback(void* buf,
}
}
+
} // namespace nacl_io
diff --git a/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.h b/native_client_sdk/src/libraries/nacl_io/mount_fuse.h
index 0e1f90d..28e4c3f 100644
--- a/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount_fuse.h
@@ -1,49 +1,50 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// 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_FUSEFS_FUSE_FS_H_
-#define LIBRARIES_NACL_IO_FUSEFS_FUSE_FS_H_
+#ifndef LIBRARIES_NACL_IO_MOUNT_FUSE_H_
+#define LIBRARIES_NACL_IO_MOUNT_FUSE_H_
#include <map>
-#include "nacl_io/filesystem.h"
#include "nacl_io/fuse.h"
-#include "nacl_io/node.h"
+#include "nacl_io/mount.h"
+#include "nacl_io/mount_node.h"
+#include "nacl_io/typed_mount_factory.h"
namespace nacl_io {
-class FuseFs : public Filesystem {
+class MountFuse : public Mount {
protected:
- FuseFs();
+ MountFuse();
- virtual Error Init(const FsInitArgs& args);
+ 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, ScopedNode* out_node);
+ virtual Error Open(const Path& path, int mode, 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:
+private:
struct fuse_operations* fuse_ops_;
void* fuse_user_data_;
- friend class FuseFsNode;
- friend class FuseFsFactory;
- DISALLOW_COPY_AND_ASSIGN(FuseFs);
+ friend class MountNodeFuse;
+ friend class FuseMountFactory;
+ DISALLOW_COPY_AND_ASSIGN(MountFuse);
};
-class FuseFsNode : public Node {
+class MountNodeFuse : public MountNode {
protected:
- FuseFsNode(Filesystem* filesystem,
- struct fuse_operations* fuse_ops,
- struct fuse_file_info& info,
- const std::string& path);
+ MountNodeFuse(Mount* mount,
+ struct fuse_operations* fuse_ops,
+ struct fuse_file_info& info,
+ const std::string& path);
public:
virtual bool CanOpen(int open_flags);
@@ -52,7 +53,7 @@ class FuseFsNode : public Node {
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:
@@ -61,12 +62,12 @@ class FuseFsNode : public Node {
std::string path_;
};
-class FileFuseFsNode : public FuseFsNode {
+class MountNodeFuseFile : public MountNodeFuse {
public:
- FileFuseFsNode(Filesystem* filesystem,
- struct fuse_operations* fuse_ops,
- struct fuse_file_info& info,
- const std::string& path);
+ MountNodeFuseFile(Mount* mount,
+ struct fuse_operations* fuse_ops,
+ struct fuse_file_info& info,
+ const std::string& path);
protected:
virtual void Destroy();
@@ -84,16 +85,16 @@ class FileFuseFsNode : public FuseFsNode {
int* out_bytes);
private:
- friend class FuseFs;
- DISALLOW_COPY_AND_ASSIGN(FileFuseFsNode);
+ friend class MountFuse;
+ DISALLOW_COPY_AND_ASSIGN(MountNodeFuseFile);
};
-class DirFuseFsNode : public FuseFsNode {
+class MountNodeFuseDir : public MountNodeFuse {
public:
- DirFuseFsNode(Filesystem* filesystem,
- struct fuse_operations* fuse_ops,
- struct fuse_file_info& info,
- const std::string& path);
+ MountNodeFuseDir(Mount* mount,
+ struct fuse_operations* fuse_ops,
+ struct fuse_file_info& info,
+ const std::string& path);
protected:
virtual void Destroy();
@@ -112,10 +113,10 @@ class DirFuseFsNode : public FuseFsNode {
off_t off);
private:
- friend class FuseFs;
- DISALLOW_COPY_AND_ASSIGN(DirFuseFsNode);
+ friend class MountFuse;
+ DISALLOW_COPY_AND_ASSIGN(MountNodeFuseDir);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_FUSEFS_FUSE_FS_H_
+#endif // LIBRARIES_NACL_IO_MOUNT_FUSE_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc b/native_client_sdk/src/libraries/nacl_io/mount_html5fs.cc
index ac4bb3f..a54c183 100644
--- a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_html5fs.cc
@@ -2,19 +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/html5fs/html5_fs.h"
+#include "nacl_io/mount_html5fs.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 <ppapi/c/pp_completion_callback.h>
-#include <ppapi/c/pp_errors.h>
-
-#include "nacl_io/html5fs/html5_fs_node.h"
+#include "nacl_io/mount_node_html5fs.h"
#include "sdk_util/auto_lock.h"
namespace nacl_io {
@@ -29,24 +26,26 @@ int64_t strtoull(const char* nptr, char** endptr, int base) {
} // namespace
-Error Html5Fs::Access(const Path& path, int a_mode) {
+Error MountHtml5Fs::Access(const Path& path, int a_mode) {
// a_mode is unused, since all files are readable, writable and executable.
- ScopedNode node;
+ ScopedMountNode node;
return Open(path, O_RDONLY, &node);
}
-Error Html5Fs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
+Error MountHtml5Fs::Open(const Path& path,
+ int open_flags,
+ ScopedMountNode* 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;
- ScopedNode node(new Html5FsNode(this, fileref));
+ ScopedMountNode node(new MountNodeHtml5Fs(this, fileref));
error = node->Init(open_flags);
if (error)
return error;
@@ -55,9 +54,9 @@ Error Html5Fs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
return 0;
}
-Error Html5Fs::Unlink(const Path& path) { return Remove(path); }
+Error MountHtml5Fs::Unlink(const Path& path) { return Remove(path); }
-Error Html5Fs::Mkdir(const Path& path, int permissions) {
+Error MountHtml5Fs::Mkdir(const Path& path, int permissions) {
Error error = BlockUntilFilesystemOpen();
if (error)
return error;
@@ -82,9 +81,9 @@ Error Html5Fs::Mkdir(const Path& path, int permissions) {
return 0;
}
-Error Html5Fs::Rmdir(const Path& path) { return Remove(path); }
+Error MountHtml5Fs::Rmdir(const Path& path) { return Remove(path); }
-Error Html5Fs::Remove(const Path& path) {
+Error MountHtml5Fs::Remove(const Path& path) {
Error error = BlockUntilFilesystemOpen();
if (error)
return error;
@@ -96,15 +95,15 @@ Error Html5Fs::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 Html5Fs::Rename(const Path& path, const Path& newpath) {
+Error MountHtml5Fs::Rename(const Path& path, const Path& newpath) {
Error error = BlockUntilFilesystemOpen();
if (error)
return error;
@@ -119,13 +118,13 @@ Error Html5Fs::Rename(const Path& path, const Path& newpath) {
return EACCES;
}
-Html5Fs::Html5Fs()
+MountHtml5Fs::MountHtml5Fs()
: filesystem_resource_(0),
filesystem_open_has_result_(false),
filesystem_open_error_(0) {}
-Error Html5Fs::Init(const FsInitArgs& args) {
- Error error = Filesystem::Init(args);
+Error MountHtml5Fs::Init(const MountInitArgs& args) {
+ Error error = Mount::Init(args);
if (error)
return error;
@@ -134,7 +133,7 @@ Error Html5Fs::Init(const FsInitArgs& args) {
pthread_cond_init(&filesystem_open_cond_, NULL);
- // Parse filesystem args.
+ // Parse mount args.
PP_FileSystemType filesystem_type = PP_FILESYSTEMTYPE_LOCALPERSISTENT;
int64_t expected_size = 0;
for (StringMap_t::const_iterator iter = args.string_map.begin();
@@ -152,8 +151,8 @@ Error Html5Fs::Init(const FsInitArgs& 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;
@@ -163,11 +162,11 @@ Error Html5Fs::Init(const FsInitArgs& args) {
bool main_thread = args.ppapi->GetCoreInterface()->IsMainThread();
PP_CompletionCallback cc =
main_thread ? PP_MakeCompletionCallback(
- &Html5Fs::FilesystemOpenCallbackThunk, this)
+ &MountHtml5Fs::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;
@@ -181,12 +180,12 @@ Error Html5Fs::Init(const FsInitArgs& args) {
return 0;
}
-void Html5Fs::Destroy() {
+void MountHtml5Fs::Destroy() {
ppapi_->ReleaseResource(filesystem_resource_);
pthread_cond_destroy(&filesystem_open_cond_);
}
-Error Html5Fs::BlockUntilFilesystemOpen() {
+Error MountHtml5Fs::BlockUntilFilesystemOpen() {
AUTO_LOCK(filesysem_open_lock_);
while (!filesystem_open_has_result_) {
pthread_cond_wait(&filesystem_open_cond_, filesysem_open_lock_.mutex());
@@ -195,12 +194,13 @@ Error Html5Fs::BlockUntilFilesystemOpen() {
}
// static
-void Html5Fs::FilesystemOpenCallbackThunk(void* user_data, int32_t result) {
- Html5Fs* self = static_cast<Html5Fs*>(user_data);
+void MountHtml5Fs::FilesystemOpenCallbackThunk(void* user_data,
+ int32_t result) {
+ MountHtml5Fs* self = static_cast<MountHtml5Fs*>(user_data);
self->FilesystemOpenCallback(result);
}
-void Html5Fs::FilesystemOpenCallback(int32_t result) {
+void MountHtml5Fs::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/html5fs/html5_fs.h b/native_client_sdk/src/libraries/nacl_io/mount_html5fs.h
index e71d636..06dad78 100644
--- a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount_html5fs.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_HTML5FS_HTML5_FS_H_
-#define LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_H_
+#ifndef LIBRARIES_NACL_IO_MOUNT_HTML5FS_H_
+#define LIBRARIES_NACL_IO_MOUNT_HTML5FS_H_
#include <pthread.h>
-#include "nacl_io/filesystem.h"
+#include "nacl_io/mount.h"
#include "nacl_io/pepper_interface.h"
-#include "nacl_io/typed_fs_factory.h"
+#include "nacl_io/typed_mount_factory.h"
#include "sdk_util/simple_lock.h"
namespace nacl_io {
-class Node;
+class MountNode;
-class Html5Fs : public Filesystem {
+class MountHtml5Fs : public Mount {
public:
virtual Error Access(const Path& path, int a_mode);
- virtual Error Open(const Path& path, int mode, ScopedNode* out_node);
+ virtual Error Open(const Path& path, int mode, ScopedMountNode* 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 Html5Fs : public Filesystem {
PP_Resource filesystem_resource() { return filesystem_resource_; }
protected:
- Html5Fs();
+ MountHtml5Fs();
- virtual Error Init(const FsInitArgs& args);
+ virtual Error Init(const MountInitArgs& args);
virtual void Destroy();
Error BlockUntilFilesystemOpen();
@@ -47,9 +47,9 @@ class Html5Fs : public Filesystem {
pthread_cond_t filesystem_open_cond_;
sdk_util::SimpleLock filesysem_open_lock_;
- friend class TypedFsFactory<Html5Fs>;
+ friend class TypedMountFactory<MountHtml5Fs>;
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_H_
+#endif // LIBRARIES_NACL_IO_MOUNT_HTML5FS_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.cc b/native_client_sdk/src/libraries/nacl_io/mount_http.cc
index 29dd761..4d613e9 100644
--- a/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_http.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/httpfs/http_fs.h"
+#include "nacl_io/mount_http.h"
#include <assert.h>
#include <ctype.h>
@@ -15,13 +15,12 @@
#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 {
@@ -40,14 +39,14 @@ std::string NormalizeHeaderKey(const std::string& s) {
return result;
}
-Error HttpFs::Access(const Path& path, int a_mode) {
+Error MountHttp::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);
- ScopedNode node(new HttpFsNode(this, url, cache_content_));
+ ScopedMountNode node(new MountNodeHttp(this, url, cache_content_));
Error error = node->Init(0);
if (error)
return error;
@@ -64,7 +63,8 @@ Error HttpFs::Access(const Path& path, int a_mode) {
return 0;
}
-Error HttpFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
+Error MountHttp::Open(const Path& path, int open_flags,
+ ScopedMountNode* out_node) {
out_node->reset(NULL);
assert(url_root_.empty() || url_root_[url_root_.length() - 1] == '/');
@@ -76,7 +76,7 @@ Error HttpFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
// If we can't find the node in the cache, create it
std::string url = MakeUrl(path);
- ScopedNode node(new HttpFsNode(this, url, cache_content_));
+ ScopedMountNode node(new MountNodeHttp(this, url, cache_content_));
Error error = node->Init(open_flags);
if (error)
return error;
@@ -85,7 +85,7 @@ Error HttpFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
if (error)
return error;
- ScopedNode parent;
+ ScopedMountNode parent;
error = FindOrCreateDir(path.Parent(), &parent);
if (error)
return error;
@@ -99,7 +99,7 @@ Error HttpFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
return 0;
}
-Error HttpFs::Unlink(const Path& path) {
+Error MountHttp::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 HttpFs::Unlink(const Path& path) {
return EACCES;
}
-Error HttpFs::Mkdir(const Path& path, int permissions) {
+Error MountHttp::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 HttpFs::Mkdir(const Path& path, int permissions) {
return EACCES;
}
-Error HttpFs::Rmdir(const Path& path) {
+Error MountHttp::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 HttpFs::Rmdir(const Path& path) {
return EACCES;
}
-Error HttpFs::Remove(const Path& path) {
+Error MountHttp::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 HttpFs::Remove(const Path& path) {
return EACCES;
}
-Error HttpFs::Rename(const Path& path, const Path& newpath) {
+Error MountHttp::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 HttpFs::Rename(const Path& path, const Path& newpath) {
return EACCES;
}
-PP_Resource HttpFs::MakeUrlRequestInfo(const std::string& url,
- const char* method,
- StringMap_t* additional_headers) {
+PP_Resource MountHttp::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 HttpFs::MakeUrlRequestInfo(const std::string& url,
PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS,
PP_MakeBool(allow_credentials_ ? PP_TRUE : PP_FALSE));
- // Merge the filesystem headers with the request headers. If the field is
- // already set it |additional_headers|, don't use the one from headers_.
+ // Merge the mount 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 HttpFs::MakeUrlRequestInfo(const std::string& url,
return request_info;
}
-HttpFs::HttpFs()
+MountHttp::MountHttp()
: allow_cors_(false),
allow_credentials_(false),
cache_stat_(true),
cache_content_(true) {}
-Error HttpFs::Init(const FsInitArgs& args) {
- Error error = Filesystem::Init(args);
+Error MountHttp::Init(const MountInitArgs& args) {
+ Error error = Mount::Init(args);
if (error)
return error;
- // Parse filesystem args.
+ // Parse mount args.
for (StringMap_t::const_iterator iter = args.string_map.begin();
iter != args.string_map.end();
++iter) {
@@ -247,9 +247,10 @@ Error HttpFs::Init(const FsInitArgs& args) {
return 0;
}
-void HttpFs::Destroy() {}
+void MountHttp::Destroy() {}
-Error HttpFs::FindOrCreateDir(const Path& path, ScopedNode* out_node) {
+Error MountHttp::FindOrCreateDir(const Path& path,
+ ScopedMountNode* out_node) {
out_node->reset(NULL);
std::string strpath = path.Join();
NodeMap_t::iterator iter = node_cache_.find(strpath);
@@ -259,14 +260,14 @@ Error HttpFs::FindOrCreateDir(const Path& path, ScopedNode* out_node) {
}
// If the node does not exist, create it.
- ScopedNode node(new DirNode(this));
+ ScopedMountNode node(new MountNodeDir(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()) {
- ScopedNode parent;
+ ScopedMountNode parent;
error = FindOrCreateDir(path.Parent(), &parent);
if (error)
return error;
@@ -282,7 +283,7 @@ Error HttpFs::FindOrCreateDir(const Path& path, ScopedNode* out_node) {
return 0;
}
-Error HttpFs::ParseManifest(const char* text) {
+Error MountHttp::ParseManifest(const char* text) {
std::vector<std::string> lines;
sdk_util::SplitString(text, '\n', &lines);
@@ -293,8 +294,7 @@ Error HttpFs::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,9 +318,7 @@ Error HttpFs::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;
}
@@ -332,9 +330,7 @@ Error HttpFs::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;
}
@@ -346,9 +342,7 @@ Error HttpFs::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;
}
@@ -356,16 +350,16 @@ Error HttpFs::ParseManifest(const char* text) {
Path path(name);
std::string url = MakeUrl(path);
- HttpFsNode* http_node = new HttpFsNode(this, url, cache_content_);
+ MountNodeHttp* http_node = new MountNodeHttp(this, url, cache_content_);
http_node->SetMode(mode);
- ScopedNode node(http_node);
+ ScopedMountNode node(http_node);
Error error = node->Init(0);
if (error)
return error;
http_node->SetCachedSize(atoi(lenstr.c_str()));
- ScopedNode dir_node;
+ ScopedMountNode dir_node;
error = FindOrCreateDir(path.Parent(), &dir_node);
if (error)
return error;
@@ -382,10 +376,10 @@ Error HttpFs::ParseManifest(const char* text) {
return 0;
}
-Error HttpFs::LoadManifest(const std::string& manifest_name,
- char** out_manifest) {
+Error MountHttp::LoadManifest(const std::string& manifest_name,
+ char** out_manifest) {
Path manifest_path(manifest_name);
- ScopedNode manifest_node;
+ ScopedMountNode manifest_node;
*out_manifest = NULL;
int error = Open(manifest_path, O_RDONLY, &manifest_node);
@@ -408,7 +402,7 @@ Error HttpFs::LoadManifest(const std::string& manifest_name,
return 0;
}
-std::string HttpFs::MakeUrl(const Path& path) {
+std::string MountHttp::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/httpfs/http_fs.h b/native_client_sdk/src/libraries/nacl_io/mount_http.h
index 22d2051..145140d 100644
--- a/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount_http.h
@@ -2,24 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_H_
-#define LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_H_
+
+#ifndef LIBRARIES_NACL_IO_MOUNT_HTTP_H_
+#define LIBRARIES_NACL_IO_MOUNT_HTTP_H_
#include <string>
-#include "nacl_io/filesystem.h"
+#include "nacl_io/mount.h"
#include "nacl_io/pepper_interface.h"
-#include "nacl_io/typed_fs_factory.h"
+#include "nacl_io/typed_mount_factory.h"
namespace nacl_io {
std::string NormalizeHeaderKey(const std::string& s);
-class HttpFs : public Filesystem {
+class MountHttp : public Mount {
public:
- typedef std::map<std::string, ScopedNode> NodeMap_t;
+ typedef std::map<std::string, ScopedMountNode> NodeMap_t;
virtual Error Access(const Path& path, int a_mode);
- virtual Error Open(const Path& path, int mode, ScopedNode* out_node);
+ virtual Error Open(const Path& path, int mode, ScopedMountNode* out_node);
virtual Error Unlink(const Path& path);
virtual Error Mkdir(const Path& path, int permissions);
virtual Error Rmdir(const Path& path);
@@ -31,13 +32,13 @@ class HttpFs : public Filesystem {
StringMap_t* additional_headers);
protected:
- HttpFs();
+ MountHttp();
- virtual Error Init(const FsInitArgs& args);
+ virtual Error Init(const MountInitArgs& args);
virtual void Destroy();
- Error FindOrCreateDir(const Path& path, ScopedNode* out_node);
+ Error FindOrCreateDir(const Path& path, ScopedMountNode* 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_; }
@@ -54,10 +55,10 @@ class HttpFs : public Filesystem {
bool cache_stat_;
bool cache_content_;
- friend class TypedFsFactory<HttpFs>;
- friend class HttpFsNode;
+ friend class TypedMountFactory<MountHttp>;
+ friend class MountNodeHttp;
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_H_
+#endif // LIBRARIES_NACL_IO_MOUNT_HTTP_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.cc b/native_client_sdk/src/libraries/nacl_io/mount_mem.cc
index e34d424..f00aa15 100644
--- a/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_mem.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/memfs/mem_fs.h"
+#include "nacl_io/mount_mem.h"
#include <errno.h>
#include <fcntl.h>
#include <string>
-#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/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/osstat.h"
#include "nacl_io/osunistd.h"
#include "nacl_io/path.h"
@@ -21,14 +21,14 @@
namespace nacl_io {
-MemFs::MemFs() : root_(NULL) {}
+MountMem::MountMem() : root_(NULL) {}
-Error MemFs::Init(const FsInitArgs& args) {
- Error error = Filesystem::Init(args);
+Error MountMem::Init(const MountInitArgs& args) {
+ Error error = Mount::Init(args);
if (error)
return error;
- root_.reset(new DirNode(this));
+ root_.reset(new MountNodeDir(this));
error = root_->Init(0);
if (error) {
root_.reset(NULL);
@@ -37,9 +37,11 @@ Error MemFs::Init(const FsInitArgs& args) {
return 0;
}
-Error MemFs::FindNode(const Path& path, int type, ScopedNode* out_node) {
+Error MountMem::FindNode(const Path& path,
+ int type,
+ ScopedMountNode* out_node) {
out_node->reset(NULL);
- ScopedNode node = root_;
+ ScopedMountNode node = root_;
// If there is no root there, we have an error.
if (node == NULL)
@@ -74,8 +76,8 @@ Error MemFs::FindNode(const Path& path, int type, ScopedNode* out_node) {
return 0;
}
-Error MemFs::Access(const Path& path, int a_mode) {
- ScopedNode node;
+Error MountMem::Access(const Path& path, int a_mode) {
+ ScopedMountNode node;
Error error = FindNode(path, 0, &node);
if (error)
@@ -91,9 +93,10 @@ Error MemFs::Access(const Path& path, int a_mode) {
return 0;
}
-Error MemFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
+Error MountMem::Open(const Path& path, int open_flags,
+ ScopedMountNode* out_node) {
out_node->reset(NULL);
- ScopedNode node;
+ ScopedMountNode node;
Error error = FindNode(path, 0, &node);
if (error) {
@@ -102,12 +105,12 @@ Error MemFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
return ENOENT;
// Now first find the parent directory to see if we can add it
- ScopedNode parent;
+ ScopedMountNode parent;
error = FindNode(path.Parent(), S_IFDIR, &parent);
if (error)
return error;
- node.reset(new MemFsNode(this));
+ node.reset(new MountNodeMem(this));
error = node->Init(open_flags);
if (error)
return error;
@@ -128,28 +131,29 @@ Error MemFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
return EEXIST;
if (open_flags & O_TRUNC)
- static_cast<MemFsNode*>(node.get())->Resize(0);
+ static_cast<MountNodeMem*>(node.get())->Resize(0);
}
+
*out_node = node;
return 0;
}
-Error MemFs::Mkdir(const Path& path, int mode) {
- // We expect a Filesystem "absolute" path
+Error MountMem::Mkdir(const Path& path, int mode) {
+ // We expect a Mount "absolute" path
if (!path.IsAbsolute())
return ENOENT;
- // The root of the filesystem is already created by the filesystem
+ // The root of the mount is already created by the mount
if (path.Size() == 1)
return EEXIST;
- ScopedNode parent;
+ ScopedMountNode parent;
int error = FindNode(path.Parent(), S_IFDIR, &parent);
if (error)
return error;
- ScopedNode node;
+ ScopedMountNode node;
error = parent->FindChild(path.Basename(), &node);
if (!error)
return EEXIST;
@@ -160,7 +164,7 @@ Error MemFs::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 DirNode(this));
+ node.reset(new MountNodeDir(this));
error = node->Init(0);
if (error)
return error;
@@ -168,23 +172,23 @@ Error MemFs::Mkdir(const Path& path, int mode) {
return parent->AddChild(path.Basename(), node);
}
-Error MemFs::Unlink(const Path& path) {
+Error MountMem::Unlink(const Path& path) {
return RemoveInternal(path, REMOVE_FILE);
}
-Error MemFs::Rmdir(const Path& path) {
+Error MountMem::Rmdir(const Path& path) {
return RemoveInternal(path, REMOVE_DIR);
}
-Error MemFs::Remove(const Path& path) {
+Error MountMem::Remove(const Path& path) {
return RemoveInternal(path, REMOVE_ALL);
}
-Error MemFs::Rename(const Path& src_path, const Path& target_path) {
- ScopedNode src_node;
- ScopedNode src_parent;
- ScopedNode target_node;
- ScopedNode target_parent;
+Error MountMem::Rename(const Path& src_path, const Path& target_path) {
+ ScopedMountNode src_node;
+ ScopedMountNode src_parent;
+ ScopedMountNode target_node;
+ ScopedMountNode target_parent;
int error = FindNode(src_path, 0, &src_node);
if (error)
return error;
@@ -249,28 +253,28 @@ Error MemFs::Rename(const Path& src_path, const Path& target_path) {
return 0;
}
-Error MemFs::RemoveInternal(const Path& path, int remove_type) {
+Error MountMem::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 Filesystem "absolute" path
+ // We expect a Mount "absolute" path
if (!path.IsAbsolute())
return ENOENT;
- // The root of the filesystem is already created by the filesystem
+ // The root of the mount is already created by the mount
if (path.Size() == 1)
return EEXIST;
}
- ScopedNode parent;
+ ScopedMountNode parent;
int error = FindNode(path.Parent(), S_IFDIR, &parent);
if (error)
return error;
// Verify we find a child which is a directory.
- ScopedNode child;
+ ScopedMountNode child;
error = parent->FindChild(path.Basename(), &child);
if (error)
return error;
diff --git a/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.h b/native_client_sdk/src/libraries/nacl_io/mount_mem.h
index 89df5fa..8ad87ca 100644
--- a/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount_mem.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_MEMFS_MEM_FS_H_
-#define LIBRARIES_NACL_IO_MEMFS_MEM_FS_H_
+#ifndef LIBRARIES_NACL_IO_MOUNT_MEM_H_
+#define LIBRARIES_NACL_IO_MOUNT_MEM_H_
-#include "nacl_io/filesystem.h"
-#include "nacl_io/typed_fs_factory.h"
+#include "nacl_io/mount.h"
+#include "nacl_io/typed_mount_factory.h"
namespace nacl_io {
-class MemFs : public Filesystem {
+class MountMem : public Mount {
protected:
- MemFs();
+ MountMem();
- using Filesystem::Init;
- virtual Error Init(const FsInitArgs& args);
+ using Mount::Init;
+ virtual Error Init(const MountInitArgs& args);
// The protected functions are only used internally and will not
- // acquire or release the filesystem's lock themselves. The caller is
+ // acquire or release the mount's lock themselves. The caller is
// required to use correct locking as needed.
// Allocate or free an INODE number.
@@ -26,30 +26,30 @@ class MemFs : public Filesystem {
void FreeINO(int ino);
// Find a Node specified node optionally failing if type does not match.
- virtual Error FindNode(const Path& path, int type, ScopedNode* out_node);
+ virtual Error FindNode(const Path& path, int type, ScopedMountNode* out_node);
public:
virtual Error Access(const Path& path, int a_mode);
- virtual Error Open(const Path& path, int mode, ScopedNode* out_node);
+ virtual Error Open(const Path& path, int mode, 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:
+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);
- ScopedNode root_;
+ ScopedMountNode root_;
- friend class TypedFsFactory<MemFs>;
- DISALLOW_COPY_AND_ASSIGN(MemFs);
+ friend class TypedMountFactory<MountMem>;
+ DISALLOW_COPY_AND_ASSIGN(MountMem);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_MEMFS_MEM_FS_H_
+#endif // LIBRARIES_NACL_IO_MOUNT_MEM_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/node.cc b/native_client_sdk/src/libraries/nacl_io/mount_node.cc
index 802eee3..f69225d 100644
--- a/native_client_sdk/src/libraries/nacl_io/node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_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/node.h"
+#include "nacl_io/mount_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;
-Node::Node(Filesystem* filesystem) : filesystem_(filesystem) {
+MountNode::MountNode(Mount* mount) : mount_(mount) {
memset(&stat_, 0, sizeof(stat_));
stat_.st_gid = GRP_ID;
stat_.st_uid = USR_ID;
stat_.st_mode = S_IRALL | S_IWALL;
- // Filesystem should normally never be NULL, but may be null in tests.
+ // Mount should normally never be NULL, but may be null in tests.
// If NULL, at least set the inode to a valid (nonzero) value.
- if (filesystem_)
- filesystem_->OnNodeCreated(this);
+ if (mount_)
+ mount_->OnNodeCreated(this);
else
stat_.st_ino = 1;
}
-Node::~Node() {}
+MountNode::~MountNode() {}
-Error Node::Init(int open_flags) {
+Error MountNode::Init(int open_flags) {
return 0;
}
-void Node::Destroy() {
- if (filesystem_) {
- filesystem_->OnNodeDestroyed(this);
+void MountNode::Destroy() {
+ if (mount_) {
+ mount_->OnNodeDestroyed(this);
}
}
-EventEmitter* Node::GetEventEmitter() { return NULL; }
+EventEmitter* MountNode::GetEventEmitter() { return NULL; }
-uint32_t Node::GetEventStatus() {
+uint32_t MountNode::GetEventStatus() {
if (GetEventEmitter())
return GetEventEmitter()->GetEventStatus();
return POLLIN | POLLOUT;
}
-bool Node::CanOpen(int open_flags) {
+bool MountNode::CanOpen(int open_flags) {
switch (open_flags & 3) {
case O_RDONLY:
return (stat_.st_mode & S_IRALL) != 0;
@@ -73,11 +73,11 @@ bool Node::CanOpen(int open_flags) {
return false;
}
-Error Node::FSync() { return 0; }
+Error MountNode::FSync() { return 0; }
-Error Node::FTruncate(off_t length) { return EINVAL; }
+Error MountNode::FTruncate(off_t length) { return EINVAL; }
-Error Node::GetDents(size_t offs,
+Error MountNode::GetDents(size_t offs,
struct dirent* pdir,
size_t count,
int* out_bytes) {
@@ -85,13 +85,13 @@ Error Node::GetDents(size_t offs,
return ENOTDIR;
}
-Error Node::GetStat(struct stat* pstat) {
+Error MountNode::GetStat(struct stat* pstat) {
AUTO_LOCK(node_lock_);
memcpy(pstat, &stat_, sizeof(stat_));
return 0;
}
-Error Node::Ioctl(int request, ...) {
+Error MountNode::Ioctl(int request, ...) {
va_list ap;
va_start(ap, request);
Error rtn = VIoctl(request, ap);
@@ -99,9 +99,9 @@ Error Node::Ioctl(int request, ...) {
return rtn;
}
-Error Node::VIoctl(int request, va_list args) { return EINVAL; }
+Error MountNode::VIoctl(int request, va_list args) { return EINVAL; }
-Error Node::Read(const HandleAttr& attr,
+Error MountNode::Read(const HandleAttr& attr,
void* buf,
size_t count,
int* out_bytes) {
@@ -109,7 +109,7 @@ Error Node::Read(const HandleAttr& attr,
return EINVAL;
}
-Error Node::Write(const HandleAttr& attr,
+Error MountNode::Write(const HandleAttr& attr,
const void* buf,
size_t count,
int* out_bytes) {
@@ -117,7 +117,7 @@ Error Node::Write(const HandleAttr& attr,
return EINVAL;
}
-Error Node::MMap(void* addr,
+Error MountNode::MMap(void* addr,
size_t length,
int prot,
int flags,
@@ -131,8 +131,8 @@ Error Node::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 filesystem into the mmap'd memory area.
+ // This default mmap support is just enough to make dlopen work.
+ // This implementation just reads from the mount 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 Node::MMap(void* addr,
return 0;
}
-Error Node::Tcflush(int queue_selector) {
+Error MountNode::Tcflush(int queue_selector) {
return EINVAL;
}
-Error Node::Tcgetattr(struct termios* termios_p) {
+Error MountNode::Tcgetattr(struct termios* termios_p) {
return EINVAL;
}
-Error Node::Tcsetattr(int optional_actions,
+Error MountNode::Tcsetattr(int optional_actions,
const struct termios *termios_p) {
return EINVAL;
}
-int Node::GetLinks() { return stat_.st_nlink; }
+int MountNode::GetLinks() { return stat_.st_nlink; }
-int Node::GetMode() { return stat_.st_mode & ~S_IFMT; }
+int MountNode::GetMode() { return stat_.st_mode & ~S_IFMT; }
-Error Node::GetSize(size_t* out_size) {
+Error MountNode::GetSize(size_t* out_size) {
*out_size = stat_.st_size;
return 0;
}
-int Node::GetType() { return stat_.st_mode & S_IFMT; }
+int MountNode::GetType() { return stat_.st_mode & S_IFMT; }
-void Node::SetType(int type) {
+void MountNode::SetType(int type) {
assert((type & ~S_IFMT) == 0);
stat_.st_mode &= ~S_IFMT;
stat_.st_mode |= type;
}
-bool Node::IsaDir() { return (stat_.st_mode & S_IFDIR) != 0; }
+bool MountNode::IsaDir() { return (stat_.st_mode & S_IFDIR) != 0; }
-bool Node::IsaFile() { return (stat_.st_mode & S_IFREG) != 0; }
+bool MountNode::IsaFile() { return (stat_.st_mode & S_IFREG) != 0; }
-bool Node::IsaSock() { return (stat_.st_mode & S_IFSOCK) != 0; }
+bool MountNode::IsaSock() { return (stat_.st_mode & S_IFSOCK) != 0; }
-bool Node::IsaTTY() { return (stat_.st_mode & S_IFCHR) != 0; }
+bool MountNode::IsaTTY() { return (stat_.st_mode & S_IFCHR) != 0; }
-Error Node::AddChild(const std::string& name,
- const ScopedNode& node) {
+Error MountNode::AddChild(const std::string& name,
+ const ScopedMountNode& node) {
return ENOTDIR;
}
-Error Node::RemoveChild(const std::string& name) { return ENOTDIR; }
+Error MountNode::RemoveChild(const std::string& name) { return ENOTDIR; }
-Error Node::FindChild(const std::string& name, ScopedNode* out_node) {
+Error MountNode::FindChild(const std::string& name, ScopedMountNode* out_node) {
out_node->reset(NULL);
return ENOTDIR;
}
-int Node::ChildCount() { return 0; }
+int MountNode::ChildCount() { return 0; }
-void Node::Link() { stat_.st_nlink++; }
+void MountNode::Link() { stat_.st_nlink++; }
-void Node::Unlink() { stat_.st_nlink--; }
+void MountNode::Unlink() { stat_.st_nlink--; }
} // namespace nacl_io
diff --git a/native_client_sdk/src/libraries/nacl_io/node.h b/native_client_sdk/src/libraries/nacl_io/mount_node.h
index 962a338..80e27fa 100644
--- a/native_client_sdk/src/libraries/nacl_io/node.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount_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_NODE_H_
-#define LIBRARIES_NACL_IO_NODE_H_
+#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_H_
+#define LIBRARIES_NACL_IO_MOUNT_NODE_H_
#include <stdarg.h>
#include <string>
@@ -24,18 +24,18 @@
namespace nacl_io {
-class Filesystem;
-class Node;
+class Mount;
+class MountNode;
struct HandleAttr;
-typedef sdk_util::ScopedRef<Node> ScopedNode;
+typedef sdk_util::ScopedRef<MountNode> ScopedMountNode;
// 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 Node : public sdk_util::RefObject {
+class MountNode : public sdk_util::RefObject {
protected:
- explicit Node(Filesystem* filesystem);
- virtual ~Node();
+ explicit MountNode(Mount* mount);
+ virtual ~MountNode();
protected:
virtual Error Init(int open_flags);
@@ -52,9 +52,9 @@ class Node : 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 filesystem.
+ // must not be called by the mount.
virtual Error FSync();
- // It is expected that the derived Node will fill with 0 when growing
+ // It is expected that the derived MountNode 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 Node : 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 Node : public sdk_util::RefObject {
virtual int ChildCount();
protected:
- // Directory operations on the node are done by the Filesystem. The
- // filesystem's lock must be held while these calls are made.
+ // Directory operations on the node are done by the Mount. The mount'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 ScopedNode& node);
+ virtual Error AddChild(const std::string& name, const ScopedMountNode& 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, ScopedNode* out_node);
+ virtual Error FindChild(const std::string& name, ScopedMountNode* out_node);
// Update the link count
virtual void Link();
@@ -126,19 +126,19 @@ class Node : 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 filesystem should do
+ // to track it's parent. When a node is unlinked, the mount should do
// any cleanup it needs.
- Filesystem* filesystem_;
-
- friend class DevFs;
- friend class DirNode;
- friend class Filesystem;
- friend class FuseFs;
- friend class Html5Fs;
- friend class HttpFs;
- friend class MemFs;
+ Mount* mount_;
+
+ friend class Mount;
+ friend class MountDev;
+ friend class MountFuse;
+ friend class MountHtml5Fs;
+ friend class MountHttp;
+ friend class MountMem;
+ friend class MountNodeDir;
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_NODE_H_
+#endif // LIBRARIES_NACL_IO_MOUNT_NODE_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
new file mode 100644
index 0000000..da34483
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_char.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_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/dir_node.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_dir.cc
index 91ef0d8..5a71de8 100644
--- a/native_client_sdk/src/libraries/nacl_io/dir_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_dir.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/dir_node.h"
+#include "nacl_io/mount_node_dir.h"
#include <errno.h>
#include <string.h>
@@ -21,8 +21,8 @@ const ino_t kParentDirIno = -1;
}
-DirNode::DirNode(Filesystem* filesystem)
- : Node(filesystem),
+MountNodeDir::MountNodeDir(Mount* mount)
+ : MountNode(mount),
cache_(stat_.st_ino, kParentDirIno),
cache_built_(false) {
SetType(S_IFDIR);
@@ -30,13 +30,13 @@ DirNode::DirNode(Filesystem* filesystem)
stat_.st_mode |= S_IRALL | S_IWALL | S_IXALL;
}
-DirNode::~DirNode() {
- for (NodeMap_t::iterator it = map_.begin(); it != map_.end(); ++it) {
+MountNodeDir::~MountNodeDir() {
+ for (MountNodeMap_t::iterator it = map_.begin(); it != map_.end(); ++it) {
it->second->Unlink();
}
}
-Error DirNode::Read(const HandleAttr& attr,
+Error MountNodeDir::Read(const HandleAttr& attr,
void* buf,
size_t count,
int* out_bytes) {
@@ -44,9 +44,9 @@ Error DirNode::Read(const HandleAttr& attr,
return EISDIR;
}
-Error DirNode::FTruncate(off_t size) { return EISDIR; }
+Error MountNodeDir::FTruncate(off_t size) { return EISDIR; }
-Error DirNode::Write(const HandleAttr& attr,
+Error MountNodeDir::Write(const HandleAttr& attr,
const void* buf,
size_t count,
int* out_bytes) {
@@ -54,7 +54,7 @@ Error DirNode::Write(const HandleAttr& attr,
return EISDIR;
}
-Error DirNode::GetDents(size_t offs,
+Error MountNodeDir::GetDents(size_t offs,
dirent* pdir,
size_t size,
int* out_bytes) {
@@ -63,8 +63,8 @@ Error DirNode::GetDents(size_t offs,
return cache_.GetDents(offs, pdir, size, out_bytes);
}
-Error DirNode::AddChild(const std::string& name,
- const ScopedNode& node) {
+Error MountNodeDir::AddChild(const std::string& name,
+ const ScopedMountNode& node) {
AUTO_LOCK(node_lock_);
if (name.empty())
@@ -73,7 +73,7 @@ Error DirNode::AddChild(const std::string& name,
if (name.length() >= MEMBER_SIZE(dirent, d_name))
return ENAMETOOLONG;
- NodeMap_t::iterator it = map_.find(name);
+ MountNodeMap_t::iterator it = map_.find(name);
if (it != map_.end())
return EEXIST;
@@ -83,9 +83,9 @@ Error DirNode::AddChild(const std::string& name,
return 0;
}
-Error DirNode::RemoveChild(const std::string& name) {
+Error MountNodeDir::RemoveChild(const std::string& name) {
AUTO_LOCK(node_lock_);
- NodeMap_t::iterator it = map_.find(name);
+ MountNodeMap_t::iterator it = map_.find(name);
if (it != map_.end()) {
it->second->Unlink();
map_.erase(it);
@@ -95,12 +95,12 @@ Error DirNode::RemoveChild(const std::string& name) {
return ENOENT;
}
-Error DirNode::FindChild(const std::string& name,
- ScopedNode* out_node) {
+Error MountNodeDir::FindChild(const std::string& name,
+ ScopedMountNode* out_node) {
out_node->reset(NULL);
AUTO_LOCK(node_lock_);
- NodeMap_t::iterator it = map_.find(name);
+ MountNodeMap_t::iterator it = map_.find(name);
if (it == map_.end())
return ENOENT;
@@ -108,16 +108,16 @@ Error DirNode::FindChild(const std::string& name,
return 0;
}
-int DirNode::ChildCount() {
+int MountNodeDir::ChildCount() {
AUTO_LOCK(node_lock_);
return map_.size();
}
-void DirNode::BuildCache_Locked() {
+void MountNodeDir::BuildCache_Locked() {
if (cache_built_)
return;
- for (NodeMap_t::iterator it = map_.begin(), end = map_.end();
+ for (MountNodeMap_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 DirNode::BuildCache_Locked() {
cache_built_ = true;
}
-void DirNode::ClearCache_Locked() {
+void MountNodeDir::ClearCache_Locked() {
cache_built_ = false;
cache_.Reset();
}
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
new file mode 100644
index 0000000..33e6574
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_dir.h
@@ -0,0 +1,66 @@
+// 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/html5fs/html5_fs_node.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_html5fs.cc
index a6fa3ba..526f94f 100644
--- a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_html5fs.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/html5fs/html5_fs_node.h"
+#include "nacl_io/mount_node_html5fs.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 Html5FsNode::FSync() {
+Error MountNodeHtml5Fs::FSync() {
// Cannot call Flush on a directory; simply do nothing.
if (IsaDir())
return 0;
- int32_t result = filesystem_->ppapi()->GetFileIoInterface()->Flush(
- fileio_resource_, PP_BlockUntilComplete());
+ int32_t result = mount_->ppapi()->GetFileIoInterface()
+ ->Flush(fileio_resource_, PP_BlockUntilComplete());
if (result != PP_OK)
return PPErrorToErrno(result);
return 0;
}
-Error Html5FsNode::GetDents(size_t offs,
- struct dirent* pdir,
- size_t size,
- int* out_bytes) {
+Error MountNodeHtml5Fs::GetDents(size_t offs,
+ struct dirent* pdir,
+ size_t size,
+ int* out_bytes) {
*out_bytes = 0;
// If this is not a directory, fail
@@ -100,38 +100,37 @@ Error Html5FsNode::GetDents(size_t offs,
OutputBuffer output_buf = {NULL, 0};
PP_ArrayOutput output = {&GetOutputBuffer, &output_buf};
- int32_t result =
- filesystem_->ppapi()->GetFileRefInterface()->ReadDirectoryEntries(
- fileref_resource_, output, PP_BlockUntilComplete());
+ int32_t result = mount_->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 = filesystem_->ppapi()->GetFileRefInterface()->GetName(
- entries[i].file_ref);
+ PP_Var file_name_var =
+ mount_->ppapi()->GetFileRefInterface()->GetName(entries[i].file_ref);
// Release the file reference.
- filesystem_->ppapi()->ReleaseResource(entries[i].file_ref);
+ mount_->ppapi()->ReleaseResource(entries[i].file_ref);
if (file_name_var.type != PP_VARTYPE_STRING)
continue;
uint32_t file_name_length;
- const char* file_name = filesystem_->ppapi()->GetVarInterface()->VarToUtf8(
- file_name_var, &file_name_length);
+ const char* file_name = mount_->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);
}
- filesystem_->ppapi()->GetVarInterface()->Release(file_name_var);
+ mount_->ppapi()->GetVarInterface()->Release(file_name_var);
}
// Release the output buffer.
@@ -140,11 +139,11 @@ Error Html5FsNode::GetDents(size_t offs,
return helper.GetDents(offs, pdir, size, out_bytes);
}
-Error Html5FsNode::GetStat(struct stat* stat) {
+Error MountNodeHtml5Fs::GetStat(struct stat* stat) {
AUTO_LOCK(node_lock_);
PP_FileInfo info;
- int32_t result = filesystem_->ppapi()->GetFileRefInterface()->Query(
+ int32_t result = mount_->ppapi()->GetFileRefInterface()->Query(
fileref_resource_, &info, PP_BlockUntilComplete());
if (result != PP_OK)
return PPErrorToErrno(result);
@@ -172,21 +171,21 @@ Error Html5FsNode::GetStat(struct stat* stat) {
return 0;
}
-Error Html5FsNode::Read(const HandleAttr& attr,
- void* buf,
- size_t count,
- int* out_bytes) {
+Error MountNodeHtml5Fs::Read(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes) {
*out_bytes = 0;
if (IsaDir())
return EISDIR;
- int32_t result = filesystem_->ppapi()->GetFileIoInterface()->Read(
- fileio_resource_,
- attr.offs,
- static_cast<char*>(buf),
- static_cast<int32_t>(count),
- PP_BlockUntilComplete());
+ int32_t result =
+ mount_->ppapi()->GetFileIoInterface()->Read(fileio_resource_,
+ attr.offs,
+ static_cast<char*>(buf),
+ static_cast<int32_t>(count),
+ PP_BlockUntilComplete());
if (result < 0)
return PPErrorToErrno(result);
@@ -194,32 +193,32 @@ Error Html5FsNode::Read(const HandleAttr& attr,
return 0;
}
-Error Html5FsNode::FTruncate(off_t size) {
+Error MountNodeHtml5Fs::FTruncate(off_t size) {
if (IsaDir())
return EISDIR;
- int32_t result = filesystem_->ppapi()->GetFileIoInterface()->SetLength(
- fileio_resource_, size, PP_BlockUntilComplete());
+ int32_t result = mount_->ppapi()->GetFileIoInterface()
+ ->SetLength(fileio_resource_, size, PP_BlockUntilComplete());
if (result != PP_OK)
return PPErrorToErrno(result);
return 0;
}
-Error Html5FsNode::Write(const HandleAttr& attr,
- const void* buf,
- size_t count,
- int* out_bytes) {
+Error MountNodeHtml5Fs::Write(const HandleAttr& attr,
+ const void* buf,
+ size_t count,
+ int* out_bytes) {
*out_bytes = 0;
if (IsaDir())
return EISDIR;
- int32_t result = filesystem_->ppapi()->GetFileIoInterface()->Write(
- fileio_resource_,
- attr.offs,
- static_cast<const char*>(buf),
- static_cast<int32_t>(count),
- PP_BlockUntilComplete());
+ int32_t result = mount_->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);
@@ -227,9 +226,11 @@ Error Html5FsNode::Write(const HandleAttr& attr,
return 0;
}
-int Html5FsNode::GetType() { return fileio_resource_ ? S_IFREG : S_IFDIR; }
+int MountNodeHtml5Fs::GetType() {
+ return fileio_resource_ ? S_IFREG : S_IFDIR;
+}
-Error Html5FsNode::GetSize(size_t* out_size) {
+Error MountNodeHtml5Fs::GetSize(size_t* out_size) {
*out_size = 0;
if (IsaDir())
@@ -238,8 +239,8 @@ Error Html5FsNode::GetSize(size_t* out_size) {
AUTO_LOCK(node_lock_);
PP_FileInfo info;
- int32_t result = filesystem_->ppapi()->GetFileIoInterface()->Query(
- fileio_resource_, &info, PP_BlockUntilComplete());
+ int32_t result = mount_->ppapi()->GetFileIoInterface()
+ ->Query(fileio_resource_, &info, PP_BlockUntilComplete());
if (result != PP_OK)
return PPErrorToErrno(result);
@@ -247,30 +248,36 @@ Error Html5FsNode::GetSize(size_t* out_size) {
return 0;
}
-bool Html5FsNode::IsaDir() { return !fileio_resource_; }
+bool MountNodeHtml5Fs::IsaDir() {
+ return !fileio_resource_;
+}
-bool Html5FsNode::IsaFile() { return fileio_resource_; }
+bool MountNodeHtml5Fs::IsaFile() {
+ return fileio_resource_;
+}
-Html5FsNode::Html5FsNode(Filesystem* filesystem, PP_Resource fileref_resource)
- : Node(filesystem),
+MountNodeHtml5Fs::MountNodeHtml5Fs(Mount* mount, PP_Resource fileref_resource)
+ : MountNode(mount),
fileref_resource_(fileref_resource),
fileio_resource_(0) {}
-Error Html5FsNode::Init(int open_flags) {
- Error error = Node::Init(open_flags);
+Error MountNodeHtml5Fs::Init(int open_flags) {
+ Error error = MountNode::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 = filesystem_->ppapi()->GetFileRefInterface()->Query(
- fileref_resource_, &file_info, PP_BlockUntilComplete());
+ int32_t query_result =
+ mount_->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 = filesystem_->ppapi()->GetFileIoInterface();
- fileio_resource_ = file_io->Create(filesystem_->ppapi()->GetInstance());
+ FileIoInterface* file_io = mount_->ppapi()->GetFileIoInterface();
+ fileio_resource_ = file_io->Create(mount_->ppapi()->GetInstance());
if (!fileio_resource_)
return ENOSYS;
@@ -283,18 +290,18 @@ Error Html5FsNode::Init(int open_flags) {
return 0;
}
-void Html5FsNode::Destroy() {
+void MountNodeHtml5Fs::Destroy() {
FSync();
if (fileio_resource_) {
- filesystem_->ppapi()->GetFileIoInterface()->Close(fileio_resource_);
- filesystem_->ppapi()->ReleaseResource(fileio_resource_);
+ mount_->ppapi()->GetFileIoInterface()->Close(fileio_resource_);
+ mount_->ppapi()->ReleaseResource(fileio_resource_);
}
- filesystem_->ppapi()->ReleaseResource(fileref_resource_);
+ mount_->ppapi()->ReleaseResource(fileref_resource_);
fileio_resource_ = 0;
fileref_resource_ = 0;
- Node::Destroy();
+ MountNode::Destroy();
}
} // namespace nacl_io
diff --git a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.h b/native_client_sdk/src/libraries/nacl_io/mount_node_html5fs.h
index 984a0ea..d8ef90b 100644
--- a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_html5fs.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_HTML5FS_HTML5_FS_NODE_H_
-#define LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_NODE_H_
+#ifndef LIBRARIES_NACL_IO_MOUNT_HTML5FS_NODE_H_
+#define LIBRARIES_NACL_IO_MOUNT_HTML5FS_NODE_H_
#include <ppapi/c/pp_resource.h>
-#include "nacl_io/node.h"
+#include "nacl_io/mount_node.h"
namespace nacl_io {
-class Html5Fs;
+class MountHtml5Fs;
-class Html5FsNode : public Node {
+class MountNodeHtml5Fs : public MountNode {
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 filesystem.
+ // must not be called by the mount.
virtual Error FSync();
virtual Error GetDents(size_t offs,
struct dirent* pdir,
@@ -34,12 +34,12 @@ class Html5FsNode : public Node {
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:
- Html5FsNode(Filesystem* filesystem, PP_Resource fileref);
+ MountNodeHtml5Fs(Mount* mount, PP_Resource fileref);
// Init with standard open flags
virtual Error Init(int open_flags);
@@ -49,9 +49,9 @@ class Html5FsNode : public Node {
PP_Resource fileref_resource_;
PP_Resource fileio_resource_; // 0 if the file is a directory.
- friend class Html5Fs;
+ friend class MountHtml5Fs;
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_NODE_H_
+#endif // LIBRARIES_NACL_IO_MOUNT_HTML5FS_NODE_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_http.cc
index 511bc5c..66b63c7 100644
--- a/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_http.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/httpfs/http_fs_node.h"
+#include "nacl_io/mount_node_http.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 HttpFsNode::SetCachedSize(off_t size) {
+void MountNodeHttp::SetCachedSize(off_t size) {
has_cached_size_ = true;
stat_.st_size = size;
}
-Error HttpFsNode::FSync() { return EACCES; }
+Error MountNodeHttp::FSync() { return EACCES; }
-Error HttpFsNode::GetDents(size_t offs,
- struct dirent* pdir,
- size_t count,
- int* out_bytes) {
+Error MountNodeHttp::GetDents(size_t offs,
+ struct dirent* pdir,
+ size_t count,
+ int* out_bytes) {
*out_bytes = 0;
return EACCES;
}
-Error HttpFsNode::GetStat(struct stat* stat) {
+Error MountNodeHttp::GetStat(struct stat* stat) {
AUTO_LOCK(node_lock_);
return GetStat_Locked(stat);
}
-Error HttpFsNode::Read(const HandleAttr& attr,
- void* buf,
- size_t count,
- int* out_bytes) {
+Error MountNodeHttp::Read(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes) {
*out_bytes = 0;
AUTO_LOCK(node_lock_);
@@ -187,18 +187,18 @@ Error HttpFsNode::Read(const HandleAttr& attr,
return DownloadPartial(attr, buf, count, out_bytes);
}
-Error HttpFsNode::FTruncate(off_t size) { return EACCES; }
+Error MountNodeHttp::FTruncate(off_t size) { return EACCES; }
-Error HttpFsNode::Write(const HandleAttr& attr,
- const void* buf,
- size_t count,
- int* out_bytes) {
+Error MountNodeHttp::Write(const HandleAttr& attr,
+ const void* buf,
+ size_t count,
+ int* out_bytes) {
// TODO(binji): support POST?
*out_bytes = 0;
return EACCES;
}
-Error HttpFsNode::GetSize(size_t* out_size) {
+Error MountNodeHttp::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 HttpFsNode::GetSize(size_t* out_size) {
return 0;
}
-HttpFsNode::HttpFsNode(Filesystem* filesystem,
- const std::string& url,
- bool cache_content)
- : Node(filesystem),
+MountNodeHttp::MountNodeHttp(Mount* mount,
+ const std::string& url,
+ bool cache_content)
+ : MountNode(mount),
url_(url),
cache_content_(cache_content),
has_cached_size_(false) {}
-void HttpFsNode::SetMode(int mode) { stat_.st_mode = mode; }
+void MountNodeHttp::SetMode(int mode) { stat_.st_mode = mode; }
-Error HttpFsNode::GetStat_Locked(struct stat* stat) {
+Error MountNodeHttp::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.
- HttpFs* filesystem = static_cast<HttpFs*>(filesystem_);
- if (!has_cached_size_ || !filesystem->cache_stat_) {
+ MountHttp* mount = static_cast<MountHttp*>(mount_);
+ if (!has_cached_size_ || !mount->cache_stat_) {
StringMap_t headers;
- ScopedResource loader(filesystem_->ppapi());
- ScopedResource request(filesystem_->ppapi());
- ScopedResource response(filesystem_->ppapi());
+ ScopedResource loader(mount_->ppapi());
+ ScopedResource request(mount_->ppapi());
+ ScopedResource response(mount_->ppapi());
int32_t statuscode;
StringMap_t response_headers;
Error error = OpenUrl("HEAD",
@@ -280,21 +280,21 @@ Error HttpFsNode::GetStat_Locked(struct stat* stat) {
return 0;
}
-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) {
+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) {
// Clear all out parameters.
*out_statuscode = 0;
out_response_headers->clear();
// Assume lock_ is already held.
- PepperInterface* ppapi = filesystem_->ppapi();
+ PepperInterface* ppapi = mount_->ppapi();
- HttpFs* mount_http = static_cast<HttpFs*>(filesystem_);
+ MountHttp* mount_http = static_cast<MountHttp*>(mount_);
out_request->Reset(
mount_http->MakeUrlRequestInfo(url_, method, request_headers));
if (!out_request->pp_resource())
@@ -350,11 +350,11 @@ Error HttpFsNode::OpenUrl(const char* method,
return 0;
}
-Error HttpFsNode::DownloadToCache() {
+Error MountNodeHttp::DownloadToCache() {
StringMap_t headers;
- ScopedResource loader(filesystem_->ppapi());
- ScopedResource request(filesystem_->ppapi());
- ScopedResource response(filesystem_->ppapi());
+ ScopedResource loader(mount_->ppapi());
+ ScopedResource request(mount_->ppapi());
+ ScopedResource response(mount_->ppapi());
int32_t statuscode;
StringMap_t response_headers;
Error error = OpenUrl("GET",
@@ -390,10 +390,10 @@ Error HttpFsNode::DownloadToCache() {
return 0;
}
-Error HttpFsNode::ReadPartialFromCache(const HandleAttr& attr,
- void* buf,
- int count,
- int* out_bytes) {
+Error MountNodeHttp::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 HttpFsNode::ReadPartialFromCache(const HandleAttr& attr,
return 0;
}
-Error HttpFsNode::DownloadPartial(const HandleAttr& attr,
- void* buf,
- size_t count,
- int* out_bytes) {
+Error MountNodeHttp::DownloadPartial(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes) {
*out_bytes = 0;
StringMap_t headers;
@@ -425,9 +425,9 @@ Error HttpFsNode::DownloadPartial(const HandleAttr& attr,
attr.offs + count - 1);
headers["Range"] = buffer;
- ScopedResource loader(filesystem_->ppapi());
- ScopedResource request(filesystem_->ppapi());
- ScopedResource response(filesystem_->ppapi());
+ ScopedResource loader(mount_->ppapi());
+ ScopedResource request(mount_->ppapi());
+ ScopedResource response(mount_->ppapi());
int32_t statuscode;
StringMap_t response_headers;
Error error = OpenUrl("GET",
@@ -501,11 +501,11 @@ Error HttpFsNode::DownloadPartial(const HandleAttr& attr,
return ReadResponseToBuffer(loader, buf, count, out_bytes);
}
-Error HttpFsNode::DownloadToTemp(int* out_bytes) {
+Error MountNodeHttp::DownloadToTemp(int* out_bytes) {
StringMap_t headers;
- ScopedResource loader(filesystem_->ppapi());
- ScopedResource request(filesystem_->ppapi());
- ScopedResource response(filesystem_->ppapi());
+ ScopedResource loader(mount_->ppapi());
+ ScopedResource request(mount_->ppapi());
+ ScopedResource response(mount_->ppapi());
int32_t statuscode;
StringMap_t response_headers;
Error error = OpenUrl("GET",
@@ -527,8 +527,8 @@ Error HttpFsNode::DownloadToTemp(int* out_bytes) {
return ReadEntireResponseToTemp(loader, out_bytes);
}
-Error HttpFsNode::ReadEntireResponseToTemp(const ScopedResource& loader,
- int* out_bytes) {
+Error MountNodeHttp::ReadEntireResponseToTemp(const ScopedResource& loader,
+ int* out_bytes) {
*out_bytes = 0;
const int kBytesToRead = MAX_READ_BUFFER_SIZE;
@@ -548,8 +548,8 @@ Error HttpFsNode::ReadEntireResponseToTemp(const ScopedResource& loader,
}
}
-Error HttpFsNode::ReadEntireResponseToCache(const ScopedResource& loader,
- int* out_bytes) {
+Error MountNodeHttp::ReadEntireResponseToCache(const ScopedResource& loader,
+ int* out_bytes) {
*out_bytes = 0;
const int kBytesToRead = MAX_READ_BUFFER_SIZE;
@@ -574,9 +574,9 @@ Error HttpFsNode::ReadEntireResponseToCache(const ScopedResource& loader,
}
}
-Error HttpFsNode::ReadResponseToTemp(const ScopedResource& loader,
- int count,
- int* out_bytes) {
+Error MountNodeHttp::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 HttpFsNode::ReadResponseToTemp(const ScopedResource& loader,
return 0;
}
-Error HttpFsNode::ReadResponseToBuffer(const ScopedResource& loader,
- void* buf,
- int count,
- int* out_bytes) {
+Error MountNodeHttp::ReadResponseToBuffer(const ScopedResource& loader,
+ void* buf,
+ int count,
+ int* out_bytes) {
*out_bytes = 0;
- PepperInterface* ppapi = filesystem_->ppapi();
+ PepperInterface* ppapi = mount_->ppapi();
URLLoaderInterface* loader_interface = ppapi->GetURLLoaderInterface();
char* out_buffer = static_cast<char*>(buf);
diff --git a/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.h b/native_client_sdk/src/libraries/nacl_io/mount_node_http.h
index d864b2c..9ad2ab2 100644
--- a/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_http.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_HTTPFS_HTTP_FS_NODE_H_
-#define LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_NODE_H_
+#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_HTTP_H_
+#define LIBRARIES_NACL_IO_MOUNT_NODE_HTTP_H_
#include <map>
#include <string>
#include <vector>
#include "nacl_io/error.h"
-#include "nacl_io/node.h"
+#include "nacl_io/mount_node.h"
#include "nacl_io/pepper_interface.h"
namespace nacl_io {
typedef std::map<std::string, std::string> StringMap_t;
-class HttpFsNode : public Node {
+class MountNodeHttp : public MountNode {
public:
virtual Error FSync();
virtual Error GetDents(size_t offs,
@@ -40,9 +40,7 @@ class HttpFsNode : public Node {
void SetMode(int mode);
protected:
- HttpFsNode(Filesystem* filesystem,
- const std::string& url,
- bool cache_content);
+ MountNodeHttp(Mount* mount, const std::string& url, bool cache_content);
private:
Error GetStat_Locked(struct stat* stat);
@@ -91,9 +89,9 @@ class HttpFsNode : public Node {
bool has_cached_size_;
std::vector<char> cached_data_;
- friend class HttpFs;
+ friend class MountHttp;
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_NODE_H_
+#endif // LIBRARIES_NACL_IO_MOUNT_NODE_HTTP_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs_node.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_mem.cc
index e26c54e..50dafd7 100644
--- a/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_mem.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/memfs/mem_fs_node.h"
+#include "nacl_io/mount_node_mem.h"
#include <errno.h>
#include <string.h>
@@ -23,16 +23,17 @@ const size_t kMaxResizeIncrement = 16 * 1024 * 1024;
} // namespace
-MemFsNode::MemFsNode(Filesystem* filesystem) : Node(filesystem) {
+MountNodeMem::MountNodeMem(Mount* mount)
+ : MountNode(mount) {
SetType(S_IFREG);
}
-MemFsNode::~MemFsNode() {}
+MountNodeMem::~MountNodeMem() {}
-Error MemFsNode::Read(const HandleAttr& attr,
- void* buf,
- size_t count,
- int* out_bytes) {
+Error MountNodeMem::Read(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes) {
*out_bytes = 0;
AUTO_LOCK(node_lock_);
@@ -50,10 +51,10 @@ Error MemFsNode::Read(const HandleAttr& attr,
return 0;
}
-Error MemFsNode::Write(const HandleAttr& attr,
- const void* buf,
- size_t count,
- int* out_bytes) {
+Error MountNodeMem::Write(const HandleAttr& attr,
+ const void* buf,
+ size_t count,
+ int* out_bytes) {
*out_bytes = 0;
AUTO_LOCK(node_lock_);
@@ -70,13 +71,13 @@ Error MemFsNode::Write(const HandleAttr& attr,
return 0;
}
-Error MemFsNode::FTruncate(off_t new_size) {
+Error MountNodeMem::FTruncate(off_t new_size) {
AUTO_LOCK(node_lock_);
Resize(new_size);
return 0;
}
-void MemFsNode::Resize(off_t new_size) {
+void MountNodeMem::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/memfs/mem_fs_node.h b/native_client_sdk/src/libraries/nacl_io/mount_node_mem.h
index 071f856..ef2ba49 100644
--- a/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs_node.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_mem.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_MEMFS_MEM_FS_NODE_H_
-#define LIBRARIES_NACL_IO_MEMFS_MEM_FS_NODE_H_
+#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_MEM_H_
+#define LIBRARIES_NACL_IO_MOUNT_NODE_MEM_H_
-#include "nacl_io/node.h"
+#include "nacl_io/mount_node.h"
#include <vector>
namespace nacl_io {
-class MemFsNode : public Node {
+class MountNodeMem : public MountNode {
public:
- explicit MemFsNode(Filesystem* filesystem);
+ explicit MountNodeMem(Mount* mount);
protected:
- virtual ~MemFsNode();
+ virtual ~MountNodeMem();
public:
// Normal read/write operations on a file
@@ -34,9 +34,9 @@ class MemFsNode : public Node {
void Resize(off_t size);
std::vector<char> data_;
- friend class MemFs;
+ friend class MountMem;
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_MEMFS_MEM_FS_NODE_H_
+#endif // LIBRARIES_NACL_IO_MOUNT_NODE_MEM_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
new file mode 100644
index 0000000..cc27a1f
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_pipe.cc
@@ -0,0 +1,62 @@
+// 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
new file mode 100644
index 0000000..a109af9
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_pipe.h
@@ -0,0 +1,36 @@
+// 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/socket/socket_node.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc
index e3baabc..d137e07 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/socket_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc
@@ -2,16 +2,15 @@
// 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"
@@ -19,8 +18,8 @@
namespace nacl_io {
-SocketNode::SocketNode(Filesystem* filesystem)
- : StreamNode(filesystem),
+MountNodeSocket::MountNodeSocket(Mount* mount)
+ : MountNodeStream(mount),
socket_resource_(0),
local_addr_(0),
remote_addr_(0),
@@ -31,8 +30,8 @@ SocketNode::SocketNode(Filesystem* filesystem)
SetType(S_IFSOCK);
}
-SocketNode::SocketNode(Filesystem* filesystem, PP_Resource socket)
- : StreamNode(filesystem),
+MountNodeSocket::MountNodeSocket(Mount* mount, PP_Resource socket)
+ : MountNodeStream(mount),
socket_resource_(socket),
local_addr_(0),
remote_addr_(0),
@@ -41,16 +40,16 @@ SocketNode::SocketNode(Filesystem* filesystem, PP_Resource socket)
keep_alive_(false) {
memset(&linger_, 0, sizeof(linger_));
SetType(S_IFSOCK);
- filesystem_->ppapi()->AddRefResource(socket_resource_);
+ mount_->ppapi()->AddRefResource(socket_resource_);
}
-void SocketNode::Destroy() {
+void MountNodeSocket::Destroy() {
if (socket_resource_)
- filesystem_->ppapi()->ReleaseResource(socket_resource_);
+ mount_->ppapi()->ReleaseResource(socket_resource_);
if (local_addr_)
- filesystem_->ppapi()->ReleaseResource(local_addr_);
+ mount_->ppapi()->ReleaseResource(local_addr_);
if (remote_addr_)
- filesystem_->ppapi()->ReleaseResource(remote_addr_);
+ mount_->ppapi()->ReleaseResource(remote_addr_);
socket_resource_ = 0;
local_addr_ = 0;
@@ -58,54 +57,55 @@ void SocketNode::Destroy() {
}
// Assume that |addr| and |out_addr| are non-NULL.
-Error SocketNode::MMap(void* addr,
- size_t length,
- int prot,
- int flags,
- size_t offset,
- void** out_addr) {
+Error MountNodeSocket::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 SocketNode::Read(const HandleAttr& attr,
- void* buf,
- size_t count,
- int* out_bytes) {
+Error MountNodeSocket::Read(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes) {
return Recv(attr, buf, count, 0, out_bytes);
}
-Error SocketNode::Write(const HandleAttr& attr,
- const void* buf,
- size_t count,
- int* out_bytes) {
+Error MountNodeSocket::Write(const HandleAttr& attr,
+ const void* buf,
+ size_t count,
+ int* out_bytes) {
return Send(attr, buf, count, 0, out_bytes);
}
-NetAddressInterface* SocketNode::NetInterface() {
- if (filesystem_->ppapi() == NULL)
+
+NetAddressInterface* MountNodeSocket::NetInterface() {
+ if (mount_->ppapi() == NULL)
return NULL;
- return filesystem_->ppapi()->GetNetAddressInterface();
+ return mount_->ppapi()->GetNetAddressInterface();
}
-TCPSocketInterface* SocketNode::TCPInterface() {
- if (filesystem_->ppapi() == NULL)
+TCPSocketInterface* MountNodeSocket::TCPInterface() {
+ if (mount_->ppapi() == NULL)
return NULL;
- return filesystem_->ppapi()->GetTCPSocketInterface();
+ return mount_->ppapi()->GetTCPSocketInterface();
}
-UDPSocketInterface* SocketNode::UDPInterface() {
- if (filesystem_->ppapi() == NULL)
+UDPSocketInterface* MountNodeSocket::UDPInterface() {
+ if (mount_->ppapi() == NULL)
return NULL;
- return filesystem_->ppapi()->GetUDPSocketInterface();
+ return mount_->ppapi()->GetUDPSocketInterface();
}
-PP_Resource SocketNode::SockAddrToResource(const struct sockaddr* addr,
- socklen_t len) {
+PP_Resource MountNodeSocket::SockAddrToResource(const struct sockaddr* addr,
+ socklen_t len) {
if (NULL == addr)
return 0;
@@ -120,9 +120,8 @@ PP_Resource SocketNode::SockAddrToResource(const struct sockaddr* addr,
addr4.port = sin->sin_port;
memcpy(addr4.addr, &sin->sin_addr, sizeof(addr4.addr));
- return filesystem_->ppapi()
- ->GetNetAddressInterface()
- ->CreateFromIPv4Address(filesystem_->ppapi()->GetInstance(), &addr4);
+ return mount_->ppapi()->GetNetAddressInterface()->CreateFromIPv4Address(
+ mount_->ppapi()->GetInstance(), &addr4);
}
if (AF_INET6 == addr->sa_family) {
@@ -136,16 +135,16 @@ PP_Resource SocketNode::SockAddrToResource(const struct sockaddr* addr,
addr6.port = sin->sin6_port;
memcpy(addr6.addr, &sin->sin6_addr, sizeof(addr6.addr));
- return filesystem_->ppapi()
- ->GetNetAddressInterface()
- ->CreateFromIPv6Address(filesystem_->ppapi()->GetInstance(), &addr6);
+ return mount_->ppapi()->GetNetAddressInterface()->CreateFromIPv6Address(
+ mount_->ppapi()->GetInstance(), &addr6);
}
return 0;
}
-socklen_t SocketNode::ResourceToSockAddr(PP_Resource addr,
- socklen_t len,
- struct sockaddr* out_addr) {
+
+socklen_t MountNodeSocket::ResourceToSockAddr(PP_Resource addr,
+ socklen_t len,
+ struct sockaddr* out_addr) {
if (0 == addr)
return 0;
@@ -177,7 +176,8 @@ socklen_t SocketNode::ResourceToSockAddr(PP_Resource addr,
return 0;
}
-bool SocketNode::IsEquivalentAddress(PP_Resource addr1, PP_Resource addr2) {
+bool MountNodeSocket::IsEquivalentAddress(PP_Resource addr1,
+ PP_Resource addr2) {
if (addr1 == addr2)
return true;
@@ -196,16 +196,16 @@ bool SocketNode::IsEquivalentAddress(PP_Resource addr1, PP_Resource addr2) {
return memcmp(saddr1, saddr2, len1) == 0;
}
-Error SocketNode::Accept(const HandleAttr& attr,
- PP_Resource* new_sock,
- struct sockaddr* addr,
- socklen_t* len) {
+Error MountNodeSocket::Accept(const HandleAttr& attr,
+ PP_Resource* new_sock,
+ struct sockaddr* addr,
+ socklen_t* len) {
return ENOSYS;
}
-Error SocketNode::Connect(const HandleAttr& attr,
- const struct sockaddr* addr,
- socklen_t len) {
+Error MountNodeSocket::Connect(const HandleAttr& attr,
+ const struct sockaddr* addr,
+ socklen_t len) {
if (len < 1)
return EINVAL;
@@ -215,12 +215,14 @@ Error SocketNode::Connect(const HandleAttr& attr,
return EOPNOTSUPP;
}
-Error SocketNode::Listen(int backlog) { return EOPNOTSUPP; }
+Error MountNodeSocket::Listen(int backlog) {
+ return EOPNOTSUPP;
+}
-Error SocketNode::GetSockOpt(int lvl,
- int optname,
- void* optval,
- socklen_t* len) {
+Error MountNodeSocket::GetSockOpt(int lvl,
+ int optname,
+ void* optval,
+ socklen_t* len) {
if (lvl != SOL_SOCKET)
return ENOPROTOOPT;
@@ -256,16 +258,17 @@ Error SocketNode::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 SocketNode::SetSockOpt(int lvl,
- int optname,
- const void* optval,
- socklen_t len) {
+Error MountNodeSocket::SetSockOpt(int lvl,
+ int optname,
+ const void* optval,
+ socklen_t len) {
if (lvl != SOL_SOCKET)
return ENOPROTOOPT;
@@ -309,43 +312,43 @@ Error SocketNode::SetSockOpt(int lvl,
return ENOPROTOOPT;
}
-Error SocketNode::Bind(const struct sockaddr* addr, socklen_t len) {
+Error MountNodeSocket::Bind(const struct sockaddr* addr, socklen_t len) {
return EINVAL;
}
-Error SocketNode::Recv(const HandleAttr& attr,
- void* buf,
- size_t len,
- int flags,
- int* out_len) {
+Error MountNodeSocket::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 SocketNode::RecvFrom(const HandleAttr& attr,
- void* buf,
- size_t len,
- int flags,
- struct sockaddr* src_addr,
- socklen_t* addrlen,
- int* 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) {
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);
- filesystem_->ppapi()->ReleaseResource(addr);
+ mount_->ppapi()->ReleaseResource(addr);
}
return err;
}
-Error SocketNode::RecvHelper(const HandleAttr& attr,
- void* buf,
- size_t len,
- int flags,
- PP_Resource* addr,
- int* out_len) {
+Error MountNodeSocket::RecvHelper(const HandleAttr& attr,
+ void* buf,
+ size_t len,
+ int flags,
+ PP_Resource* addr,
+ int* out_len) {
if (0 == socket_resource_)
return EBADF;
@@ -353,8 +356,8 @@ Error SocketNode::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);
@@ -373,21 +376,21 @@ Error SocketNode::RecvHelper(const HandleAttr& attr,
return err;
}
-Error SocketNode::Send(const HandleAttr& attr,
- const void* buf,
- size_t len,
- int flags,
- int* out_len) {
+Error MountNodeSocket::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 SocketNode::SendTo(const HandleAttr& attr,
- const void* buf,
- size_t len,
- int flags,
- const struct sockaddr* dest_addr,
- socklen_t addrlen,
- int* 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) {
if ((NULL == dest_addr) && (0 == remote_addr_))
return EDESTADDRREQ;
@@ -396,16 +399,16 @@ Error SocketNode::SendTo(const HandleAttr& attr,
return EINVAL;
Error err = SendHelper(attr, buf, len, flags, addr, out_len);
- filesystem_->ppapi()->ReleaseResource(addr);
+ mount_->ppapi()->ReleaseResource(addr);
return err;
}
-Error SocketNode::SendHelper(const HandleAttr& attr,
- const void* buf,
- size_t len,
- int flags,
- PP_Resource addr,
- int* out_len) {
+Error MountNodeSocket::SendHelper(const HandleAttr& attr,
+ const void* buf,
+ size_t len,
+ int flags,
+ PP_Resource addr,
+ int* out_len) {
if (0 == socket_resource_)
return EBADF;
@@ -434,15 +437,18 @@ Error SocketNode::SendHelper(const HandleAttr& attr,
return err;
}
-void SocketNode::SetError_Locked(int pp_error_num) {
+void MountNodeSocket::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 SocketNode::Shutdown(int how) { return EOPNOTSUPP; }
+Error MountNodeSocket::Shutdown(int how) {
+ return EOPNOTSUPP;
+}
+
-Error SocketNode::GetPeerName(struct sockaddr* addr, socklen_t* len) {
+Error MountNodeSocket::GetPeerName(struct sockaddr* addr, socklen_t* len) {
if (NULL == addr || NULL == len)
return EFAULT;
@@ -455,7 +461,7 @@ Error SocketNode::GetPeerName(struct sockaddr* addr, socklen_t* len) {
return ENOTCONN;
}
-Error SocketNode::GetSockName(struct sockaddr* addr, socklen_t* len) {
+Error MountNodeSocket::GetSockName(struct sockaddr* addr, socklen_t* len) {
if (NULL == addr || NULL == len)
return EFAULT;
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/socket_node.h b/native_client_sdk/src/libraries/nacl_io/mount_node_socket.h
index fe3b3f06..3ecb3db 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/socket_node.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_socket.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_SOCKET_SOCKET_NODE_H_
-#define LIBRARIES_NACL_IO_SOCKET_SOCKET_NODE_H_
+#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_SOCKET_H_
+#define LIBRARIES_NACL_IO_MOUNT_NODE_SOCKET_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/filesystem.h"
-#include "nacl_io/node.h"
+#include "nacl_io/mount.h"
+#include "nacl_io/mount_node.h"
+#include "nacl_io/mount_node_stream.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 StreamFs;
-class SocketNode;
-typedef sdk_util::ScopedRef<SocketNode> ScopedSocketNode;
+class MountStream;
+class MountNodeSocket;
+typedef sdk_util::ScopedRef<MountNodeSocket> ScopedMountNodeSocket;
-class SocketNode : public StreamNode {
+class MountNodeSocket : public MountNodeStream {
public:
- explicit SocketNode(Filesystem* filesystem);
- SocketNode(Filesystem* filesystem, PP_Resource socket);
+ explicit MountNodeSocket(Mount* mount);
+ MountNodeSocket(Mount* mount, PP_Resource socket);
protected:
virtual void Destroy();
@@ -127,6 +127,7 @@ class SocketNode : public StreamNode {
PP_Resource* addr,
int* out_len);
+
// Per socket type send and recv
virtual Error Recv_Locked(void* buffer,
size_t len,
@@ -138,6 +139,7 @@ class SocketNode : public StreamNode {
PP_Resource addr,
int* out_len) = 0;
+
NetAddressInterface* NetInterface();
TCPSocketInterface* TCPInterface();
UDPSocketInterface* UDPInterface();
@@ -159,10 +161,10 @@ class SocketNode : public StreamNode {
struct linger linger_;
friend class KernelProxy;
- friend class StreamFs;
+ friend class MountStream;
};
} // namespace nacl_io
#endif // PROVIDES_SOCKET_API
-#endif // LIBRARIES_NACL_IO_SOCKET_SOCKET_NODE_H_
+#endif // LIBRARIES_NACL_IO_MOUNT_NODE_SOCKET_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
new file mode 100644
index 0000000..d38a69e
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_stream.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/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/stream/stream_node.h b/native_client_sdk/src/libraries/nacl_io/mount_node_stream.h
index 554fdf3..fedd5ab 100644
--- a/native_client_sdk/src/libraries/nacl_io/stream/stream_node.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_stream.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_STREAM_STREAM_NODE_H_
-#define LIBRARIES_NACL_IO_STREAM_STREAM_NODE_H_
+#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_STREAM_H_
+#define LIBRARIES_NACL_IO_MOUNT_NODE_STREAM_H_
#include <map>
#include <string>
-#include "nacl_io/node.h"
-#include "nacl_io/pipe/pipe_event_emitter.h"
+#include "nacl_io/event_emitter_pipe.h"
+#include "nacl_io/mount_node.h"
#include "sdk_util/atomicops.h"
namespace nacl_io {
-class StreamNode;
-class StreamFs;
+class MountNodeStream;
+class MountStream;
-typedef sdk_util::ScopedRef<StreamNode> ScopedStreamNode;
+typedef sdk_util::ScopedRef<MountNodeStream> ScopedMountNodeStream;
enum StreamStateFlags {
SSF_CONNECTING = 0x0001,
@@ -34,9 +34,10 @@ enum StreamStateFlags {
SSF_CLOSED = 0x8000
};
-class StreamNode : public Node {
+
+class MountNodeStream : public MountNode {
public:
- explicit StreamNode(Filesystem* fs);
+ explicit MountNodeStream(Mount* mnt);
virtual Error Init(int open_flags);
@@ -49,7 +50,7 @@ class StreamNode : public Node {
uint32_t GetStreamFlags();
bool TestStreamFlags(uint32_t bits);
- StreamFs* stream();
+ MountStream* mount_stream();
protected:
int read_timeout_;
@@ -61,4 +62,4 @@ class StreamNode : public Node {
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_STREAM_STREAM_NODE_H_
+#endif // LIBRARIES_NACL_IO_MOUNT_NODE_STREAM_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/tcp_node.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_tcp.cc
index d4f4122..1366eec11 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/tcp_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_tcp.cc
@@ -2,6 +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/ossocket.h"
#ifdef PROVIDES_SOCKET_API
@@ -11,40 +12,43 @@
#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 StreamFs::Work {
+class TCPWork : public MountStream::Work {
public:
- explicit TcpWork(const ScopedTcpEventEmitter& emitter)
- : StreamFs::Work(emitter->stream()->stream()),
+ explicit TCPWork(const ScopedEventEmitterTCP& emitter)
+ : MountStream::Work(emitter->stream()->mount_stream()),
emitter_(emitter),
- data_(NULL) {}
+ data_(NULL) {
+ }
- ~TcpWork() { delete[] data_; }
+ ~TCPWork() {
+ delete[] data_;
+ }
TCPSocketInterface* TCPInterface() {
- return filesystem()->ppapi()->GetTCPSocketInterface();
+ return mount()->ppapi()->GetTCPSocketInterface();
}
protected:
- ScopedTcpEventEmitter emitter_;
+ ScopedEventEmitterTCP emitter_;
char* data_;
};
-class TcpSendWork : public TcpWork {
+class TCPSendWork : public TCPWork {
public:
- explicit TcpSendWork(const ScopedTcpEventEmitter& emitter,
- const ScopedSocketNode& stream)
- : TcpWork(emitter), node_(stream) {}
+ explicit TCPSendWork(const ScopedEventEmitterTCP& emitter,
+ const ScopedMountNodeSocket& stream)
+ : TCPWork(emitter), node_(stream) {}
virtual bool Start(int32_t val) {
AUTO_LOCK(emitter_->GetLock());
@@ -68,7 +72,7 @@ class TcpSendWork : public TcpWork {
int err = TCPInterface()->Write(node_->socket_resource(),
data_,
capped_len,
- filesystem()->GetRunCompletion(this));
+ mount()->GetRunCompletion(this));
if (err != PP_OK_COMPLETIONPENDING) {
// Anything else, we should assume the socket has gone bad.
@@ -98,17 +102,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.
- ScopedSocketNode node_;
+ ScopedMountNodeSocket node_;
};
-class TcpRecvWork : public TcpWork {
+class TCPRecvWork : public TCPWork {
public:
- explicit TcpRecvWork(const ScopedTcpEventEmitter& emitter)
- : TcpWork(emitter) {}
+ explicit TCPRecvWork(const ScopedEventEmitterTCP& emitter)
+ : TCPWork(emitter) {}
virtual bool Start(int32_t val) {
AUTO_LOCK(emitter_->GetLock());
- TcpNode* stream = static_cast<TcpNode*>(emitter_->stream());
+ MountNodeTCP* stream = static_cast<MountNodeTCP*>(emitter_->stream());
// Does the stream exist, and can it recv?
if (NULL == stream || !stream->TestStreamFlags(SSF_CAN_RECV))
@@ -129,7 +133,7 @@ class TcpRecvWork : public TcpWork {
int err = TCPInterface()->Read(stream->socket_resource(),
data_,
capped_len,
- filesystem()->GetRunCompletion(this));
+ mount()->GetRunCompletion(this));
if (err != PP_OK_COMPLETIONPENDING) {
// Anything else, we should assume the socket has gone bad.
stream->SetError_Locked(err);
@@ -142,7 +146,7 @@ class TcpRecvWork : public TcpWork {
virtual void Run(int32_t length_error) {
AUTO_LOCK(emitter_->GetLock());
- TcpNode* stream = static_cast<TcpNode*>(emitter_->stream());
+ MountNodeTCP* stream = static_cast<MountNodeTCP*>(emitter_->stream());
if (!stream)
return;
@@ -159,18 +163,20 @@ class TcpRecvWork : public TcpWork {
}
};
-class TCPAcceptWork : public StreamFs::Work {
+class TCPAcceptWork : public MountStream::Work {
public:
- explicit TCPAcceptWork(StreamFs* stream, const ScopedTcpEventEmitter& emitter)
- : StreamFs::Work(stream), emitter_(emitter) {}
+ explicit TCPAcceptWork(MountStream* stream,
+ const ScopedEventEmitterTCP& emitter)
+ : MountStream::Work(stream),
+ emitter_(emitter) {}
TCPSocketInterface* TCPInterface() {
- return filesystem()->ppapi()->GetTCPSocketInterface();
+ return mount()->ppapi()->GetTCPSocketInterface();
}
virtual bool Start(int32_t val) {
AUTO_LOCK(emitter_->GetLock());
- TcpNode* node = static_cast<TcpNode*>(emitter_->stream());
+ MountNodeTCP* node = static_cast<MountNodeTCP*>(emitter_->stream());
// Does the stream exist, and can it accept?
if (NULL == node)
@@ -182,7 +188,7 @@ class TCPAcceptWork : public StreamFs::Work {
int err = TCPInterface()->Accept(node->socket_resource(),
&new_socket_,
- filesystem()->GetRunCompletion(this));
+ mount()->GetRunCompletion(this));
if (err != PP_OK_COMPLETIONPENDING) {
// Anything else, we should assume the socket has gone bad.
@@ -195,7 +201,7 @@ class TCPAcceptWork : public StreamFs::Work {
virtual void Run(int32_t error) {
AUTO_LOCK(emitter_->GetLock());
- TcpNode* node = static_cast<TcpNode*>(emitter_->stream());
+ MountNodeTCP* node = static_cast<MountNodeTCP*>(emitter_->stream());
if (node == NULL)
return;
@@ -210,22 +216,23 @@ class TCPAcceptWork : public StreamFs::Work {
protected:
PP_Resource new_socket_;
- ScopedTcpEventEmitter emitter_;
+ ScopedEventEmitterTCP emitter_;
};
-class TCPConnectWork : public StreamFs::Work {
+class TCPConnectWork : public MountStream::Work {
public:
- explicit TCPConnectWork(StreamFs* stream,
- const ScopedTcpEventEmitter& emitter)
- : StreamFs::Work(stream), emitter_(emitter) {}
+ explicit TCPConnectWork(MountStream* stream,
+ const ScopedEventEmitterTCP& emitter)
+ : MountStream::Work(stream),
+ emitter_(emitter) {}
TCPSocketInterface* TCPInterface() {
- return filesystem()->ppapi()->GetTCPSocketInterface();
+ return mount()->ppapi()->GetTCPSocketInterface();
}
virtual bool Start(int32_t val) {
AUTO_LOCK(emitter_->GetLock());
- TcpNode* node = static_cast<TcpNode*>(emitter_->stream());
+ MountNodeTCP* node = static_cast<MountNodeTCP*>(emitter_->stream());
// Does the stream exist, and can it connect?
if (NULL == node)
@@ -233,7 +240,7 @@ class TCPConnectWork : public StreamFs::Work {
int err = TCPInterface()->Connect(node->socket_resource(),
node->remote_addr(),
- filesystem()->GetRunCompletion(this));
+ mount()->GetRunCompletion(this));
if (err != PP_OK_COMPLETIONPENDING) {
// Anything else, we should assume the socket has gone bad.
node->SetError_Locked(err);
@@ -245,7 +252,7 @@ class TCPConnectWork : public StreamFs::Work {
virtual void Run(int32_t error) {
AUTO_LOCK(emitter_->GetLock());
- TcpNode* node = static_cast<TcpNode*>(emitter_->stream());
+ MountNodeTCP* node = static_cast<MountNodeTCP*>(emitter_->stream());
if (node == NULL)
return;
@@ -260,30 +267,30 @@ class TCPConnectWork : public StreamFs::Work {
}
protected:
- ScopedTcpEventEmitter emitter_;
+ ScopedEventEmitterTCP emitter_;
};
-TcpNode::TcpNode(Filesystem* filesystem)
- : SocketNode(filesystem),
- emitter_(new TcpEventEmitter(kDefaultFifoSize, kDefaultFifoSize)),
+MountNodeTCP::MountNodeTCP(Mount* mount)
+ : MountNodeSocket(mount),
+ emitter_(new EventEmitterTCP(kDefaultFifoSize, kDefaultFifoSize)),
tcp_nodelay_(false) {
emitter_->AttachStream(this);
}
-TcpNode::TcpNode(Filesystem* filesystem, PP_Resource socket)
- : SocketNode(filesystem, socket),
- emitter_(new TcpEventEmitter(kDefaultFifoSize, kDefaultFifoSize)),
+MountNodeTCP::MountNodeTCP(Mount* mount, PP_Resource socket)
+ : MountNodeSocket(mount, socket),
+ emitter_(new EventEmitterTCP(kDefaultFifoSize, kDefaultFifoSize)),
tcp_nodelay_(false) {
emitter_->AttachStream(this);
}
-void TcpNode::Destroy() {
+void MountNodeTCP::Destroy() {
emitter_->DetachStream();
- SocketNode::Destroy();
+ MountNodeSocket::Destroy();
}
-Error TcpNode::Init(int open_flags) {
- Error err = SocketNode::Init(open_flags);
+Error MountNodeTCP::Init(int open_flags) {
+ Error err = MountNodeSocket::Init(open_flags);
if (err != 0)
return err;
@@ -297,8 +304,7 @@ Error TcpNode::Init(int open_flags) {
remote_addr_ = TCPInterface()->GetRemoteAddress(socket_resource_);
ConnectDone_Locked();
} else {
- socket_resource_ =
- TCPInterface()->Create(filesystem_->ppapi()->GetInstance());
+ socket_resource_ = TCPInterface()->Create(mount_->ppapi()->GetInstance());
if (0 == socket_resource_)
return EACCES;
SetStreamFlags(SSF_CAN_CONNECT);
@@ -307,14 +313,19 @@ Error TcpNode::Init(int open_flags) {
return 0;
}
-EventEmitter* TcpNode::GetEventEmitter() { return emitter_.get(); }
+EventEmitter* MountNodeTCP::GetEventEmitter() {
+ return emitter_.get();
+}
-void TcpNode::SetError_Locked(int pp_error_num) {
- SocketNode::SetError_Locked(pp_error_num);
+void MountNodeTCP::SetError_Locked(int pp_error_num) {
+ MountNodeSocket::SetError_Locked(pp_error_num);
emitter_->SetError_Locked();
}
-Error TcpNode::GetSockOpt(int lvl, int optname, void* optval, socklen_t* len) {
+Error MountNodeTCP::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_;
@@ -325,25 +336,25 @@ Error TcpNode::GetSockOpt(int lvl, int optname, void* optval, socklen_t* len) {
return 0;
}
- return SocketNode::GetSockOpt(lvl, optname, optval, len);
+ return MountNodeSocket::GetSockOpt(lvl, optname, optval, len);
}
-Error TcpNode::SetNoDelay_Locked() {
+
+Error MountNodeTCP::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 TcpNode::SetSockOpt(int lvl,
- int optname,
- const void* optval,
- socklen_t len) {
+Error MountNodeTCP::SetSockOpt(int lvl,
+ int optname,
+ const void* optval,
+ socklen_t len) {
if (lvl == IPPROTO_TCP && optname == TCP_NODELAY) {
if (len < sizeof(int))
return EINVAL;
@@ -352,25 +363,25 @@ Error TcpNode::SetSockOpt(int lvl,
return SetNoDelay_Locked();
}
- return SocketNode::SetSockOpt(lvl, optname, optval, len);
+ return MountNodeSocket::SetSockOpt(lvl, optname, optval, len);
}
-void TcpNode::QueueAccept() {
- StreamFs::Work* work = new TCPAcceptWork(stream(), emitter_);
- stream()->EnqueueWork(work);
+void MountNodeTCP::QueueAccept() {
+ MountStream::Work* work = new TCPAcceptWork(mount_stream(), emitter_);
+ mount_stream()->EnqueueWork(work);
}
-void TcpNode::QueueConnect() {
- StreamFs::Work* work = new TCPConnectWork(stream(), emitter_);
- stream()->EnqueueWork(work);
+void MountNodeTCP::QueueConnect() {
+ MountStream::Work* work = new TCPConnectWork(mount_stream(), emitter_);
+ mount_stream()->EnqueueWork(work);
}
-void TcpNode::QueueInput() {
- StreamFs::Work* work = new TcpRecvWork(emitter_);
- stream()->EnqueueWork(work);
+void MountNodeTCP::QueueInput() {
+ MountStream::Work* work = new TCPRecvWork(emitter_);
+ mount_stream()->EnqueueWork(work);
}
-void TcpNode::QueueOutput() {
+void MountNodeTCP::QueueOutput() {
if (TestStreamFlags(SSF_SENDING))
return;
@@ -380,14 +391,15 @@ void TcpNode::QueueOutput() {
if (0 == emitter_->BytesInOutputFIFO())
return;
- StreamFs::Work* work = new TcpSendWork(emitter_, ScopedSocketNode(this));
- stream()->EnqueueWork(work);
+ MountStream::Work* work = new TCPSendWork(emitter_,
+ ScopedMountNodeSocket(this));
+ mount_stream()->EnqueueWork(work);
}
-Error TcpNode::Accept(const HandleAttr& attr,
- PP_Resource* out_sock,
- struct sockaddr* addr,
- socklen_t* len) {
+Error MountNodeTCP::Accept(const HandleAttr& attr,
+ PP_Resource* out_sock,
+ struct sockaddr* addr,
+ socklen_t* len) {
EventListenerLock wait(GetEventEmitter());
if (!TestStreamFlags(SSF_LISTENING))
@@ -412,7 +424,7 @@ Error TcpNode::Accept(const HandleAttr& attr,
// Set the out paramaters
PP_Resource remote_addr = TCPInterface()->GetRemoteAddress(*out_sock);
*len = ResourceToSockAddr(remote_addr, *len, addr);
- filesystem_->ppapi()->ReleaseResource(remote_addr);
+ mount_->ppapi()->ReleaseResource(remote_addr);
QueueAccept();
return 0;
@@ -422,7 +434,7 @@ Error TcpNode::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 TcpNode::Bind(const struct sockaddr* addr, socklen_t len) {
+Error MountNodeTCP::Bind(const struct sockaddr* addr, socklen_t len) {
AUTO_LOCK(node_lock_);
/* Only bind once. */
@@ -430,12 +442,13 @@ Error TcpNode::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) {
- filesystem_->ppapi()->ReleaseResource(local_addr_);
+ mount_->ppapi()->ReleaseResource(local_addr_);
local_addr_ = 0;
return PPErrorToErrno(err);
}
@@ -443,9 +456,9 @@ Error TcpNode::Bind(const struct sockaddr* addr, socklen_t len) {
return 0;
}
-Error TcpNode::Connect(const HandleAttr& attr,
- const struct sockaddr* addr,
- socklen_t len) {
+Error MountNodeTCP::Connect(const HandleAttr& attr,
+ const struct sockaddr* addr,
+ socklen_t len) {
EventListenerLock wait(GetEventEmitter());
if (TestStreamFlags(SSF_CONNECTING))
@@ -477,7 +490,7 @@ Error TcpNode::Connect(const HandleAttr& attr,
return 0;
}
-Error TcpNode::Shutdown(int how) {
+Error MountNodeTCP::Shutdown(int how) {
AUTO_LOCK(node_lock_);
if (!IsConnected())
return ENOTCONN;
@@ -488,7 +501,7 @@ Error TcpNode::Shutdown(int how) {
return 0;
}
-void TcpNode::ConnectDone_Locked() {
+void MountNodeTCP::ConnectDone_Locked() {
local_addr_ = TCPInterface()->GetLocalAddress(socket_resource_);
// Now that we are connected, we can start sending and receiving.
@@ -505,18 +518,19 @@ void TcpNode::ConnectDone_Locked() {
QueueInput();
}
-void TcpNode::ConnectFailed_Locked() {
- filesystem_->ppapi()->ReleaseResource(remote_addr_);
+void MountNodeTCP::ConnectFailed_Locked() {
+ mount_->ppapi()->ReleaseResource(remote_addr_);
remote_addr_ = 0;
}
-Error TcpNode::Listen(int backlog) {
+Error MountNodeTCP::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);
@@ -527,24 +541,24 @@ Error TcpNode::Listen(int backlog) {
return 0;
}
-Error TcpNode::Recv_Locked(void* buf,
- size_t len,
- PP_Resource* out_addr,
- int* out_len) {
+Error MountNodeTCP::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.
- filesystem_->ppapi()->AddRefResource(remote_addr_);
+ mount_->ppapi()->AddRefResource(remote_addr_);
return 0;
}
// TCP ignores dst addr passed to send_to, and always uses bound address
-Error TcpNode::Send_Locked(const void* buf,
- size_t len,
- PP_Resource,
- int* out_len) {
+Error MountNodeTCP::Send_Locked(const void* buf,
+ size_t len,
+ PP_Resource,
+ int* out_len) {
assert(emitter_.get());
if (emitter_->GetError_Locked())
return EPIPE;
@@ -552,6 +566,7 @@ Error TcpNode::Send_Locked(const void* buf,
return 0;
}
+
} // namespace nacl_io
#endif // PROVIDES_SOCKET_API
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/tcp_node.h b/native_client_sdk/src/libraries/nacl_io/mount_node_tcp.h
index 6b2686c..6b45bc4 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/tcp_node.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_tcp.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_SOCKET_TCP_NODE_H_
-#define LIBRARIES_NACL_IO_SOCKET_TCP_NODE_H_
+#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_TCP_H_
+#define LIBRARIES_NACL_IO_MOUNT_NODE_TCP_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/node.h"
-#include "nacl_io/socket/socket_node.h"
-#include "nacl_io/socket/tcp_event_emitter.h"
+#include "nacl_io/event_emitter_tcp.h"
+#include "nacl_io/mount_node.h"
+#include "nacl_io/mount_node_socket.h"
namespace nacl_io {
-class TcpNode : public SocketNode {
+class MountNodeTCP : public MountNodeSocket {
public:
- explicit TcpNode(Filesystem* filesystem);
- TcpNode(Filesystem* filesystem, PP_Resource socket);
+ explicit MountNodeTCP(Mount* mount);
+ MountNodeTCP(Mount* mount, PP_Resource socket);
protected:
virtual Error Init(int open_flags);
@@ -42,7 +42,10 @@ class TcpNode : public SocketNode {
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,
@@ -66,12 +69,13 @@ class TcpNode : public SocketNode {
PP_Resource addr,
int* out_len);
- ScopedTcpEventEmitter emitter_;
+ ScopedEventEmitterTCP emitter_;
PP_Resource accepted_socket_;
bool tcp_nodelay_;
};
+
} // namespace nacl_io
#endif // PROVIDES_SOCKET_API
-#endif // LIBRARIES_NACL_IO_SOCKET_TCP_NODE_H_
+#endif // LIBRARIES_NACL_IO_MOUNT_NODE_TCP_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/devfs/tty_node.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_tty.cc
index 9173f12..48581c46 100644
--- a/native_client_sdk/src/libraries/nacl_io/devfs/tty_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_tty.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/devfs/tty_node.h"
+#include "nacl_io/mount_node_tty.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 {
-TtyNode::TtyNode(Filesystem* filesystem)
- : CharNode(filesystem),
+MountNodeTty::MountNodeTty(Mount* mount)
+ : MountNodeCharDevice(mount),
emitter_(new EventEmitter),
rows_(DEFAULT_TTY_ROWS),
cols_(DEFAULT_TTY_COLS) {
@@ -46,7 +46,7 @@ TtyNode::TtyNode(Filesystem* filesystem)
emitter_->RaiseEvents_Locked(POLLOUT);
}
-void TtyNode::InitTermios() {
+void MountNodeTty::InitTermios() {
// Some sane values that produce good result.
termios_.c_iflag = ICRNL | IXON | IXOFF | IUTF8;
termios_.c_oflag = OPOST | ONLCR;
@@ -74,12 +74,14 @@ void TtyNode::InitTermios() {
termios_.c_cc[VEOL2] = 0;
}
-EventEmitter* TtyNode::GetEventEmitter() { return emitter_.get(); }
+EventEmitter* MountNodeTty::GetEventEmitter() {
+ return emitter_.get();
+}
-Error TtyNode::Write(const HandleAttr& attr,
- const void* buf,
- size_t count,
- int* out_bytes) {
+Error MountNodeTty::Write(const HandleAttr& attr,
+ const void* buf,
+ size_t count,
+ int* out_bytes) {
AUTO_LOCK(output_lock_);
*out_bytes = 0;
@@ -87,8 +89,9 @@ Error TtyNode::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.
@@ -99,10 +102,11 @@ Error TtyNode::Write(const HandleAttr& attr,
return 0;
}
-Error TtyNode::Read(const HandleAttr& attr,
- void* buf,
- size_t count,
- int* out_bytes) {
+
+Error MountNodeTty::Read(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes) {
EventListenerLock wait(GetEventEmitter());
*out_bytes = 0;
@@ -114,8 +118,9 @@ Error TtyNode::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
@@ -124,9 +129,9 @@ Error TtyNode::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(),
@@ -137,8 +142,8 @@ Error TtyNode::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;
@@ -148,7 +153,7 @@ Error TtyNode::Read(const HandleAttr& attr,
return 0;
}
-Error TtyNode::Echo(const char* string, int count) {
+Error MountNodeTty::Echo(const char* string, int count) {
int wrote;
HandleAttr data;
Error error = Write(data, string, count, &wrote);
@@ -161,7 +166,7 @@ Error TtyNode::Echo(const char* string, int count) {
return 0;
}
-Error TtyNode::ProcessInput(struct tioc_nacl_input_string* message) {
+Error MountNodeTty::ProcessInput(struct tioc_nacl_input_string* message) {
AUTO_LOCK(emitter_->GetLock())
const char* buffer = message->buffer;
@@ -228,7 +233,7 @@ Error TtyNode::ProcessInput(struct tioc_nacl_input_string* message) {
return 0;
}
-Error TtyNode::VIoctl(int request, va_list args) {
+Error MountNodeTty::VIoctl(int request, va_list args) {
switch (request) {
case TIOCNACLOUTPUT: {
struct tioc_nacl_output* arg = va_arg(args, struct tioc_nacl_output*);
@@ -246,7 +251,7 @@ Error TtyNode::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: {
@@ -279,17 +284,17 @@ Error TtyNode::VIoctl(int request, va_list args) {
return EINVAL;
}
-Error TtyNode::Tcgetattr(struct termios* termios_p) {
+Error MountNodeTty::Tcgetattr(struct termios* termios_p) {
AUTO_LOCK(node_lock_);
*termios_p = termios_;
return 0;
}
-Error TtyNode::Tcsetattr(int optional_actions,
- const struct termios* termios_p) {
+Error MountNodeTty::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/devfs/tty_node.h b/native_client_sdk/src/libraries/nacl_io/mount_node_tty.h
index 72045e8..b47396f 100644
--- a/native_client_sdk/src/libraries/nacl_io/devfs/tty_node.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_tty.h
@@ -2,23 +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_DEVFS_TTY_NODE_H_
-#define LIBRARIES_NACL_IO_DEVFS_TTY_NODE_H_
+#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_TTY_H_
+#define LIBRARIES_NACL_IO_MOUNT_NODE_TTY_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 TtyNode : public CharNode {
+class MountNodeTty : public MountNodeCharDevice {
public:
- explicit TtyNode(Filesystem* filesystem);
+ explicit MountNodeTty(Mount* mount);
virtual EventEmitter* GetEventEmitter();
@@ -36,7 +37,7 @@ class TtyNode : public CharNode {
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_;
@@ -60,6 +61,6 @@ class TtyNode : public CharNode {
sdk_util::SimpleLock output_lock_;
};
-} // namespace nacl_io
+}
-#endif // LIBRARIES_NACL_IO_DEVFS_TTY_NODE_H_
+#endif
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_udp.cc
index a0f759c..c35a8f5 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_udp.cc
@@ -2,48 +2,52 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "nacl_io/socket/udp_node.h"
+
+#include "nacl_io/mount_node_udp.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 StreamFs::Work {
+class UDPWork : public MountStream::Work {
public:
- explicit UdpWork(const ScopedUdpEventEmitter& emitter)
- : StreamFs::Work(emitter->stream()->stream()),
+ explicit UDPWork(const ScopedEventEmitterUDP& emitter)
+ : MountStream::Work(emitter->stream()->mount_stream()),
emitter_(emitter),
- packet_(NULL) {}
+ packet_(NULL) {
+ }
- ~UdpWork() { delete packet_; }
+ ~UDPWork() {
+ delete packet_;
+ }
UDPSocketInterface* UDPInterface() {
- return filesystem()->ppapi()->GetUDPSocketInterface();
+ return mount()->ppapi()->GetUDPSocketInterface();
}
protected:
- ScopedUdpEventEmitter emitter_;
+ ScopedEventEmitterUDP emitter_;
Packet* packet_;
};
-class UdpSendWork : public UdpWork {
+class UDPSendWork : public UDPWork {
public:
- explicit UdpSendWork(const ScopedUdpEventEmitter& emitter,
- const ScopedSocketNode& node)
- : UdpWork(emitter), node_(node) {}
+ explicit UDPSendWork(const ScopedEventEmitterUDP& emitter,
+ const ScopedMountNodeSocket& node)
+ : UDPWork(emitter), node_(node) {}
virtual bool Start(int32_t val) {
AUTO_LOCK(emitter_->GetLock());
@@ -60,7 +64,7 @@ class UdpSendWork : public UdpWork {
packet_->buffer(),
packet_->len(),
packet_->addr(),
- filesystem()->GetRunCompletion(this));
+ mount()->GetRunCompletion(this));
if (err != PP_OK_COMPLETIONPENDING) {
// Anything else, we should assume the socket has gone bad.
node_->SetError_Locked(err);
@@ -88,21 +92,24 @@ 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.
- ScopedSocketNode node_;
+ ScopedMountNodeSocket node_;
};
-class UdpRecvWork : public UdpWork {
+
+class UDPRecvWork : public UDPWork {
public:
- explicit UdpRecvWork(const ScopedUdpEventEmitter& emitter)
- : UdpWork(emitter) {
+ explicit UDPRecvWork(const ScopedEventEmitterUDP& emitter)
+ : UDPWork(emitter) {
data_ = new char[kMaxPacketSize];
}
- ~UdpRecvWork() { delete[] data_; }
+ ~UDPRecvWork() {
+ delete[] data_;
+ }
virtual bool Start(int32_t val) {
AUTO_LOCK(emitter_->GetLock());
- UdpNode* stream = static_cast<UdpNode*>(emitter_->stream());
+ MountNodeUDP* stream = static_cast<MountNodeUDP*>(emitter_->stream());
// Does the stream exist, and can it recv?
if (NULL == stream || !stream->TestStreamFlags(SSF_CAN_RECV))
@@ -117,7 +124,7 @@ class UdpRecvWork : public UdpWork {
data_,
kMaxPacketSize,
&addr_,
- filesystem()->GetRunCompletion(this));
+ mount()->GetRunCompletion(this));
if (err != PP_OK_COMPLETIONPENDING) {
stream->SetError_Locked(err);
return false;
@@ -128,13 +135,13 @@ class UdpRecvWork : public UdpWork {
virtual void Run(int32_t length_error) {
AUTO_LOCK(emitter_->GetLock());
- UdpNode* stream = static_cast<UdpNode*>(emitter_->stream());
+ MountNodeUDP* stream = static_cast<MountNodeUDP*>(emitter_->stream());
if (NULL == stream)
return;
// On successful receive we queue more input
if (length_error > 0) {
- Packet* packet = new Packet(filesystem()->ppapi());
+ Packet* packet = new Packet(mount()->ppapi());
packet->Copy(data_, length_error, addr_);
emitter_->WriteRXPacket_Locked(packet);
stream->ClearStreamFlags(SSF_RECVING);
@@ -149,52 +156,54 @@ class UdpRecvWork : public UdpWork {
PP_Resource addr_;
};
-UdpNode::UdpNode(Filesystem* filesystem)
- : SocketNode(filesystem),
- emitter_(new UdpEventEmitter(kDefaultFifoSize, kDefaultFifoSize)) {
+
+MountNodeUDP::MountNodeUDP(Mount* mount)
+ : MountNodeSocket(mount),
+ emitter_(new EventEmitterUDP(kDefaultFifoSize, kDefaultFifoSize)) {
emitter_->AttachStream(this);
}
-void UdpNode::Destroy() {
+void MountNodeUDP::Destroy() {
emitter_->DetachStream();
- SocketNode::Destroy();
+ MountNodeSocket::Destroy();
}
-UdpEventEmitter* UdpNode::GetEventEmitter() { return emitter_.get(); }
+EventEmitterUDP* MountNodeUDP::GetEventEmitter() {
+ return emitter_.get();
+}
-Error UdpNode::Init(int open_flags) {
- Error err = SocketNode::Init(open_flags);
+Error MountNodeUDP::Init(int open_flags) {
+ Error err = MountNodeSocket::Init(open_flags);
if (err != 0)
return err;
if (UDPInterface() == NULL)
return EACCES;
- socket_resource_ =
- UDPInterface()->Create(filesystem_->ppapi()->GetInstance());
+ socket_resource_ = UDPInterface()->Create(mount_->ppapi()->GetInstance());
if (0 == socket_resource_)
return EACCES;
return 0;
}
-void UdpNode::QueueInput() {
- UdpRecvWork* work = new UdpRecvWork(emitter_);
- stream()->EnqueueWork(work);
+void MountNodeUDP::QueueInput() {
+ UDPRecvWork* work = new UDPRecvWork(emitter_);
+ mount_stream()->EnqueueWork(work);
}
-void UdpNode::QueueOutput() {
+void MountNodeUDP::QueueOutput() {
if (!TestStreamFlags(SSF_CAN_SEND))
return;
if (TestStreamFlags(SSF_SENDING))
return;
- UdpSendWork* work = new UdpSendWork(emitter_, ScopedSocketNode(this));
- stream()->EnqueueWork(work);
+ UDPSendWork* work = new UDPSendWork(emitter_, ScopedMountNodeSocket(this));
+ mount_stream()->EnqueueWork(work);
}
-Error UdpNode::Bind(const struct sockaddr* addr, socklen_t len) {
+Error MountNodeUDP::Bind(const struct sockaddr* addr, socklen_t len) {
if (0 == socket_resource_)
return EBADF;
@@ -206,9 +215,10 @@ Error UdpNode::Bind(const struct sockaddr* addr, socklen_t len) {
if (0 == out_addr)
return EINVAL;
- int err =
- UDPInterface()->Bind(socket_resource_, out_addr, PP_BlockUntilComplete());
- filesystem_->ppapi()->ReleaseResource(out_addr);
+ int err = UDPInterface()->Bind(socket_resource_,
+ out_addr,
+ PP_BlockUntilComplete());
+ mount_->ppapi()->ReleaseResource(out_addr);
if (err != 0)
return PPErrorToErrno(err);
@@ -225,15 +235,15 @@ Error UdpNode::Bind(const struct sockaddr* addr, socklen_t len) {
return 0;
}
-Error UdpNode::Connect(const HandleAttr& attr,
- const struct sockaddr* addr,
- socklen_t len) {
+Error MountNodeUDP::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) {
- filesystem_->ppapi()->ReleaseResource(remote_addr_);
+ mount_->ppapi()->ReleaseResource(remote_addr_);
remote_addr_ = 0;
}
@@ -244,20 +254,21 @@ Error UdpNode::Connect(const HandleAttr& attr,
return 0;
}
-Error UdpNode::Recv_Locked(void* buf,
- size_t len,
- PP_Resource* out_addr,
- int* out_len) {
+Error MountNodeUDP::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) {
- filesystem_->ppapi()->AddRefResource(packet->addr());
+ mount_->ppapi()->AddRefResource(packet->addr());
*out_addr = packet->addr();
}
@@ -271,10 +282,10 @@ Error UdpNode::Recv_Locked(void* buf,
return EBADF;
}
-Error UdpNode::Send_Locked(const void* buf,
- size_t len,
- PP_Resource addr,
- int* out_len) {
+Error MountNodeUDP::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;
@@ -288,8 +299,9 @@ Error UdpNode::Send_Locked(const void* buf,
}
*out_len = 0;
- int capped_len = static_cast<int32_t>(std::min<int>(len, kMaxPacketSize));
- Packet* packet = new Packet(filesystem_->ppapi());
+ int capped_len =
+ static_cast<int32_t>(std::min<int>(len, kMaxPacketSize));
+ Packet* packet = new Packet(mount_->ppapi());
packet->Copy(buf, capped_len, addr);
emitter_->WriteTXPacket_Locked(packet);
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/udp_node.h b/native_client_sdk/src/libraries/nacl_io/mount_node_udp.h
index be8cf05..95f2889 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/udp_node.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_udp.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_SOCKET_UDP_NODE_H_
-#define LIBRARIES_NACL_IO_SOCKET_UDP_NODE_H_
+#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_UDP_H_
+#define LIBRARIES_NACL_IO_MOUNT_NODE_UDP_H_
#include "nacl_io/ossocket.h"
#ifdef PROVIDES_SOCKET_API
@@ -11,21 +11,22 @@
#include <ppapi/c/pp_resource.h>
#include <ppapi/c/ppb_udp_socket.h>
-#include "nacl_io/socket/socket_node.h"
-#include "nacl_io/socket/udp_event_emitter.h"
+#include "nacl_io/event_emitter_udp.h"
+#include "nacl_io/mount_node.h"
+#include "nacl_io/mount_node_socket.h"
namespace nacl_io {
-class UdpNode : public SocketNode {
+class MountNodeUDP : public MountNodeSocket {
public:
- explicit UdpNode(Filesystem* filesystem);
+ explicit MountNodeUDP(Mount* mount);
protected:
virtual Error Init(int open_flags);
virtual void Destroy();
public:
- virtual UdpEventEmitter* GetEventEmitter();
+ virtual EventEmitterUDP* GetEventEmitter();
virtual void QueueInput();
virtual void QueueOutput();
@@ -46,10 +47,11 @@ class UdpNode : public SocketNode {
PP_Resource addr,
int* out_len);
- ScopedUdpEventEmitter emitter_;
+ ScopedEventEmitterUDP emitter_;
};
+
} // namespace nacl_io
#endif // PROVIDES_SOCKET_API
-#endif // LIBRARIES_NACL_IO_SOCKET_UDP_NODE_H_
+#endif // LIBRARIES_NACL_IO_MOUNT_NODE_UDP_H_
diff --git a/native_client_sdk/src/libraries/nacl_io/passthroughfs/passthrough_fs.cc b/native_client_sdk/src/libraries/nacl_io/mount_passthrough.cc
index 8ca51d6..9f91763 100644
--- a/native_client_sdk/src/libraries/nacl_io/passthroughfs/passthrough_fs.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_passthrough.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/passthroughfs/passthrough_fs.h"
+#include "nacl_io/mount_passthrough.h"
#include <errno.h>
@@ -11,10 +11,10 @@
namespace nacl_io {
-class PassthroughFsNode : public Node {
+class MountNodePassthrough : public MountNode {
public:
- explicit PassthroughFsNode(Filesystem* filesystem, int real_fd)
- : Node(filesystem), real_fd_(real_fd) {}
+ explicit MountNodePassthrough(Mount* mount, int real_fd)
+ : MountNode(mount), real_fd_(real_fd) {}
protected:
virtual Error Init(int flags) { return 0; }
@@ -104,65 +104,68 @@ class PassthroughFsNode : public Node {
}
private:
- friend class PassthroughFs;
+ friend class MountPassthrough;
int real_fd_;
};
-PassthroughFs::PassthroughFs() {}
+MountPassthrough::MountPassthrough() {}
-Error PassthroughFs::Init(const FsInitArgs& args) {
- return Filesystem::Init(args);
+Error MountPassthrough::Init(const MountInitArgs& args) {
+ return Mount::Init(args);
}
-void PassthroughFs::Destroy() {}
+void MountPassthrough::Destroy() {}
-Error PassthroughFs::Access(const Path& path, int a_mode) {
+Error MountPassthrough::Access(const Path& path, int a_mode) {
// There is no underlying 'access' syscall in NaCl. It just returns ENOSYS.
return ENOSYS;
}
-Error PassthroughFs::Open(const Path& path, int mode, ScopedNode* out_node) {
+Error MountPassthrough::Open(const Path& path,
+ int mode,
+ ScopedMountNode* 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 PassthroughFsNode(this, real_fd));
+ out_node->reset(new MountNodePassthrough(this, real_fd));
return 0;
}
-Error PassthroughFs::OpenResource(const Path& path, ScopedNode* out_node) {
+Error MountPassthrough::OpenResource(const Path& path,
+ ScopedMountNode* 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 PassthroughFsNode(this, real_fd));
+ out_node->reset(new MountNodePassthrough(this, real_fd));
return 0;
}
-Error PassthroughFs::Unlink(const Path& path) {
+Error MountPassthrough::Unlink(const Path& path) {
// Not implemented by NaCl.
return ENOSYS;
}
-Error PassthroughFs::Mkdir(const Path& path, int perm) {
+Error MountPassthrough::Mkdir(const Path& path, int perm) {
return _real_mkdir(path.Join().c_str(), perm);
}
-Error PassthroughFs::Rmdir(const Path& path) {
+Error MountPassthrough::Rmdir(const Path& path) {
return _real_rmdir(path.Join().c_str());
}
-Error PassthroughFs::Remove(const Path& path) {
+Error MountPassthrough::Remove(const Path& path) {
// Not implemented by NaCl.
return ENOSYS;
}
-Error PassthroughFs::Rename(const Path& path, const Path& newpath) {
+Error MountPassthrough::Rename(const Path& path, const Path& newpath) {
// Not implemented by NaCl.
return ENOSYS;
}
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_passthrough.h b/native_client_sdk/src/libraries/nacl_io/mount_passthrough.h
new file mode 100644
index 0000000..3cc3285
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/mount_passthrough.h
@@ -0,0 +1,37 @@
+// 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/stream/stream_fs.cc b/native_client_sdk/src/libraries/nacl_io/mount_stream.cc
index 03c90d8..e7b23ef 100644
--- a/native_client_sdk/src/libraries/nacl_io/stream/stream_fs.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_stream.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/stream/stream_fs.h"
+#include "nacl_io/ossocket.h"
#include <errno.h>
-#include "nacl_io/ossocket.h"
+#include "nacl_io/mount_stream.h"
#include "nacl_io/pepper_interface.h"
namespace nacl_io {
void DispatchStart(void* work_ptr, int32_t val) {
- StreamFs::Work* work = static_cast<StreamFs::Work*>(work_ptr);
+ MountStream::Work* work = static_cast<MountStream::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) {
- StreamFs::Work* work = static_cast<StreamFs::Work*>(work_ptr);
+ MountStream::Work* work = static_cast<MountStream::Work*>(work_ptr);
work->Run(val);
delete work;
}
-void* StreamFs::StreamThreadThunk(void* fs_ptr) {
- StreamFs* filesystem = static_cast<StreamFs*>(fs_ptr);
- filesystem->StreamThread();
+void* MountStream::StreamThreadThunk(void* mount_ptr) {
+ MountStream* mount = static_cast<MountStream*>(mount_ptr);
+ mount->StreamThread();
return NULL;
}
// All work is done via completions callbacks from posted work.
-void StreamFs::StreamThread() {
+void MountStream::StreamThread() {
{
AUTO_LOCK(message_lock_)
message_loop_ =
@@ -46,16 +46,16 @@ void StreamFs::StreamThread() {
ppapi_->GetMessageLoopInterface()->Run(message_loop_);
}
-PP_CompletionCallback StreamFs::GetStartCompletion(Work* work) {
+PP_CompletionCallback MountStream::GetStartCompletion(Work* work) {
return PP_MakeCompletionCallback(DispatchStart, work);
}
-PP_CompletionCallback StreamFs::GetRunCompletion(Work* work) {
+PP_CompletionCallback MountStream::GetRunCompletion(Work* work) {
return PP_MakeCompletionCallback(DispatchRun, work);
}
// Place enqueue onto the socket thread.
-void StreamFs::EnqueueWork(Work* work) {
+void MountStream::EnqueueWork(Work* work) {
if (message_loop_ == 0) {
AUTO_LOCK(message_lock_);
@@ -72,11 +72,12 @@ void StreamFs::EnqueueWork(Work* work) {
ppapi_->GetMessageLoopInterface()->PostWork(message_loop_, cb, 0);
}
-StreamFs::StreamFs() : message_loop_(0) {
+MountStream::MountStream()
+ : message_loop_(0) {
pthread_cond_init(&message_cond_, NULL);
}
-StreamFs::~StreamFs() {
+MountStream::~MountStream() {
if (message_loop_) {
ppapi_->GetMessageLoopInterface()->PostQuit(message_loop_, PP_TRUE);
ppapi_->ReleaseResource(message_loop_);
@@ -84,20 +85,22 @@ StreamFs::~StreamFs() {
pthread_cond_destroy(&message_cond_);
}
-Error StreamFs::Access(const Path& path, int a_mode) { return EACCES; }
+Error MountStream::Access(const Path& path, int a_mode) { return EACCES; }
-Error StreamFs::Open(const Path& path, int o_flags, ScopedNode* out_node) {
- return EACCES;
-}
+Error MountStream::Open(const Path& path,
+ int o_flags,
+ ScopedMountNode* out_node) { return EACCES; }
-Error StreamFs::Unlink(const Path& path) { return EACCES; }
+Error MountStream::Unlink(const Path& path) { return EACCES; }
-Error StreamFs::Mkdir(const Path& path, int permissions) { return EACCES; }
+Error MountStream::Mkdir(const Path& path, int permissions) { return EACCES; }
-Error StreamFs::Rmdir(const Path& path) { return EACCES; }
+Error MountStream::Rmdir(const Path& path) { return EACCES; }
-Error StreamFs::Remove(const Path& path) { return EACCES; }
+Error MountStream::Remove(const Path& path) { return EACCES; }
-Error StreamFs::Rename(const Path& path, const Path& newpath) { return EACCES; }
+Error MountStream::Rename(const Path& path, const Path& newpath) {
+ return EACCES;
+}
} // namespace nacl_io
diff --git a/native_client_sdk/src/libraries/nacl_io/stream/stream_fs.h b/native_client_sdk/src/libraries/nacl_io/mount_stream.h
index eeec738..e03abe7 100644
--- a/native_client_sdk/src/libraries/nacl_io/stream/stream_fs.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount_stream.h
@@ -2,28 +2,29 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIBRARIES_NACL_IO_STREAM_STREAM_H_
-#define LIBRARIES_NACL_IO_STREAM_STREAM_H_
+#ifndef LIBRARIES_NACL_IO_MOUNT_STREAM_H_
+#define LIBRARIES_NACL_IO_MOUNT_STREAM_H_
-#include "nacl_io/filesystem.h"
+#include "nacl_io/mount.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_resource.h"
+
namespace nacl_io {
-// 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.
+// 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.
-class StreamFs;
-class StreamNode;
+class MountStream;
+class MountNodeStream;
-class StreamFs : public Filesystem {
+class MountStream : public Mount {
public:
class Work {
public:
- explicit Work(StreamFs* filesystem) : filesystem_(filesystem) {}
+ explicit Work(MountStream* mount) : mount_(mount) {}
virtual ~Work() {}
// Called by adding work the queue, val should be safe to ignore.
@@ -32,18 +33,18 @@ class StreamFs : public Filesystem {
// 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;
- StreamFs* filesystem() { return filesystem_; }
+ MountStream* mount() { return mount_; }
- private:
- StreamFs* filesystem_;
+ private:
+ MountStream* mount_;
};
protected:
- StreamFs();
- virtual ~StreamFs();
+ MountStream();
+ virtual ~MountStream();
public:
- // Enqueue a work object onto this StreamFs's thread
+ // Enqueue a work object onto this MountStream's thread
void EnqueueWork(Work* work);
// Returns a completion callback which will execute the StartWork member
@@ -55,7 +56,9 @@ class StreamFs : public Filesystem {
static PP_CompletionCallback GetRunCompletion(Work* work);
virtual Error Access(const Path& path, int a_mode);
- virtual Error Open(const Path& path, int o_flags, ScopedNode* out_node);
+ virtual Error Open(const Path& path,
+ int o_flags,
+ ScopedMountNode* out_node);
virtual Error Unlink(const Path& path);
virtual Error Mkdir(const Path& path, int permissions);
virtual Error Rmdir(const Path& path);
@@ -71,9 +74,9 @@ class StreamFs : public Filesystem {
sdk_util::SimpleLock message_lock_;
friend class KernelProxy;
- DISALLOW_COPY_AND_ASSIGN(StreamFs);
+ DISALLOW_COPY_AND_ASSIGN(MountStream);
};
} // namespace nacl_io
-#endif // LIBRARIES_NACL_IO_STREAM_STREAM_H_
+#endif // LIBRARIES_NACL_IO_MOUNT_STREAM_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 b597496..2263d1b 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_fs_type(const char* fs_type,
+int nacl_io_register_mount_type(const char* mount_type,
fuse_operations* fuse_ops) {
- return ki_register_fs_type(fs_type, fuse_ops);
+ return ki_register_mount_type(mount_type, fuse_ops);
}
-int nacl_io_unregister_fs_type(const char* fs_type) {
- return ki_unregister_fs_type(fs_type);
+int nacl_io_unregister_mount_type(const char* mount_type) {
+ return ki_unregister_mount_type(mount_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 7c49222..98490f2 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 filesystems that require PPAPI; e.g. persistent storage, etc.
+ * use any mounts that require PPAPI; e.g. persistent storage, etc.
*/
void nacl_io_init();
@@ -38,7 +38,9 @@ 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.
@@ -70,7 +72,7 @@ void nacl_io_init_ppapi(PP_Instance instance, PPB_GetInterface get_interface);
* data: Unused.
*
* "html5fs": A filesystem that uses PPAPI FileSystem interface, which can be
- * read in JavaScript via the HTML5 FileSystem API. This filesystem
+ * read in JavaScript via the HTML5 FileSystem API. This mount
* provides the use of persistent storage. Please read the
* documentation in ppapi/c/ppb_file_system.h for more information.
* source: Unused.
@@ -116,7 +118,7 @@ void nacl_io_init_ppapi(PP_Instance instance, PPB_GetInterface get_interface);
*/
/**
- * Register a new filesystem type, using a FUSE interface to implement it.
+ * Register a new mount type, using a FUSE interface to implement it.
*
* Example:
* int my_open(const char* path, struct fuse_file_info*) {
@@ -138,44 +140,44 @@ void nacl_io_init_ppapi(PP_Instance instance, PPB_GetInterface get_interface);
*
* ...
*
- * const char fs_type[] = "my_fs";
- * int result = nacl_io_register_fs_type(fs_type, &my_fuse_ops);
+ * const char mount_type[] = "my_mount";
+ * int result = nacl_io_register_mount_type(mount_type, &my_fuse_ops);
* if (!result) {
- * fprintf(stderr, "Error registering filesystem type %s.\n", fs_type);
+ * fprintf(stderr, "Error registering mount type %s.\n", mount_type);
* exit(1);
* }
*
* ...
*
- * int result = mount("", "/fs/foo", fs_type, 0, NULL);
+ * int result = mount("", "/mnt/foo", mount_type, 0, NULL);
* if (!result) {
- * fprintf(stderr, "Error mounting %s.\n", fs_type);
+ * fprintf(stderr, "Error mounting %s.\n", mount_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] fs_type The name of the new filesystem type.
+ * @param[in] mount_type The name of the new mount type.
* @param[in] fuse_ops A pointer to the FUSE interface that will be used to
- * implement this filesystem type. This pointer must be valid for the
- * lifetime of all filesystems and nodes that are created with it.
+ * implement this mount type. This pointer must be valid for the lifetime
+ * of all mounts and nodes that are created with it.
* @return 0 on success, -1 on failure (with errno set).
*/
struct fuse_operations;
-int nacl_io_register_fs_type(const char* fs_type,
- struct fuse_operations* fuse_ops);
+int nacl_io_register_mount_type(const char* mount_type,
+ struct fuse_operations* fuse_ops);
/**
- * Unregister a filesystem type, previously registered by
- * nacl_io_register_fs_type().
+ * Unregister a mount type, previously registered by
+ * 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().
+ * @param[in] mount_type The name of the mount type; the same identifier that
+ * was passed to nacl_io_register_mount_type().
* @return 0 on success, -1 on failure (with errno set).
*/
-int nacl_io_unregister_fs_type(const char* fs_type);
+int nacl_io_unregister_mount_type(const char* mount_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/socket/packet.cc b/native_client_sdk/src/libraries/nacl_io/packet.cc
index fcfbf7d..c75fb11 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/packet.cc
+++ b/native_client_sdk/src/libraries/nacl_io/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/socket/packet.h"
+#include "nacl_io/packet.h"
#include <string.h>
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/packet.h b/native_client_sdk/src/libraries/nacl_io/packet.h
index b238a7b..46f3b3b 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/packet.h
+++ b/native_client_sdk/src/libraries/nacl_io/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_SOCKET_PACKET_H_
-#define LIBRARIES_NACL_IO_SOCKET_PACKET_H_
+#ifndef LIBRARIES_NACL_IO_PACKET_H_
+#define LIBRARIES_NACL_IO_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_SOCKET_PACKET_H_
+#endif // LIBRARIES_NACL_IO_PACKET_H_
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
deleted file mode 100644
index 983c5da..0000000
--- a/native_client_sdk/src/libraries/nacl_io/passthroughfs/passthrough_fs.h
+++ /dev/null
@@ -1,38 +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_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/pipe/pipe_node.cc b/native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.cc
deleted file mode 100644
index fce322b..0000000
--- a/native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.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/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
deleted file mode 100644
index 4b4c937..0000000
--- a/native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.h
+++ /dev/null
@@ -1,39 +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_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/stream/stream_node.cc b/native_client_sdk/src/libraries/nacl_io/stream/stream_node.cc
deleted file mode 100644
index 2802213..0000000
--- a/native_client_sdk/src/libraries/nacl_io/stream/stream_node.cc
+++ /dev/null
@@ -1,51 +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/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/typed_fs_factory.h b/native_client_sdk/src/libraries/nacl_io/typed_fs_factory.h
deleted file mode 100644
index 9c1aa1c1..0000000
--- a/native_client_sdk/src/libraries/nacl_io/typed_fs_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_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
new file mode 100644
index 0000000..805429c
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/typed_mount_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_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
deleted file mode 100644
index 500cf2a..0000000
--- a/native_client_sdk/src/tests/nacl_io_test/dev_fs_for_testing.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_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 76f5359..92d9e74 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,14 +20,16 @@
#include "nacl_io/kernel_intercept.h"
#include "nacl_io/kernel_proxy.h"
#include "nacl_io/kernel_wrap.h"
-#include "nacl_io/pipe/pipe_node.h"
-#include "nacl_io/stream/stream_fs.h"
+#include "nacl_io/mount_node_pipe.h"
+#include "nacl_io/mount_stream.h"
#include "ppapi_simple/ps.h"
+
using namespace nacl_io;
using namespace sdk_util;
+
class EventListenerTester : public EventListener {
public:
EventListenerTester() : EventListener(), events_(0) {};
@@ -36,13 +38,18 @@ 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;
@@ -78,14 +85,16 @@ 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();
}
@@ -108,16 +117,17 @@ 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_);
@@ -126,7 +136,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_);
@@ -152,9 +162,13 @@ 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);
}
@@ -162,7 +176,7 @@ TEST(PipeTest, Listener) {
const char hello[] = "Hello World.";
char tmp[64] = "Goodbye";
- PipeEventEmitter pipe(32);
+ EventEmitterPipe pipe(32);
// Expect to time out on input.
{
@@ -188,16 +202,17 @@ TEST(PipeTest, Listener) {
EXPECT_EQ(0, strcmp(hello, tmp));
}
-class StreamFsForTesting : public StreamFs {
+
+class TestMountStream : public MountStream {
public:
- StreamFsForTesting() {}
+ TestMountStream() {}
};
TEST(PipeNodeTest, Basic) {
- ScopedFilesystem fs(new StreamFsForTesting());
+ ScopedMount mnt(new TestMountStream());
- PipeNode* pipe_node = new PipeNode(fs.get());
- ScopedRef<PipeNode> pipe(pipe_node);
+ MountNodePipe* pipe_node = new MountNodePipe(mnt.get());
+ ScopedRef<MountNodePipe> pipe(pipe_node);
EXPECT_EQ(POLLOUT, pipe_node->GetEventStatus());
}
@@ -214,7 +229,9 @@ 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);
@@ -312,3 +329,4 @@ 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 becde2a..f2a73e1 100644
--- a/native_client_sdk/src/tests/nacl_io_test/example.dsc
+++ b/native_client_sdk/src/tests/nacl_io_test/example.dsc
@@ -7,12 +7,11 @@
'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_html5_fs.cc',
- 'fake_pepper_interface_html5_fs.h',
+ 'fake_pepper_interface_html5fs.cc',
+ 'fake_pepper_interface_html5fs.h',
'fake_pepper_interface_url_loader.cc',
'fake_pepper_interface_url_loader.h',
'fake_resource_manager.cc',
@@ -20,27 +19,28 @@
'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_html5_fs.cc b/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5fs.cc
index bab795c..3bc3989 100644
--- a/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5fs.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_html5_fs.h"
+#include "fake_pepper_interface_html5fs.h"
#include <string.h>
diff --git a/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.h b/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5fs.h
index d922a2a..9903c30 100644
--- a/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.h
+++ b/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5fs.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_HTML5_FS_H_
-#define LIBRARIES_NACL_IO_TEST_FAKE_PEPPER_INTERFACE_HTML5_FS_H_
+#ifndef LIBRARIES_NACL_IO_TEST_FAKE_PEPPER_INTERFACE_HTML5FS_H_
+#define LIBRARIES_NACL_IO_TEST_FAKE_PEPPER_INTERFACE_HTML5FS_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_HTML5_FS_H_
+#endif // LIBRARIES_NACL_IO_TEST_FAKE_PEPPER_INTERFACE_HTML5FS_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 d54c922..8a35634 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/socket/fifo_packet.h"
-#include "nacl_io/socket/packet.h"
+#include "nacl_io/fifo_packet.h"
+#include "nacl_io/packet.h"
#include "ppapi_simple/ps.h"
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 cfa1ca4..67e70f4 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 NodeForTesting : public Node {
+class MountNodeRefMock : public MountNode {
public:
- explicit NodeForTesting(Filesystem* fs) : Node(fs) {}
+ MountNodeRefMock(Mount* mnt) : MountNode(mnt) {}
};
-class FilesystemForTesting : public Filesystem {
+class MountRefMock : public Mount {
public:
- FilesystemForTesting() {}
+ MountRefMock() {}
public:
Error Access(const Path& path, int a_mode) { return ENOSYS; }
- Error Open(const Path& path, int mode, ScopedNode* out_node) {
+ Error Open(const Path& path, int mode, ScopedMountNode* out_node) {
out_node->reset(NULL);
return ENOSYS;
}
@@ -43,67 +43,70 @@ class FilesystemForTesting : public Filesystem {
Error Rename(const Path& path, const Path& newpath) { return 0; }
};
-class KernelHandleForTesting : public KernelHandle {
+class KernelHandleRefMock : public KernelHandle {
public:
- KernelHandleForTesting(const ScopedFilesystem& fs, const ScopedNode& node)
- : KernelHandle(fs, node) {}
+ KernelHandleRefMock(const ScopedMount& mnt, const ScopedMountNode& node)
+ : KernelHandle(mnt, node) {}
};
class KernelObjectTest : public ::testing::Test {
public:
void SetUp() {
- fs.reset(new FilesystemForTesting());
- node.reset(new NodeForTesting(fs.get()));
+ mnt.reset(new MountRefMock());
+ node.reset(new MountNodeRefMock(mnt.get()));
}
void TearDown() {
- // fs is ref-counted, it doesn't need to be explicitly deleted.
+ // mnt is ref-counted, it doesn't need to be explicitly deleted.
node.reset(NULL);
- fs.reset(NULL);
+ mnt.reset(NULL);
}
KernelObject proxy;
- ScopedFilesystem fs;
- ScopedNode node;
+ ScopedMount mnt;
+ ScopedMountNode node;
};
} // namespace
+#include <nacl_io/mount_mem.h>
+#include <nacl_io/mount_http.h>
+
TEST_F(KernelObjectTest, Referencing) {
- // The filesystem and node should have 1 ref count at this point
- EXPECT_EQ(1, fs->RefCount());
+ // The mount and node should have 1 ref count at this point
+ EXPECT_EQ(1, mnt->RefCount());
EXPECT_EQ(1, node->RefCount());
- // Pass the filesystem and node into a KernelHandle
- KernelHandle* raw_handle = new KernelHandleForTesting(fs, node);
+ // Pass the mount and node into a KernelHandle
+ KernelHandle* raw_handle = new KernelHandleRefMock(mnt, node);
ScopedKernelHandle handle_a(raw_handle);
- // The filesystem and node should have 1 ref count at this point
+ // The mount and node should have 1 ref count at this point
EXPECT_EQ(1, handle_a->RefCount());
- EXPECT_EQ(2, fs->RefCount());
+ EXPECT_EQ(2, mnt->RefCount());
EXPECT_EQ(2, node->RefCount());
ScopedKernelHandle handle_b = handle_a;
- // There should be two references to the KernelHandle, the filesystem and node
+ // There should be two references to the KernelHandle, the mount 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, fs->RefCount());
+ EXPECT_EQ(2, mnt->RefCount());
EXPECT_EQ(2, node->RefCount());
// Allocating an FD should cause the KernelProxy to ref the handle and
- // the node and filesystem should be unchanged.
+ // the node and mount should be unchanged.
int fd1 = proxy.AllocateFD(handle_a);
EXPECT_EQ(3, handle_a->RefCount());
- EXPECT_EQ(2, fs->RefCount());
+ EXPECT_EQ(2, mnt->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, fs->RefCount());
+ EXPECT_EQ(2, mnt->RefCount());
EXPECT_EQ(2, node->RefCount());
// Handles are expected to come out in order
@@ -113,7 +116,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, fs->RefCount());
+ EXPECT_EQ(2, mnt->RefCount());
EXPECT_EQ(2, node->RefCount());
// We should find the handle by either fd
@@ -123,7 +126,7 @@ TEST_F(KernelObjectTest, Referencing) {
EXPECT_EQ(raw_handle, handle_b.get());
EXPECT_EQ(4, handle_a->RefCount());
- EXPECT_EQ(2, fs->RefCount());
+ EXPECT_EQ(2, mnt->RefCount());
EXPECT_EQ(2, node->RefCount());
// A non existent fd should fail, and handleA should decrement as handleB
@@ -141,37 +144,37 @@ TEST_F(KernelObjectTest, Referencing) {
handle_b.reset();
EXPECT_EQ(2, raw_handle->RefCount());
- EXPECT_EQ(2, fs->RefCount());
+ EXPECT_EQ(2, mnt->RefCount());
EXPECT_EQ(2, node->RefCount());
proxy.FreeFD(fd2);
EXPECT_EQ(1, raw_handle->RefCount());
- EXPECT_EQ(2, fs->RefCount());
+ EXPECT_EQ(2, mnt->RefCount());
EXPECT_EQ(2, node->RefCount());
proxy.FreeFD(fd1);
- EXPECT_EQ(1, fs->RefCount());
+ EXPECT_EQ(1, mnt->RefCount());
EXPECT_EQ(1, node->RefCount());
}
TEST_F(KernelObjectTest, FreeAndReassignFD) {
- // The filesystem and node should have 1 ref count at this point
- EXPECT_EQ(1, fs->RefCount());
+ // The mount and node should have 1 ref count at this point
+ EXPECT_EQ(1, mnt->RefCount());
EXPECT_EQ(1, node->RefCount());
- KernelHandle* raw_handle = new KernelHandleForTesting(fs, node);
+ KernelHandle* raw_handle = new KernelHandleRefMock(mnt, node);
ScopedKernelHandle handle(raw_handle);
- EXPECT_EQ(2, fs->RefCount());
+ EXPECT_EQ(2, mnt->RefCount());
EXPECT_EQ(2, node->RefCount());
EXPECT_EQ(1, raw_handle->RefCount());
proxy.AllocateFD(handle);
- EXPECT_EQ(2, fs->RefCount());
+ EXPECT_EQ(2, mnt->RefCount());
EXPECT_EQ(2, node->RefCount());
EXPECT_EQ(2, raw_handle->RefCount());
proxy.FreeAndReassignFD(5, handle);
- EXPECT_EQ(2, fs->RefCount());
+ EXPECT_EQ(2, mnt->RefCount());
EXPECT_EQ(2, node->RefCount());
EXPECT_EQ(3, raw_handle->RefCount());
diff --git a/native_client_sdk/src/tests/nacl_io_test/mock_kernel_proxy.cc b/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.cc
index 08c41a0..e3791fa 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mock_kernel_proxy.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.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 "mock_kernel_proxy.h"
+#include "kernel_proxy_mock.h"
#include "nacl_io/kernel_intercept.h"
-MockKernelProxy::MockKernelProxy() {}
+KernelProxyMock::KernelProxyMock() {}
-MockKernelProxy::~MockKernelProxy() {
+KernelProxyMock::~KernelProxyMock() {
// 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/mock_kernel_proxy.h b/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.h
index d8b35c3..3c26039 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mock_kernel_proxy.h
+++ b/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_mock.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_MOCK_KERNEL_PROXY_H_
-#define LIBRARIES_NACL_IO_TEST_MOCK_KERNEL_PROXY_H_
+#ifndef LIBRARIES_NACL_IO_TEST_KERNEL_PROXY_MOCK_H_
+#define LIBRARIES_NACL_IO_TEST_KERNEL_PROXY_MOCK_H_
#include <sys/types.h>
#include <sys/stat.h>
@@ -14,10 +14,10 @@
#include "nacl_io/ossocket.h"
#include "nacl_io/ostermios.h"
-class MockKernelProxy : public nacl_io::KernelProxy {
+class KernelProxyMock : public nacl_io::KernelProxy {
public:
- MockKernelProxy();
- virtual ~MockKernelProxy();
+ KernelProxyMock();
+ virtual ~KernelProxyMock();
MOCK_METHOD2(access, int(const char*, int));
MOCK_METHOD1(chdir, int(const char*));
@@ -99,4 +99,4 @@ class MockKernelProxy : public nacl_io::KernelProxy {
};
-#endif // LIBRARIES_NACL_IO_TEST_MOCK_KERNEL_PROXY_H_
+#endif // LIBRARIES_NACL_IO_TEST_KERNEL_PROXY_MOCK_H_
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 44c158d..2707ad4 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 "mock_fs.h"
-#include "mock_node.h"
+#include "mount_mock.h"
+#include "mount_node_mock.h"
-#include "nacl_io/filesystem.h"
#include "nacl_io/kernel_intercept.h"
#include "nacl_io/kernel_proxy.h"
-#include "nacl_io/memfs/mem_fs.h"
+#include "nacl_io/mount.h"
+#include "nacl_io/mount_mem.h"
#include "nacl_io/osmman.h"
#include "nacl_io/path.h"
-#include "nacl_io/typed_fs_factory.h"
+#include "nacl_io/typed_mount_factory.h"
using namespace nacl_io;
using namespace sdk_util;
@@ -39,14 +39,14 @@ using ::testing::WithArgs;
namespace {
-class KernelProxyTest_KernelProxy : public KernelProxy {
+class KernelProxyFriend : public KernelProxy {
public:
- Filesystem* RootFs() {
- ScopedFilesystem fs;
+ Mount* RootMount() {
+ ScopedMount mnt;
Path path;
- AcquireFsAndRelPath("/", &fs, &path);
- return fs.get();
+ AcquireMountAndRelPath("/", &mnt, &path);
+ return mnt.get();
}
};
@@ -61,10 +61,12 @@ class KernelProxyTest : public ::testing::Test {
EXPECT_EQ(0, kp_.mount("", "/", "memfs", 0, NULL));
}
- void TearDown() { ki_uninit(); }
+ void TearDown() {
+ ki_uninit();
+ }
protected:
- KernelProxyTest_KernelProxy kp_;
+ KernelProxyFriend kp_;
};
} // namespace
@@ -81,7 +83,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 filesystem node but directly in the FD mapping.
+ * or the mount node but directly in the FD mapping.
*/
TEST_F(KernelProxyTest, Fcntl_GETFD) {
int fd = ki_open("/test", O_RDWR | O_CREAT);
@@ -93,7 +95,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
@@ -107,10 +109,10 @@ TEST_F(KernelProxyTest, FileLeak) {
char filename[128];
int garbage[buffer_size];
- MemFs* filesystem = (MemFs*)kp_.RootFs();
- ScopedNode root;
+ MountMem* mount = (MountMem*)kp_.RootMount();
+ ScopedMountNode root;
- ASSERT_EQ(0, filesystem->Open(Path("/"), O_RDONLY, &root));
+ ASSERT_EQ(0, mount->Open(Path("/"), O_RDONLY, &root));
ASSERT_EQ(0, root->ChildCount());
for (int file_num = 0; file_num < 4096; file_num++) {
@@ -126,7 +128,9 @@ 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;
@@ -420,24 +424,24 @@ namespace {
StringMap_t g_string_map;
-class KernelProxyMountTest_Filesystem : public MemFs {
+class MountMockInit : public MountMem {
public:
- using MemFs::Init;
+ using MountMem::Init;
- virtual Error Init(const FsInitArgs& args) {
+ virtual Error Init(const MountInitArgs& args) {
g_string_map = args.string_map;
if (g_string_map.find("false") != g_string_map.end())
return EINVAL;
return 0;
}
- friend class TypedFsFactory<KernelProxyMountTest_Filesystem>;
+ friend class TypedMountFactory<MountMockInit>;
};
-class KernelProxyMountTest_KernelProxy : public KernelProxy {
+class KernelProxyMountMock : public KernelProxy {
virtual Error Init(PepperInterface* ppapi) {
KernelProxy::Init(NULL);
- factories_["initfs"] = new TypedFsFactory<KernelProxyMountTest_Filesystem>;
+ factories_["initfs"] = new TypedMountFactory<MountMockInit>;
return 0;
}
};
@@ -446,12 +450,16 @@ 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:
- KernelProxyMountTest_KernelProxy kp_;
+ KernelProxyMountMock kp_;
};
} // namespace
@@ -472,10 +480,9 @@ namespace {
int g_MMapCount = 0;
-class KernelProxyMMapTest_Node : public Node {
+class MountNodeMockMMap : public MountNode {
public:
- KernelProxyMMapTest_Node(Filesystem* filesystem)
- : Node(filesystem), node_mmap_count_(0) {
+ MountNodeMockMMap(Mount* mount) : MountNode(mount), node_mmap_count_(0) {
EXPECT_EQ(0, Init(0));
}
@@ -507,15 +514,15 @@ class KernelProxyMMapTest_Node : public Node {
int node_mmap_count_;
};
-class KernelProxyMMapTest_Filesystem : public Filesystem {
+class MountMockMMap : public Mount {
public:
virtual Error Access(const Path& path, int a_mode) { return 0; }
- virtual Error Open(const Path& path, int mode, ScopedNode* out_node) {
- out_node->reset(new KernelProxyMMapTest_Node(this));
+ virtual Error Open(const Path& path, int mode, ScopedMountNode* out_node) {
+ out_node->reset(new MountNodeMockMMap(this));
return 0;
}
- virtual Error OpenResource(const Path& path, ScopedNode* out_node) {
+ virtual Error OpenResource(const Path& path, ScopedMountNode* out_node) {
out_node->reset(NULL);
return ENOSYS;
}
@@ -525,13 +532,13 @@ class KernelProxyMMapTest_Filesystem : public Filesystem {
virtual Error Remove(const Path& path) { return ENOSYS; }
virtual Error Rename(const Path& path, const Path& newpath) { return ENOSYS; }
- friend class TypedFsFactory<KernelProxyMMapTest_Filesystem>;
+ friend class TypedMountFactory<MountMockMMap>;
};
-class KernelProxyMMapTest_KernelProxy : public KernelProxy {
+class KernelProxyMockMMap : public KernelProxy {
virtual Error Init(PepperInterface* ppapi) {
KernelProxy::Init(NULL);
- factories_["mmapfs"] = new TypedFsFactory<KernelProxyMMapTest_Filesystem>;
+ factories_["mmapfs"] = new TypedMountFactory<MountMockMMap>;
return 0;
}
};
@@ -540,12 +547,16 @@ 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:
- KernelProxyMMapTest_KernelProxy kp_;
+ KernelProxyMockMMap kp_;
};
} // namespace
@@ -578,36 +589,36 @@ TEST_F(KernelProxyMMapTest, MMap) {
namespace {
-class SingletonFsFactory : public FsFactory {
+class SingletonMountFactory : public MountFactory {
public:
- SingletonFsFactory(const ScopedFilesystem& filesystem) : mount_(filesystem) {}
+ SingletonMountFactory(const ScopedMount& mount) : mount_(mount) {}
- virtual Error CreateFilesystem(const FsInitArgs& args,
- ScopedFilesystem* out_fs) {
- *out_fs = mount_;
+ virtual Error CreateMount(const MountInitArgs& args,
+ ScopedMount* out_mount) {
+ *out_mount = mount_;
return 0;
}
private:
- ScopedFilesystem mount_;
+ ScopedMount mount_;
};
-class KernelProxyErrorTest_KernelProxy : public KernelProxy {
+class KernelProxyError : public KernelProxy {
public:
- KernelProxyErrorTest_KernelProxy() : fs_(new MockFs) {}
+ KernelProxyError() : mnt_(new MountMock) {}
virtual Error Init(PepperInterface* ppapi) {
KernelProxy::Init(ppapi);
- factories_["testfs"] = new SingletonFsFactory(fs_);
+ factories_["testfs"] = new SingletonMountFactory(mnt_);
- EXPECT_CALL(*fs_, Destroy()).Times(1);
+ EXPECT_CALL(*mnt_, Destroy()).Times(1);
return 0;
}
- ScopedRef<MockFs> fs() { return fs_; }
+ ScopedRef<MountMock> mnt() { return mnt_; }
private:
- ScopedRef<MockFs> fs_;
+ ScopedRef<MountMock> mnt_;
};
class KernelProxyErrorTest : public ::testing::Test {
@@ -621,20 +632,22 @@ class KernelProxyErrorTest : public ::testing::Test {
EXPECT_EQ(0, kp_.mount("", "/", "testfs", 0, NULL));
}
- void TearDown() { ki_uninit(); }
+ void TearDown() {
+ ki_uninit();
+ }
- ScopedRef<MockFs> fs() { return kp_.fs(); }
+ ScopedRef<MountMock> mnt() { return kp_.mnt(); }
private:
- KernelProxyErrorTest_KernelProxy kp_;
+ KernelProxyError kp_;
};
} // namespace
TEST_F(KernelProxyErrorTest, WriteError) {
- ScopedRef<MockFs> mock_fs(fs());
- ScopedRef<MockNode> mock_node(new MockNode(&*mock_fs));
- EXPECT_CALL(*mock_fs, Open(_, _, _))
+ ScopedRef<MountMock> mock_mnt(mnt());
+ ScopedRef<MountNodeMock> mock_node(new MountNodeMock(&*mock_mnt));
+ EXPECT_CALL(*mock_mnt, Open(_, _, _))
.WillOnce(DoAll(SetArgPointee<2>(mock_node), Return(0)));
EXPECT_CALL(*mock_node, Write(_, _, _, _))
@@ -648,15 +661,15 @@ TEST_F(KernelProxyErrorTest, WriteError) {
char buf[20];
EXPECT_EQ(-1, ki_write(fd, &buf[0], 20));
- // The Filesystem should be able to return whatever error it wants and have it
+ // The Mount should be able to return whatever error it wants and have it
// propagate through.
EXPECT_EQ(1234, errno);
}
TEST_F(KernelProxyErrorTest, ReadError) {
- ScopedRef<MockFs> mock_fs(fs());
- ScopedRef<MockNode> mock_node(new MockNode(&*mock_fs));
- EXPECT_CALL(*mock_fs, Open(_, _, _))
+ ScopedRef<MountMock> mock_mnt(mnt());
+ ScopedRef<MountNodeMock> mock_node(new MountNodeMock(&*mock_mnt));
+ EXPECT_CALL(*mock_mnt, Open(_, _, _))
.WillOnce(DoAll(SetArgPointee<2>(mock_node), Return(0)));
EXPECT_CALL(*mock_node, Read(_, _, _, _))
@@ -670,7 +683,7 @@ TEST_F(KernelProxyErrorTest, ReadError) {
char buf[20];
EXPECT_EQ(-1, ki_read(fd, &buf[0], 20));
- // The Filesystem should be able to return whatever error it wants and have it
+ // The Mount 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 1ba70ca..2eb474b 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 "mock_kernel_proxy.h"
+#include "kernel_proxy_mock.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(); }
- MockKernelProxy mock;
+ KernelProxyMock mock;
};
} // namespace
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
new file mode 100644
index 0000000..72ef88c
--- /dev/null
+++ b/native_client_sdk/src/tests/nacl_io_test/mount_dev_mock.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_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/fuse_fs_test.cc b/native_client_sdk/src/tests/nacl_io_test/mount_fuse_test.cc
index 8bb42b8..a0ac553 100644
--- a/native_client_sdk/src/tests/nacl_io_test/fuse_fs_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/mount_fuse_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 FuseFsForTesting : public FuseFs {
+class MountFuseForTesting : public MountFuse {
public:
- explicit FuseFsForTesting(fuse_operations* fuse_ops) {
- FsInitArgs args;
+ explicit MountFuseForTesting(fuse_operations* fuse_ops) {
+ MountInitArgs args;
args.fuse_ops = fuse_ops;
EXPECT_EQ(0, Init(args));
}
@@ -177,19 +177,19 @@ fuse_operations g_fuse_operations = {
testfs_write, // write
};
-class FuseFsTest : public ::testing::Test {
+class MountFuseTest : public ::testing::Test {
public:
- FuseFsTest();
+ MountFuseTest();
void SetUp();
protected:
- FuseFsForTesting fs_;
+ MountFuseForTesting mnt_;
};
-FuseFsTest::FuseFsTest() : fs_(&g_fuse_operations) {}
+MountFuseTest::MountFuseTest() : mnt_(&g_fuse_operations) {}
-void FuseFsTest::SetUp() {
+void MountFuseTest::SetUp() {
// Reset the filesystem.
g_files.clear();
@@ -205,9 +205,9 @@ void FuseFsTest::SetUp() {
} // namespace
-TEST_F(FuseFsTest, OpenAndRead) {
- ScopedNode node;
- ASSERT_EQ(0, fs_.Open(Path("/hello"), O_RDONLY, &node));
+TEST_F(MountFuseTest, OpenAndRead) {
+ ScopedMountNode node;
+ ASSERT_EQ(0, mnt_.Open(Path("/hello"), O_RDONLY, &node));
char buffer[15] = {0};
int bytes_read = 0;
@@ -218,9 +218,9 @@ TEST_F(FuseFsTest, OpenAndRead) {
ASSERT_STREQ(hello_world, buffer);
}
-TEST_F(FuseFsTest, CreateAndWrite) {
- ScopedNode node;
- ASSERT_EQ(0, fs_.Open(Path("/foobar"), O_RDWR | O_CREAT, &node));
+TEST_F(MountFuseTest, CreateAndWrite) {
+ ScopedMountNode node;
+ ASSERT_EQ(0, mnt_.Open(Path("/foobar"), O_RDWR | O_CREAT, &node));
HandleAttr attr;
const char message[] = "Something interesting";
@@ -237,33 +237,33 @@ TEST_F(FuseFsTest, CreateAndWrite) {
ASSERT_STREQ(message, buffer);
}
-TEST_F(FuseFsTest, GetStat) {
+TEST_F(MountFuseTest, GetStat) {
struct stat statbuf;
- ScopedNode node;
+ ScopedMountNode node;
- ASSERT_EQ(0, fs_.Open(Path("/hello"), O_RDONLY, &node));
+ ASSERT_EQ(0, mnt_.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, fs_.Open(Path("/"), O_RDONLY, &node));
+ ASSERT_EQ(0, mnt_.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, fs_.Open(Path("/foobar"), O_RDWR | O_CREAT, &node));
+ ASSERT_EQ(0, mnt_.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(FuseFsTest, GetDents) {
- ScopedNode root;
+TEST_F(MountFuseTest, GetDents) {
+ ScopedMountNode root;
- ASSERT_EQ(0, fs_.Open(Path("/"), O_RDONLY, &root));
+ ASSERT_EQ(0, mnt_.Open(Path("/"), O_RDONLY, &root));
struct dirent entries[4];
int bytes_read;
@@ -284,8 +284,8 @@ TEST_F(FuseFsTest, GetDents) {
EXPECT_STREQ("hello", entries[1].d_name);
// Add a file and read again.
- ScopedNode node;
- ASSERT_EQ(0, fs_.Open(Path("/foobar"), O_RDWR | O_CREAT, &node));
+ ScopedMountNode node;
+ ASSERT_EQ(0, mnt_.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_fs_type("flatfs", &g_fuse_operations);
+ ki_register_mount_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_fs_type("flatfs");
+ ki_unregister_mount_type("flatfs");
ki_uninit();
}
diff --git a/native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc b/native_client_sdk/src/tests/nacl_io_test/mount_html5fs_test.cc
index e29c76e..b770892 100644
--- a/native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/mount_html5fs_test.cc
@@ -18,12 +18,12 @@
#endif
#include "nacl_io/kernel_handle.h"
-#include "nacl_io/html5fs/html5_fs.h"
+#include "nacl_io/mount_html5fs.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_html5_fs.h"
+#include "fake_pepper_interface_html5fs.h"
#include "mock_util.h"
#include "pepper_interface_mock.h"
@@ -38,10 +38,10 @@ using ::testing::Return;
namespace {
-class Html5FsForTesting : public Html5Fs {
+class MountHtml5FsForTesting : public MountHtml5Fs {
public:
- Html5FsForTesting(StringMap_t& string_map, PepperInterface* ppapi) {
- FsInitArgs args;
+ MountHtml5FsForTesting(StringMap_t& string_map, PepperInterface* ppapi) {
+ MountInitArgs args;
args.string_map = string_map;
args.ppapi = ppapi;
Error error = Init(args);
@@ -49,9 +49,9 @@ class Html5FsForTesting : public Html5Fs {
}
};
-class Html5FsTest : public ::testing::Test {
+class MountHtml5FsTest : public ::testing::Test {
public:
- Html5FsTest();
+ MountHtml5FsTest();
protected:
FakePepperInterfaceHtml5Fs ppapi_html5_;
@@ -59,7 +59,7 @@ class Html5FsTest : public ::testing::Test {
PepperInterfaceDelegate ppapi_;
};
-Html5FsTest::Html5FsTest()
+MountHtml5FsTest::MountHtml5FsTest()
: ppapi_mock_(ppapi_html5_.GetInstance()),
ppapi_(ppapi_html5_.GetInstance()) {
// Default delegation to the html5 pepper interface.
@@ -72,7 +72,7 @@ Html5FsTest::Html5FsTest()
} // namespace
-TEST_F(Html5FsTest, FilesystemType) {
+TEST_F(MountHtml5FsTest, 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(Html5FsTest, FilesystemType) {
StringMap_t map;
map["type"] = filesystem_type_string;
map["expected_size"] = expected_size_string;
- ScopedRef<Html5FsForTesting> fs(
- new Html5FsForTesting(map, &ppapi_));
+ ScopedRef<MountHtml5FsForTesting> mnt(
+ new MountHtml5FsForTesting(map, &ppapi_));
Mock::VerifyAndClearExpectations(&filesystem_mock);
}
}
}
-TEST_F(Html5FsTest, Access) {
+TEST_F(MountHtml5FsTest, Access) {
EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile("/foo", NULL));
StringMap_t map;
- ScopedRef<Html5FsForTesting> fs(
- new Html5FsForTesting(map, &ppapi_));
+ ScopedRef<MountHtml5FsForTesting> mnt(
+ new MountHtml5FsForTesting(map, &ppapi_));
- ASSERT_EQ(0, fs->Access(Path("/foo"), R_OK | W_OK | X_OK));
- ASSERT_EQ(ENOENT, fs->Access(Path("/bar"), F_OK));
+ ASSERT_EQ(0, mnt->Access(Path("/foo"), R_OK | W_OK | X_OK));
+ ASSERT_EQ(ENOENT, mnt->Access(Path("/bar"), F_OK));
}
-TEST_F(Html5FsTest, Mkdir) {
+TEST_F(MountHtml5FsTest, Mkdir) {
StringMap_t map;
- ScopedRef<Html5FsForTesting> fs(
- new Html5FsForTesting(map, &ppapi_));
+ ScopedRef<MountHtml5FsForTesting> mnt(
+ new MountHtml5FsForTesting(map, &ppapi_));
// mkdir at the root should return EEXIST, not EACCES.
- EXPECT_EQ(EEXIST, fs->Mkdir(Path("/"), 0644));
+ EXPECT_EQ(EEXIST, mnt->Mkdir(Path("/"), 0644));
Path path("/foo");
- ASSERT_EQ(ENOENT, fs->Access(path, F_OK));
- ASSERT_EQ(0, fs->Mkdir(path, 0644));
+ ASSERT_EQ(ENOENT, mnt->Access(path, F_OK));
+ ASSERT_EQ(0, mnt->Mkdir(path, 0644));
struct stat stat;
- ScopedNode node;
- ASSERT_EQ(0, fs->Open(path, O_RDONLY, &node));
+ ScopedMountNode node;
+ ASSERT_EQ(0, mnt->Open(path, O_RDONLY, &node));
EXPECT_EQ(0, node->GetStat(&stat));
EXPECT_EQ(S_IFDIR, stat.st_mode & S_IFDIR);
}
-TEST_F(Html5FsTest, Remove) {
+TEST_F(MountHtml5FsTest, Remove) {
EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile("/foo", NULL));
StringMap_t map;
- ScopedRef<Html5FsForTesting> fs(
- new Html5FsForTesting(map, &ppapi_));
+ ScopedRef<MountHtml5FsForTesting> mnt(
+ new MountHtml5FsForTesting(map, &ppapi_));
Path path("/foo");
- ASSERT_EQ(0, fs->Access(path, F_OK));
- ASSERT_EQ(0, fs->Remove(path));
- EXPECT_EQ(ENOENT, fs->Access(path, F_OK));
+ ASSERT_EQ(0, mnt->Access(path, F_OK));
+ ASSERT_EQ(0, mnt->Remove(path));
+ EXPECT_EQ(ENOENT, mnt->Access(path, F_OK));
}
// Unlink + Rmdir forward to Remove unconditionally, which will not fail if the
// file type is wrong.
-TEST_F(Html5FsTest, DISABLED_Unlink) {
+TEST_F(MountHtml5FsTest, DISABLED_Unlink) {
EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile("/file", NULL));
EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddDirectory("/dir", NULL));
StringMap_t map;
- ScopedRef<Html5FsForTesting> fs(
- new Html5FsForTesting(map, &ppapi_));
+ ScopedRef<MountHtml5FsForTesting> mnt(
+ new MountHtml5FsForTesting(map, &ppapi_));
- 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));
+ 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));
}
// Unlink + Rmdir forward to Remove unconditionally, which will not fail if the
// file type is wrong.
-TEST_F(Html5FsTest, DISABLED_Rmdir) {
+TEST_F(MountHtml5FsTest, DISABLED_Rmdir) {
EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile("/file", NULL));
EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddDirectory("/dir", NULL));
StringMap_t map;
- ScopedRef<Html5FsForTesting> fs(
- new Html5FsForTesting(map, &ppapi_));
+ ScopedRef<MountHtml5FsForTesting> mnt(
+ new MountHtml5FsForTesting(map, &ppapi_));
- 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));
+ 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));
}
-TEST_F(Html5FsTest, OpenForCreate) {
+TEST_F(MountHtml5FsTest, OpenForCreate) {
StringMap_t map;
- ScopedRef<Html5FsForTesting> fs(
- new Html5FsForTesting(map, &ppapi_));
+ ScopedRef<MountHtml5FsForTesting> mnt(
+ new MountHtml5FsForTesting(map, &ppapi_));
Path path("/foo");
- EXPECT_EQ(ENOENT, fs->Access(path, F_OK));
+ EXPECT_EQ(ENOENT, mnt->Access(path, F_OK));
- ScopedNode node;
- ASSERT_EQ(0, fs->Open(path, O_CREAT | O_RDWR, &node));
+ ScopedMountNode node;
+ ASSERT_EQ(0, mnt->Open(path, O_CREAT | O_RDWR, &node));
// Write some data.
char contents[] = "contents";
@@ -213,7 +213,7 @@ TEST_F(Html5FsTest, OpenForCreate) {
EXPECT_EQ(strlen(contents), bytes_written);
// Create again.
- ASSERT_EQ(0, fs->Open(path, O_CREAT, &node));
+ ASSERT_EQ(0, mnt->Open(path, O_CREAT, &node));
// Check that the file still has data.
size_t size;
@@ -221,30 +221,30 @@ TEST_F(Html5FsTest, OpenForCreate) {
EXPECT_EQ(strlen(contents), size);
// Open exclusively.
- EXPECT_EQ(EEXIST, fs->Open(path, O_CREAT | O_EXCL, &node));
+ EXPECT_EQ(EEXIST, mnt->Open(path, O_CREAT | O_EXCL, &node));
// Try to truncate without write access.
- EXPECT_EQ(EINVAL, fs->Open(path, O_CREAT | O_TRUNC, &node));
+ EXPECT_EQ(EINVAL, mnt->Open(path, O_CREAT | O_TRUNC, &node));
// Open and truncate.
- ASSERT_EQ(0, fs->Open(path, O_CREAT | O_TRUNC | O_WRONLY, &node));
+ ASSERT_EQ(0, mnt->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(Html5FsTest, Read) {
+TEST_F(MountHtml5FsTest, 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<Html5FsForTesting> fs(
- new Html5FsForTesting(map, &ppapi_));
+ ScopedRef<MountHtml5FsForTesting> mnt(
+ new MountHtml5FsForTesting(map, &ppapi_));
- ScopedNode node;
- ASSERT_EQ(0, fs->Open(Path("/file"), O_RDONLY, &node));
+ ScopedMountNode node;
+ ASSERT_EQ(0, mnt->Open(Path("/file"), O_RDONLY, &node));
char buffer[10] = {0};
int bytes_read = 0;
@@ -273,22 +273,22 @@ TEST_F(Html5FsTest, Read) {
ASSERT_EQ(0, bytes_written);
// Reading from a directory should fail.
- ASSERT_EQ(0, fs->Open(Path("/dir"), O_RDONLY, &node));
+ ASSERT_EQ(0, mnt->Open(Path("/dir"), O_RDONLY, &node));
ASSERT_EQ(EISDIR, node->Read(attr, &buffer[0], sizeof(buffer), &bytes_read));
}
-TEST_F(Html5FsTest, Write) {
+TEST_F(MountHtml5FsTest, 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<Html5FsForTesting> fs(
- new Html5FsForTesting(map, &ppapi_));
+ ScopedRef<MountHtml5FsForTesting> mnt(
+ new MountHtml5FsForTesting(map, &ppapi_));
- ScopedNode node;
- ASSERT_EQ(0, fs->Open(Path("/file"), O_WRONLY, &node));
+ ScopedMountNode node;
+ ASSERT_EQ(0, mnt->Open(Path("/file"), O_WRONLY, &node));
// Reading should fail.
char buffer[10];
@@ -298,7 +298,7 @@ TEST_F(Html5FsTest, Write) {
EXPECT_EQ(0, bytes_read);
// Reopen as read-write.
- ASSERT_EQ(0, fs->Open(Path("/file"), O_RDWR, &node));
+ ASSERT_EQ(0, mnt->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(Html5FsTest, Write) {
EXPECT_STREQ("construct", buffer);
// Writing to a directory should fail.
- EXPECT_EQ(0, fs->Open(Path("/dir"), O_RDWR, &node));
+ EXPECT_EQ(0, mnt->Open(Path("/dir"), O_RDWR, &node));
EXPECT_EQ(EISDIR, node->Write(attr, &buffer[0], sizeof(buffer), &bytes_read));
}
-TEST_F(Html5FsTest, GetStat) {
+TEST_F(MountHtml5FsTest, GetStat) {
const int creation_time = 1000;
const int access_time = 2000;
const int modified_time = 3000;
@@ -338,11 +338,11 @@ TEST_F(Html5FsTest, GetStat) {
fake_node->set_last_modified_time(modified_time);
StringMap_t map;
- ScopedRef<Html5FsForTesting> fs(
- new Html5FsForTesting(map, &ppapi_));
+ ScopedRef<MountHtml5FsForTesting> mnt(
+ new MountHtml5FsForTesting(map, &ppapi_));
- ScopedNode node;
- ASSERT_EQ(0, fs->Open(Path("/file"), O_RDONLY, &node));
+ ScopedMountNode node;
+ ASSERT_EQ(0, mnt->Open(Path("/file"), O_RDONLY, &node));
struct stat statbuf;
EXPECT_EQ(0, node->GetStat(&statbuf));
@@ -363,7 +363,7 @@ TEST_F(Html5FsTest, GetStat) {
EXPECT_FALSE(node->IsaTTY());
// GetStat on a directory...
- EXPECT_EQ(0, fs->Open(Path("/dir"), O_RDONLY, &node));
+ EXPECT_EQ(0, mnt->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(Html5FsTest, GetStat) {
EXPECT_FALSE(node->IsaTTY());
}
-TEST_F(Html5FsTest, FTruncate) {
+TEST_F(MountHtml5FsTest, 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<Html5FsForTesting> fs(
- new Html5FsForTesting(map, &ppapi_));
+ ScopedRef<MountHtml5FsForTesting> mnt(
+ new MountHtml5FsForTesting(map, &ppapi_));
- ScopedNode node;
- ASSERT_EQ(0, fs->Open(Path("/file"), O_RDWR, &node));
+ ScopedMountNode node;
+ ASSERT_EQ(0, mnt->Open(Path("/file"), O_RDWR, &node));
HandleAttr attr;
char buffer[10] = {0};
@@ -413,24 +413,24 @@ TEST_F(Html5FsTest, FTruncate) {
EXPECT_STREQ("cont\0\0\0\0", buffer);
// Ftruncate should fail for a directory.
- EXPECT_EQ(0, fs->Open(Path("/dir"), O_RDONLY, &node));
+ EXPECT_EQ(0, mnt->Open(Path("/dir"), O_RDONLY, &node));
EXPECT_EQ(EISDIR, node->FTruncate(4));
}
-TEST_F(Html5FsTest, GetDents) {
+TEST_F(MountHtml5FsTest, GetDents) {
const char contents[] = "contents";
EXPECT_TRUE(
ppapi_html5_.filesystem_template()->AddFile("/file", contents, NULL));
StringMap_t map;
- ScopedRef<Html5FsForTesting> fs(
- new Html5FsForTesting(map, &ppapi_));
+ ScopedRef<MountHtml5FsForTesting> mnt(
+ new MountHtml5FsForTesting(map, &ppapi_));
- ScopedNode root;
- ASSERT_EQ(0, fs->Open(Path("/"), O_RDONLY, &root));
+ ScopedMountNode root;
+ ASSERT_EQ(0, mnt->Open(Path("/"), O_RDONLY, &root));
- ScopedNode node;
- ASSERT_EQ(0, fs->Open(Path("/file"), O_RDWR, &node));
+ ScopedMountNode node;
+ ASSERT_EQ(0, mnt->Open(Path("/file"), O_RDWR, &node));
// Should fail for regular files.
const size_t kMaxDirents = 5;
@@ -467,7 +467,7 @@ TEST_F(Html5FsTest, GetDents) {
}
// Add another file...
- ASSERT_EQ(0, fs->Open(Path("/file2"), O_CREAT, &node));
+ ASSERT_EQ(0, mnt->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/http_fs_test.cc b/native_client_sdk/src/tests/nacl_io_test/mount_http_test.cc
index 76a7050..a679bbc 100644
--- a/native_client_sdk/src/tests/nacl_io_test/http_fs_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/mount_http_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 HttpFsForTesting : public HttpFs {
+class MountHttpForTesting : public MountHttp {
public:
- HttpFsForTesting(StringMap_t map, PepperInterface* ppapi) {
- FsInitArgs args(1);
+ MountHttpForTesting(StringMap_t map, PepperInterface* ppapi) {
+ MountInitArgs args(1);
args.string_map = map;
args.ppapi = ppapi;
EXPECT_EQ(0, Init(args));
}
- using HttpFs::GetNodeCacheForTesting;
- using HttpFs::ParseManifest;
- using HttpFs::FindOrCreateDir;
+ using MountHttp::GetNodeCacheForTesting;
+ using MountHttp::ParseManifest;
+ using MountHttp::FindOrCreateDir;
};
enum {
@@ -60,36 +60,39 @@ StringMap_t MakeStringMap(StringMapParam param) {
return smap;
}
-class HttpFsTest : public ::testing::TestWithParam<StringMapParam> {
+class MountHttpTest : public ::testing::TestWithParam<StringMapParam> {
public:
- HttpFsTest();
+ MountHttpTest();
protected:
FakePepperInterfaceURLLoader ppapi_;
- HttpFsForTesting fs_;
+ MountHttpForTesting mnt_;
};
-HttpFsTest::HttpFsTest() : fs_(MakeStringMap(GetParam()), &ppapi_) {}
+MountHttpTest::MountHttpTest() :
+ mnt_(MakeStringMap(GetParam()), &ppapi_) {
+}
} // namespace
-TEST_P(HttpFsTest, Access) {
+
+TEST_P(MountHttpTest, Access) {
ASSERT_TRUE(ppapi_.server_template()->AddEntity("foo", "", NULL));
- 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));
+ 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));
}
-TEST_P(HttpFsTest, OpenAndCloseServerError) {
+TEST_P(MountHttpTest, OpenAndCloseServerError) {
EXPECT_TRUE(ppapi_.server_template()->AddError("file", 500));
- ScopedNode node;
- ASSERT_EQ(EIO, fs_.Open(Path("/file"), O_RDONLY, &node));
+ ScopedMountNode node;
+ ASSERT_EQ(EIO, mnt_.Open(Path("/file"), O_RDONLY, &node));
}
-TEST_P(HttpFsTest, ReadPartial) {
+TEST_P(MountHttpTest, ReadPartial) {
const char contents[] = "0123456789abcdefg";
ASSERT_TRUE(ppapi_.server_template()->AddEntity("file", contents, NULL));
ppapi_.server_template()->set_allow_partial(true);
@@ -99,8 +102,8 @@ TEST_P(HttpFsTest, ReadPartial) {
char buf[10];
memset(&buf[0], 0, sizeof(buf));
- ScopedNode node;
- ASSERT_EQ(0, fs_.Open(Path("/file"), O_RDONLY, &node));
+ ScopedMountNode node;
+ ASSERT_EQ(0, mnt_.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);
@@ -119,7 +122,7 @@ TEST_P(HttpFsTest, ReadPartial) {
EXPECT_EQ(0, result_bytes);
}
-TEST_P(HttpFsTest, ReadPartialNoServerSupport) {
+TEST_P(MountHttpTest, ReadPartialNoServerSupport) {
const char contents[] = "0123456789abcdefg";
ASSERT_TRUE(ppapi_.server_template()->AddEntity("file", contents, NULL));
ppapi_.server_template()->set_allow_partial(false);
@@ -129,8 +132,8 @@ TEST_P(HttpFsTest, ReadPartialNoServerSupport) {
char buf[10];
memset(&buf[0], 0, sizeof(buf));
- ScopedNode node;
- ASSERT_EQ(0, fs_.Open(Path("/file"), O_RDONLY, &node));
+ ScopedMountNode node;
+ ASSERT_EQ(0, mnt_.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);
@@ -149,12 +152,12 @@ TEST_P(HttpFsTest, ReadPartialNoServerSupport) {
EXPECT_EQ(0, result_bytes);
}
-TEST_P(HttpFsTest, Write) {
+TEST_P(MountHttpTest, Write) {
const char contents[] = "contents";
ASSERT_TRUE(ppapi_.server_template()->AddEntity("file", contents, NULL));
- ScopedNode node;
- ASSERT_EQ(0, fs_.Open(Path("/file"), O_WRONLY, &node));
+ ScopedMountNode node;
+ ASSERT_EQ(0, mnt_.Open(Path("/file"), O_WRONLY, &node));
// Writing always fails.
HandleAttr attr;
@@ -164,12 +167,12 @@ TEST_P(HttpFsTest, Write) {
EXPECT_EQ(0, bytes_written);
}
-TEST_P(HttpFsTest, GetStat) {
+TEST_P(MountHttpTest, GetStat) {
const char contents[] = "contents";
ASSERT_TRUE(ppapi_.server_template()->AddEntity("file", contents, NULL));
- ScopedNode node;
- ASSERT_EQ(0, fs_.Open(Path("/file"), O_RDONLY, &node));
+ ScopedMountNode node;
+ ASSERT_EQ(0, mnt_.Open(Path("/file"), O_RDONLY, &node));
struct stat statbuf;
EXPECT_EQ(0, node->GetStat(&statbuf));
@@ -182,108 +185,108 @@ TEST_P(HttpFsTest, GetStat) {
EXPECT_EQ(0, statbuf.st_mtime);
}
-TEST_P(HttpFsTest, FTruncate) {
+TEST_P(MountHttpTest, FTruncate) {
const char contents[] = "contents";
ASSERT_TRUE(ppapi_.server_template()->AddEntity("file", contents, NULL));
- ScopedNode node;
- ASSERT_EQ(0, fs_.Open(Path("/file"), O_RDWR, &node));
+ ScopedMountNode node;
+ ASSERT_EQ(0, mnt_.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,
- HttpFsTest,
+ MountHttpTest,
::testing::Values((uint32_t)kStringMapParamCacheNone,
(uint32_t)kStringMapParamCacheContent,
(uint32_t)kStringMapParamCacheStat,
(uint32_t)kStringMapParamCacheContentStat));
-TEST(HttpFsDirTest, Mkdir) {
+TEST(MountHttpDirTest, Mkdir) {
StringMap_t args;
- HttpFsForTesting fs(args, NULL);
+ MountHttpForTesting mnt(args, NULL);
char manifest[] = "-r-- 123 /mydir/foo\n-rw- 234 /thatdir/bar\n";
- ASSERT_EQ(0, fs.ParseManifest(manifest));
+ ASSERT_EQ(0, mnt.ParseManifest(manifest));
// mkdir of existing directories should give "File exists".
- EXPECT_EQ(EEXIST, fs.Mkdir(Path("/"), 0));
- EXPECT_EQ(EEXIST, fs.Mkdir(Path("/mydir"), 0));
+ EXPECT_EQ(EEXIST, mnt.Mkdir(Path("/"), 0));
+ EXPECT_EQ(EEXIST, mnt.Mkdir(Path("/mydir"), 0));
// mkdir of non-existent directories should give "Permission denied".
- EXPECT_EQ(EACCES, fs.Mkdir(Path("/non_existent"), 0));
+ EXPECT_EQ(EACCES, mnt.Mkdir(Path("/non_existent"), 0));
}
-TEST(HttpFsDirTest, Rmdir) {
+TEST(MountHttpDirTest, Rmdir) {
StringMap_t args;
- HttpFsForTesting fs(args, NULL);
+ MountHttpForTesting mnt(args, NULL);
char manifest[] = "-r-- 123 /mydir/foo\n-rw- 234 /thatdir/bar\n";
- ASSERT_EQ(0, fs.ParseManifest(manifest));
+ ASSERT_EQ(0, mnt.ParseManifest(manifest));
// Rmdir on existing dirs should give "Permission Denied"
- EXPECT_EQ(EACCES, fs.Rmdir(Path("/")));
- EXPECT_EQ(EACCES, fs.Rmdir(Path("/mydir")));
+ EXPECT_EQ(EACCES, mnt.Rmdir(Path("/")));
+ EXPECT_EQ(EACCES, mnt.Rmdir(Path("/mydir")));
// Rmdir on existing files should give "Not a direcotory"
- EXPECT_EQ(ENOTDIR, fs.Rmdir(Path("/mydir/foo")));
+ EXPECT_EQ(ENOTDIR, mnt.Rmdir(Path("/mydir/foo")));
// Rmdir on non-existent files should give "No such file or directory"
- EXPECT_EQ(ENOENT, fs.Rmdir(Path("/non_existent")));
+ EXPECT_EQ(ENOENT, mnt.Rmdir(Path("/non_existent")));
}
-TEST(HttpFsDirTest, Unlink) {
+TEST(MountHttpDirTest, Unlink) {
StringMap_t args;
- HttpFsForTesting fs(args, NULL);
+ MountHttpForTesting mnt(args, NULL);
char manifest[] = "-r-- 123 /mydir/foo\n-rw- 234 /thatdir/bar\n";
- ASSERT_EQ(0, fs.ParseManifest(manifest));
+ ASSERT_EQ(0, mnt.ParseManifest(manifest));
// Unlink of existing files should give "Permission Denied"
- EXPECT_EQ(EACCES, fs.Unlink(Path("/mydir/foo")));
+ EXPECT_EQ(EACCES, mnt.Unlink(Path("/mydir/foo")));
// Unlink of existing directory should give "Is a directory"
- EXPECT_EQ(EISDIR, fs.Unlink(Path("/mydir")));
+ EXPECT_EQ(EISDIR, mnt.Unlink(Path("/mydir")));
// Unlink of non-existent files should give "No such file or directory"
- EXPECT_EQ(ENOENT, fs.Unlink(Path("/non_existent")));
+ EXPECT_EQ(ENOENT, mnt.Unlink(Path("/non_existent")));
}
-TEST(HttpFsDirTest, Remove) {
+TEST(MountHttpDirTest, Remove) {
StringMap_t args;
- HttpFsForTesting fs(args, NULL);
+ MountHttpForTesting mnt(args, NULL);
char manifest[] = "-r-- 123 /mydir/foo\n-rw- 234 /thatdir/bar\n";
- ASSERT_EQ(0, fs.ParseManifest(manifest));
+ ASSERT_EQ(0, mnt.ParseManifest(manifest));
// Remove of existing files should give "Permission Denied"
- EXPECT_EQ(EACCES, fs.Remove(Path("/mydir/foo")));
+ EXPECT_EQ(EACCES, mnt.Remove(Path("/mydir/foo")));
// Remove of existing directory should give "Permission Denied"
- EXPECT_EQ(EACCES, fs.Remove(Path("/mydir")));
+ EXPECT_EQ(EACCES, mnt.Remove(Path("/mydir")));
// Unlink of non-existent files should give "No such file or directory"
- EXPECT_EQ(ENOENT, fs.Remove(Path("/non_existent")));
+ EXPECT_EQ(ENOENT, mnt.Remove(Path("/non_existent")));
}
-TEST(HttpFsDirTest, ParseManifest) {
+TEST(MountHttpDirTest, ParseManifest) {
StringMap_t args;
size_t result_size = 0;
- HttpFsForTesting fs(args, NULL);
+ MountHttpForTesting mnt(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, fs.ParseManifest(manifest));
+ ASSERT_EQ(0, mnt.ParseManifest(manifest));
- ScopedNode root;
- EXPECT_EQ(0, fs.FindOrCreateDir(Path("/"), &root));
- ASSERT_NE((Node*)NULL, root.get());
+ ScopedMountNode root;
+ EXPECT_EQ(0, mnt.FindOrCreateDir(Path("/"), &root));
+ ASSERT_NE((MountNode*)NULL, root.get());
EXPECT_EQ(2, root->ChildCount());
- ScopedNode dir;
- EXPECT_EQ(0, fs.FindOrCreateDir(Path("/mydir"), &dir));
- ASSERT_NE((Node*)NULL, dir.get());
+ ScopedMountNode dir;
+ EXPECT_EQ(0, mnt.FindOrCreateDir(Path("/mydir"), &dir));
+ ASSERT_NE((MountNode*)NULL, dir.get());
EXPECT_EQ(1, dir->ChildCount());
- Node* node = (*fs.GetNodeCacheForTesting())["/mydir/foo"].get();
- EXPECT_NE((Node*)NULL, node);
+ MountNode* node = (*mnt.GetNodeCacheForTesting())["/mydir/foo"].get();
+ EXPECT_NE((MountNode*)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.
- ScopedNode foo;
- ASSERT_EQ(0, fs.Open(Path("/mydir/foo"), O_RDONLY, &foo));
+ ScopedMountNode foo;
+ ASSERT_EQ(0, mnt.Open(Path("/mydir/foo"), O_RDONLY, &foo));
- ScopedNode bar;
- ASSERT_EQ(0, fs.Open(Path("/thatdir/bar"), O_RDWR, &bar));
+ ScopedMountNode bar;
+ ASSERT_EQ(0, mnt.Open(Path("/thatdir/bar"), O_RDWR, &bar));
struct stat sfoo;
struct stat sbar;
diff --git a/native_client_sdk/src/tests/nacl_io_test/mock_fs.cc b/native_client_sdk/src/tests/nacl_io_test/mount_mock.cc
index 6d7f4b1..1006822 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mock_fs.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/mount_mock.cc
@@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "mock_fs.h"
+#include "mount_mock.h"
-MockFs::MockFs() {}
+MountMock::MountMock() {}
+
+MountMock::~MountMock() {}
-MockFs::~MockFs() {}
diff --git a/native_client_sdk/src/tests/nacl_io_test/mock_fs.h b/native_client_sdk/src/tests/nacl_io_test/mount_mock.h
index e0dd5e8..cde3bbb 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mock_fs.h
+++ b/native_client_sdk/src/tests/nacl_io_test/mount_mock.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_MOCK_FS_H_
-#define LIBRARIES_NACL_IO_TEST_MOCK_FS_H_
+#ifndef LIBRARIES_NACL_IO_TEST_MOUNT_MOCK_H_
+#define LIBRARIES_NACL_IO_TEST_MOUNT_MOCK_H_
#include "gmock/gmock.h"
-#include "nacl_io/filesystem.h"
+#include "nacl_io/mount.h"
-class MockFs : public nacl_io::Filesystem {
+class MountMock : public nacl_io::Mount {
public:
typedef nacl_io::Error Error;
- typedef nacl_io::FsInitArgs FsInitArgs;
+ typedef nacl_io::MountInitArgs MountInitArgs;
typedef nacl_io::Path Path;
typedef nacl_io::PepperInterface PepperInterface;
- typedef nacl_io::ScopedNode ScopedNode;
+ typedef nacl_io::ScopedMountNode ScopedMountNode;
typedef nacl_io::StringMap_t StringMap_t;
- MockFs();
- virtual ~MockFs();
+ MountMock();
+ virtual ~MountMock();
- MOCK_METHOD1(Init, Error(const FsInitArgs&));
+ MOCK_METHOD1(Init, Error(const MountInitArgs&));
MOCK_METHOD0(Destroy, void());
MOCK_METHOD2(Access, Error(const Path&, int));
- MOCK_METHOD3(Open, Error(const Path&, int, ScopedNode*));
- MOCK_METHOD2(OpenResource, Error(const Path&, ScopedNode*));
+ MOCK_METHOD3(Open, Error(const Path&, int, ScopedMountNode*));
+ MOCK_METHOD2(OpenResource, Error(const Path&, ScopedMountNode*));
MOCK_METHOD1(Unlink, Error(const Path&));
MOCK_METHOD2(Mkdir, Error(const Path&, int));
MOCK_METHOD1(Rmdir, Error(const Path&));
@@ -33,4 +33,4 @@ class MockFs : public nacl_io::Filesystem {
MOCK_METHOD2(Rename, Error(const Path&, const Path&));
};
-#endif // LIBRARIES_NACL_IO_TEST_MOCK_FS_H_
+#endif // LIBRARIES_NACL_IO_TEST_MOUNT_MOCK_H_
diff --git a/native_client_sdk/src/tests/nacl_io_test/mock_node.cc b/native_client_sdk/src/tests/nacl_io_test/mount_node_mock.cc
index 1cc21f7..695af3a 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mock_node.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/mount_node_mock.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 "mock_node.h"
+#include "mount_node_mock.h"
-MockNode::MockNode(nacl_io::Filesystem* mount) : Node(mount) {}
+MountNodeMock::MountNodeMock(nacl_io::Mount* mount) : MountNode(mount) {}
-MockNode::~MockNode() {}
+MountNodeMock::~MountNodeMock() {}
diff --git a/native_client_sdk/src/tests/nacl_io_test/mock_node.h b/native_client_sdk/src/tests/nacl_io_test/mount_node_mock.h
index c1113be..2edd767 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mock_node.h
+++ b/native_client_sdk/src/tests/nacl_io_test/mount_node_mock.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_MOCK_NODE_H_
-#define LIBRARIES_NACL_IO_TEST_MOCK_NODE_H_
+#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/filesystem.h"
#include "nacl_io/kernel_handle.h"
+#include "nacl_io/mount.h"
-class MockNode : public nacl_io::Node {
+class MountNodeMock : public nacl_io::MountNode {
public:
typedef nacl_io::Error Error;
typedef nacl_io::HandleAttr HandleAttr;
- typedef nacl_io::ScopedNode ScopedNode;
+ typedef nacl_io::ScopedMountNode ScopedMountNode;
- explicit MockNode(nacl_io::Filesystem*);
- virtual ~MockNode();
+ explicit MountNodeMock(nacl_io::Mount*);
+ virtual ~MountNodeMock();
MOCK_METHOD1(Init, Error(int));
MOCK_METHOD0(Destroy, void());
@@ -37,11 +37,11 @@ class MockNode : public nacl_io::Node {
MOCK_METHOD0(IsaFile, bool());
MOCK_METHOD0(IsaTTY, bool());
MOCK_METHOD0(ChildCount, int());
- MOCK_METHOD2(AddChild, Error(const std::string&, const ScopedNode&));
+ MOCK_METHOD2(AddChild, Error(const std::string&, const ScopedMountNode&));
MOCK_METHOD1(RemoveChild, Error(const std::string&));
- MOCK_METHOD2(FindChild, Error(const std::string&, ScopedNode*));
+ MOCK_METHOD2(FindChild, Error(const std::string&, ScopedMountNode*));
MOCK_METHOD0(Link, void());
MOCK_METHOD0(Unlink, void());
};
-#endif // LIBRARIES_NACL_IO_TEST_MOCK_NODE_H_
+#endif // LIBRARIES_NACL_IO_TEST_MOUNT_NODE_MOCK_H_
diff --git a/native_client_sdk/src/tests/nacl_io_test/mem_fs_node_test.cc b/native_client_sdk/src/tests/nacl_io_test/mount_node_test.cc
index e6ea301..efa9c80 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mem_fs_node_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/mount_node_test.cc
@@ -10,64 +10,60 @@
#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/memfs/mem_fs.h"
-#include "nacl_io/memfs/mem_fs_node.h"
-#include "nacl_io/node.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/osdirent.h"
-#define NULL_NODE ((Node*)NULL)
+#define NULL_NODE ((MountNode*) NULL)
using namespace nacl_io;
-static int s_alloc_num = 0;
+static int s_AllocNum = 0;
-namespace {
-
-class MemFsForTesting : public MemFs {
+class MockMount : public MountMem {
public:
- MemFsForTesting() {
- FsInitArgs args(1);
+ MockMount() {
+ MountInitArgs args(1);
EXPECT_EQ(0, Init(args));
}
int num_nodes() { return inode_pool_.size(); }
};
-class MemFsNodeForTesting : public MemFsNode {
+class MockNode : public MountNodeMem {
public:
- MemFsNodeForTesting() : MemFsNode(NULL) { s_alloc_num++; }
+ MockNode() : MountNodeMem(NULL) { s_AllocNum++; }
- ~MemFsNodeForTesting() { s_alloc_num--; }
+ ~MockNode() { s_AllocNum--; }
- using MemFsNode::Init;
- using MemFsNode::AddChild;
- using MemFsNode::RemoveChild;
- using MemFsNode::FindChild;
+ using MountNodeMem::Init;
+ using MountNodeMem::AddChild;
+ using MountNodeMem::RemoveChild;
+ using MountNodeMem::FindChild;
};
-class DirNodeForTesting : public DirNode {
+class MockDir : public MountNodeDir {
public:
- DirNodeForTesting() : DirNode(NULL) { s_alloc_num++; }
+ MockDir() : MountNodeDir(NULL) { s_AllocNum++; }
- ~DirNodeForTesting() { s_alloc_num--; }
+ ~MockDir() { s_AllocNum--; }
- using DirNode::Init;
- using DirNode::AddChild;
- using DirNode::RemoveChild;
- using DirNode::FindChild;
+ using MountNodeDir::Init;
+ using MountNodeDir::AddChild;
+ using MountNodeDir::RemoveChild;
+ using MountNodeDir::FindChild;
};
-} // namespace
-
-TEST(MemFsNodeTest, File) {
- MemFsNodeForTesting file;
- ScopedNode result_node;
+TEST(MountNodeTest, File) {
+ MockNode file;
+ ScopedMountNode result_node;
size_t result_size = 0;
int result_bytes = 0;
@@ -118,8 +114,8 @@ TEST(MemFsNodeTest, File) {
EXPECT_EQ(NULL_NODE, result_node.get());
}
-TEST(MemFsNodeTest, FTruncate) {
- MemFsNodeForTesting file;
+TEST(MountNodeTest, FTruncate) {
+ MockNode file;
size_t result_size = 0;
int result_bytes = 0;
@@ -165,11 +161,11 @@ TEST(MemFsNodeTest, FTruncate) {
EXPECT_EQ(0, memcmp(buffer, data, 100));
}
-TEST(MemFsNodeTest, Fcntl_GETFL) {
- MemFsNodeForTesting* node = new MemFsNodeForTesting();
- ScopedFilesystem fs(new MemFsForTesting());
- ScopedNode file(node);
- KernelHandle handle(fs, file);
+TEST(MountNodeTest, Fcntl_GETFL) {
+ MockNode* node = new MockNode();
+ ScopedMount mnt(new MockMount());
+ ScopedMountNode file(node);
+ KernelHandle handle(mnt, file);
ASSERT_EQ(0, handle.Init(O_CREAT | O_APPEND));
// Test invalid fcntl command.
@@ -193,10 +189,10 @@ TEST(MemFsNodeTest, Fcntl_GETFL) {
ASSERT_EQ(EPERM, handle.Fcntl(F_SETFL, NULL, flags));
}
-TEST(MemFsNodeTest, Directory) {
- s_alloc_num = 0;
- DirNodeForTesting root;
- ScopedNode result_node;
+TEST(MountNodeTest, Directory) {
+ s_AllocNum = 0;
+ MockDir root;
+ ScopedMountNode result_node;
size_t result_size = 0;
int result_bytes = 0;
@@ -221,9 +217,9 @@ TEST(MemFsNodeTest, Directory) {
EXPECT_EQ(EISDIR, root.Write(attr, buf1, sizeof(buf1), &result_bytes));
// Test directory operations
- MemFsNodeForTesting* raw_file = new MemFsNodeForTesting;
+ MockNode* raw_file = new MockNode;
EXPECT_EQ(0, raw_file->Init(0));
- ScopedNode file(raw_file);
+ ScopedMountNode file(raw_file);
EXPECT_EQ(0, root.RefCount());
EXPECT_EQ(1, file->RefCount());
@@ -265,7 +261,7 @@ TEST(MemFsNodeTest, Directory) {
EXPECT_EQ(2, file->GetLinks());
EXPECT_EQ(3, file->RefCount());
- EXPECT_EQ(2, s_alloc_num);
+ EXPECT_EQ(2, s_AllocNum);
EXPECT_EQ(0, root.FindChild("F1", &result_node));
EXPECT_NE(NULL_NODE, result_node.get());
EXPECT_EQ(0, root.FindChild("F2", &result_node));
@@ -273,23 +269,23 @@ TEST(MemFsNodeTest, Directory) {
EXPECT_EQ(ENOENT, root.FindChild("F3", &result_node));
EXPECT_EQ(NULL_NODE, result_node.get());
- EXPECT_EQ(2, s_alloc_num);
+ EXPECT_EQ(2, s_AllocNum);
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_alloc_num);
+ EXPECT_EQ(2, s_AllocNum);
file.reset();
- EXPECT_EQ(1, s_alloc_num);
+ EXPECT_EQ(1, s_AllocNum);
}
-TEST(MemFsNodeTest, OpenMode) {
- MemFsNodeForTesting* node = new MemFsNodeForTesting();
- ScopedFilesystem fs(new MemFsForTesting());
- ScopedNode file(node);
+TEST(MountNodeTest, OpenMode) {
+ MockNode* node = new MockNode();
+ ScopedMount mnt(new MockMount());
+ ScopedMountNode file(node);
const char write_buf[] = "hello world";
char read_buf[10];
@@ -297,7 +293,7 @@ TEST(MemFsNodeTest, OpenMode) {
// Write some data to the file
{
- KernelHandle handle(fs, file);
+ KernelHandle handle(mnt, 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));
@@ -306,7 +302,7 @@ TEST(MemFsNodeTest, OpenMode) {
// Reading from the O_WRONLY handle should be impossible
{
byte_count = 0;
- KernelHandle handle(fs, file);
+ KernelHandle handle(mnt, 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));
@@ -316,7 +312,7 @@ TEST(MemFsNodeTest, OpenMode) {
// Writing to a O_RDONLY handle should fail
{
byte_count = 0;
- KernelHandle handle(fs, file);
+ KernelHandle handle(mnt, 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/tty_test.cc b/native_client_sdk/src/tests/nacl_io_test/mount_node_tty_test.cc
index d79d8ea..04cd84f 100644
--- a/native_client_sdk/src/tests/nacl_io_test/tty_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/mount_node_tty_test.cc
@@ -11,13 +11,14 @@
#include <sys/time.h>
#include <string>
-#include "dev_fs_for_testing.h"
#include "gtest/gtest.h"
-#include "nacl_io/devfs/dev_fs.h"
-#include "nacl_io/filesystem.h"
+#include "mount_dev_mock.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;
@@ -28,9 +29,9 @@ class TtyTest : public ::testing::Test {
public:
void SetUp() {
ki_init(&kp_);
- 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_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_NE(NULL_NODE, dev_tty_.get());
}
@@ -40,8 +41,8 @@ class TtyTest : public ::testing::Test {
protected:
KernelProxy kp_;
- DevFsForTesting fs_;
- ScopedNode dev_tty_;
+ MountDevMock mnt_;
+ ScopedMountNode dev_tty_;
};
TEST_F(TtyTest, InvalidIoctl) {
diff --git a/native_client_sdk/src/tests/nacl_io_test/filesystem_test.cc b/native_client_sdk/src/tests/nacl_io_test/mount_test.cc
index 41bdadd..bbea69e 100644
--- a/native_client_sdk/src/tests/nacl_io_test/filesystem_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/mount_test.cc
@@ -8,12 +8,12 @@
#include <sys/stat.h>
#include <string>
-#include "dev_fs_for_testing.h"
#include "gtest/gtest.h"
-#include "nacl_io/filesystem.h"
+#include "mount_dev_mock.h"
#include "nacl_io/ioctl.h"
#include "nacl_io/kernel_handle.h"
-#include "nacl_io/memfs/mem_fs.h"
+#include "nacl_io/mount.h"
+#include "nacl_io/mount_mem.h"
#include "nacl_io/osdirent.h"
#include "nacl_io/osunistd.h"
@@ -21,58 +21,58 @@ using namespace nacl_io;
namespace {
-class MemFsForTesting : public MemFs {
+class MountMemMock : public MountMem {
public:
- MemFsForTesting() {
- FsInitArgs args(1);
+ MountMemMock() {
+ MountInitArgs 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(FilesystemTest, Sanity) {
- MemFsForTesting fs;
+TEST(MountTest, Sanity) {
+ MountMemMock mnt;
- ScopedNode file;
- ScopedNode root;
- ScopedNode result_node;
+ ScopedMountNode file;
+ ScopedMountNode root;
+ ScopedMountNode result_node;
size_t result_size = 0;
int result_bytes = 0;
char buf1[1024];
- // A memory filesystem starts with one directory node: the root.
- EXPECT_EQ(1, fs.num_nodes());
+ // A memory mount starts with one directory node: the root.
+ EXPECT_EQ(1, mnt.num_nodes());
// Fail to open non existent file
- EXPECT_EQ(ENOENT, fs.Access(Path("/foo"), R_OK | W_OK));
- EXPECT_EQ(ENOENT, fs.Open(Path("/foo"), O_RDWR, &result_node));
+ EXPECT_EQ(ENOENT, mnt.Access(Path("/foo"), R_OK | W_OK));
+ EXPECT_EQ(ENOENT, mnt.Open(Path("/foo"), O_RDWR, &result_node));
EXPECT_EQ(NULL, result_node.get());
- EXPECT_EQ(1, fs.num_nodes());
+ EXPECT_EQ(1, mnt.num_nodes());
// Create a file
- EXPECT_EQ(0, fs.Open(Path("/foo"), O_RDWR | O_CREAT, &file));
+ EXPECT_EQ(0, mnt.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, fs.num_nodes());
+ EXPECT_EQ(2, mnt.num_nodes());
EXPECT_EQ(2, file->RefCount());
- EXPECT_EQ(0, fs.Access(Path("/foo"), R_OK | W_OK));
- EXPECT_EQ(EACCES, fs.Access(Path("/foo"), X_OK));
+ EXPECT_EQ(0, mnt.Access(Path("/foo"), R_OK | W_OK));
+ EXPECT_EQ(EACCES, mnt.Access(Path("/foo"), X_OK));
// All access should be allowed on the root directory.
- EXPECT_EQ(0, fs.Access(Path("/"), R_OK | W_OK | X_OK));
+ EXPECT_EQ(0, mnt.Access(Path("/"), R_OK | W_OK | X_OK));
// Open the root directory for write should fail.
- EXPECT_EQ(EISDIR, fs.Open(Path("/"), O_RDWR, &root));
- EXPECT_EQ(2, fs.num_nodes());
+ EXPECT_EQ(EISDIR, mnt.Open(Path("/"), O_RDWR, &root));
+ EXPECT_EQ(2, mnt.num_nodes());
// Open the root directory, should not create a new file
- EXPECT_EQ(0, fs.Open(Path("/"), O_RDONLY, &root));
- EXPECT_EQ(2, fs.num_nodes());
+ EXPECT_EQ(0, mnt.Open(Path("/"), O_RDONLY, &root));
+ EXPECT_EQ(2, mnt.num_nodes());
ASSERT_NE(NULL_NODE, root.get());
struct dirent dirs[4];
int len;
@@ -82,13 +82,13 @@ TEST(FilesystemTest, Sanity) {
// Fail to re-create the same file
EXPECT_EQ(EEXIST,
- fs.Open(Path("/foo"), O_RDWR | O_CREAT | O_EXCL, &result_node));
+ mnt.Open(Path("/foo"), O_RDWR | O_CREAT | O_EXCL, &result_node));
EXPECT_EQ(NULL_NODE, result_node.get());
- EXPECT_EQ(2, fs.num_nodes());
+ EXPECT_EQ(2, mnt.num_nodes());
// Fail to create a directory with the same name
- EXPECT_EQ(EEXIST, fs.Mkdir(Path("/foo"), O_RDWR));
- EXPECT_EQ(2, fs.num_nodes());
+ EXPECT_EQ(EEXIST, mnt.Mkdir(Path("/foo"), O_RDWR));
+ EXPECT_EQ(2, mnt.num_nodes());
HandleAttr attrs;
@@ -101,187 +101,188 @@ TEST(FilesystemTest, 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, fs.num_nodes());
+ EXPECT_EQ(2, mnt.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, fs.Open(Path("/foo"), O_RDWR | O_CREAT, &result_node));
+ EXPECT_EQ(0, mnt.Open(Path("/foo"), O_RDWR | O_CREAT, &result_node));
EXPECT_EQ(3, file->RefCount());
- EXPECT_EQ(2, fs.num_nodes());
+ EXPECT_EQ(2, mnt.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 Filesystem holds it
+ // Remove our references so that only the Mount holds it
file.reset();
result_node.reset();
- EXPECT_EQ(2, fs.num_nodes());
+ EXPECT_EQ(2, mnt.num_nodes());
// This should have deleted the object
- EXPECT_EQ(0, fs.Unlink(Path("/foo")));
- EXPECT_EQ(1, fs.num_nodes());
+ EXPECT_EQ(0, mnt.Unlink(Path("/foo")));
+ EXPECT_EQ(1, mnt.num_nodes());
// We should fail to find it
- EXPECT_EQ(ENOENT, fs.Unlink(Path("/foo")));
- EXPECT_EQ(1, fs.num_nodes());
+ EXPECT_EQ(ENOENT, mnt.Unlink(Path("/foo")));
+ EXPECT_EQ(1, mnt.num_nodes());
// Recreate foo as a directory
- EXPECT_EQ(0, fs.Mkdir(Path("/foo"), O_RDWR));
- EXPECT_EQ(2, fs.num_nodes());
+ EXPECT_EQ(0, mnt.Mkdir(Path("/foo"), O_RDWR));
+ EXPECT_EQ(2, mnt.num_nodes());
// Create a file (exclusively)
- EXPECT_EQ(0, fs.Open(Path("/foo/bar"), O_RDWR | O_CREAT | O_EXCL, &file));
+ EXPECT_EQ(0, mnt.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, fs.num_nodes());
+ EXPECT_EQ(3, mnt.num_nodes());
// Attempt to delete the directory and fail
- EXPECT_EQ(ENOTEMPTY, fs.Rmdir(Path("/foo")));
+ EXPECT_EQ(ENOTEMPTY, mnt.Rmdir(Path("/foo")));
EXPECT_EQ(2, root->RefCount());
EXPECT_EQ(2, file->RefCount());
- EXPECT_EQ(3, fs.num_nodes());
+ EXPECT_EQ(3, mnt.num_nodes());
// Unlink the file, we should have the only file ref at this point.
- EXPECT_EQ(0, fs.Unlink(Path("/foo/bar")));
+ EXPECT_EQ(0, mnt.Unlink(Path("/foo/bar")));
EXPECT_EQ(2, root->RefCount());
EXPECT_EQ(1, file->RefCount());
- EXPECT_EQ(3, fs.num_nodes());
+ EXPECT_EQ(3, mnt.num_nodes());
// Deref the file, to make it go away
file.reset();
- EXPECT_EQ(2, fs.num_nodes());
+ EXPECT_EQ(2, mnt.num_nodes());
// Deref the directory
- EXPECT_EQ(0, fs.Rmdir(Path("/foo")));
- EXPECT_EQ(1, fs.num_nodes());
+ EXPECT_EQ(0, mnt.Rmdir(Path("/foo")));
+ EXPECT_EQ(1, mnt.num_nodes());
// Verify the directory is gone
- EXPECT_EQ(ENOENT, fs.Access(Path("/foo"), F_OK));
- EXPECT_EQ(ENOENT, fs.Open(Path("/foo"), O_RDWR, &file));
+ EXPECT_EQ(ENOENT, mnt.Access(Path("/foo"), F_OK));
+ EXPECT_EQ(ENOENT, mnt.Open(Path("/foo"), O_RDWR, &file));
EXPECT_EQ(NULL_NODE, file.get());
}
-TEST(FilesystemTest, OpenMode_TRUNC) {
- MemFsForTesting fs;
- ScopedNode file;
- ScopedNode root;
- ScopedNode result_node;
+TEST(MountTest, OpenMode_TRUNC) {
+ MountMemMock mnt;
+ ScopedMountNode file;
+ ScopedMountNode root;
+ ScopedMountNode result_node;
HandleAttr attrs;
int result_bytes;
// Open a file and write something to it.
const char* buf = "hello";
- ASSERT_EQ(0, fs.Open(Path("/foo"), O_RDWR | O_CREAT, &file));
+ ASSERT_EQ(0, mnt.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, fs.Open(Path("/foo"), O_RDWR | O_TRUNC, &file));
+ ASSERT_EQ(0, mnt.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(FilesystemTest, MemFsRemove) {
- MemFsForTesting fs;
- ScopedNode file;
- ScopedNode result_node;
+TEST(MountTest, MemMountRemove) {
+ MountMemMock mnt;
+ ScopedMountNode file;
+ ScopedMountNode result_node;
- ASSERT_EQ(0, fs.Mkdir(Path("/dir"), O_RDWR));
- ASSERT_EQ(0, fs.Open(Path("/file"), O_RDWR | O_CREAT | O_EXCL, &file));
+ ASSERT_EQ(0, mnt.Mkdir(Path("/dir"), O_RDWR));
+ ASSERT_EQ(0, mnt.Open(Path("/file"), O_RDWR | O_CREAT | O_EXCL, &file));
EXPECT_NE(NULL_NODE, file.get());
- EXPECT_EQ(3, fs.num_nodes());
+ EXPECT_EQ(3, mnt.num_nodes());
file.reset();
- 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());
+ 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());
- ASSERT_EQ(ENOENT, fs.Open(Path("/dir/foo"), O_CREAT | O_RDWR, &result_node));
+ ASSERT_EQ(ENOENT,
+ mnt.Open(Path("/dir/foo"), O_CREAT | O_RDWR, &result_node));
ASSERT_EQ(NULL_NODE, result_node.get());
- ASSERT_EQ(ENOENT, fs.Open(Path("/file"), O_RDONLY, &result_node));
+ ASSERT_EQ(ENOENT, mnt.Open(Path("/file"), O_RDONLY, &result_node));
ASSERT_EQ(NULL_NODE, result_node.get());
}
-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());
+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());
- 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());
+ 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());
// Move from one directory to another should ok
- 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());
+ 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());
// Move within the same directory
- 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());
+ 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());
// Move to another directory but without a filename
- 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());
+ 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());
}
-TEST(FilesystemTest, MemFsRenameDir) {
- MemFsForTesting fs;
+TEST(MountTest, MemMountRenameDir) {
+ MountMemMock mnt;
- ASSERT_EQ(0, fs.Mkdir(Path("/dir1"), O_RDWR));
- ASSERT_EQ(0, fs.Mkdir(Path("/dir2"), O_RDWR));
- EXPECT_EQ(3, fs.num_nodes());
+ ASSERT_EQ(0, mnt.Mkdir(Path("/dir1"), O_RDWR));
+ ASSERT_EQ(0, mnt.Mkdir(Path("/dir2"), O_RDWR));
+ EXPECT_EQ(3, mnt.num_nodes());
// Renaming one directory to another should work
- 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());
+ 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());
// Reset to initial state
- ASSERT_EQ(0, fs.Mkdir(Path("/dir1"), O_RDWR));
- EXPECT_EQ(3, fs.num_nodes());
+ ASSERT_EQ(0, mnt.Mkdir(Path("/dir1"), O_RDWR));
+ EXPECT_EQ(3, mnt.num_nodes());
// Renaming a directory to a new name within another
- 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());
+ 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());
// Reset to initial state
- ASSERT_EQ(0, fs.Rmdir(Path("/dir2/foo")));
- ASSERT_EQ(0, fs.Mkdir(Path("/dir1"), O_RDWR));
- EXPECT_EQ(3, fs.num_nodes());
+ ASSERT_EQ(0, mnt.Rmdir(Path("/dir2/foo")));
+ ASSERT_EQ(0, mnt.Mkdir(Path("/dir1"), O_RDWR));
+ EXPECT_EQ(3, mnt.num_nodes());
// Renaming one directory to another should fail if the target is non-empty
- ASSERT_EQ(0, fs.Mkdir(Path("/dir2/dir3"), O_RDWR));
- ASSERT_EQ(ENOTEMPTY, fs.Rename(Path("/dir1"), Path("/dir2")));
+ ASSERT_EQ(0, mnt.Mkdir(Path("/dir2/dir3"), O_RDWR));
+ ASSERT_EQ(ENOTEMPTY, mnt.Rename(Path("/dir1"), Path("/dir2")));
}
-TEST(FilesystemTest, DevAccess) {
+TEST(MountTest, DevAccess) {
// Should not be able to open non-existent file.
- DevFsForTesting fs;
- ASSERT_EQ(ENOENT, fs.Access(Path("/foo"), F_OK));
+ MountDevMock mnt;
+ ASSERT_EQ(ENOENT, mnt.Access(Path("/foo"), F_OK));
}
-TEST(FilesystemTest, DevNull) {
- DevFsForTesting fs;
- ScopedNode dev_null;
+TEST(MountTest, DevNull) {
+ MountDevMock mnt;
+ ScopedMountNode dev_null;
int result_bytes = 0;
- 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_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_NE(NULL_NODE, dev_null.get());
// Writing to /dev/null should write everything.
@@ -297,14 +298,14 @@ TEST(FilesystemTest, DevNull) {
EXPECT_EQ(0, result_bytes);
}
-TEST(FilesystemTest, DevZero) {
- DevFsForTesting fs;
- ScopedNode dev_zero;
+TEST(MountTest, DevZero) {
+ MountDevMock mnt;
+ ScopedMountNode dev_zero;
int result_bytes = 0;
- 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_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_NE(NULL_NODE, dev_zero.get());
// Writing to /dev/zero should write everything.
@@ -327,14 +328,14 @@ TEST(FilesystemTest, DevZero) {
}
// Disabled due to intermittent failures on linux: http://crbug.com/257257
-TEST(FilesystemTest, DISABLED_DevUrandom) {
- DevFsForTesting fs;
- ScopedNode dev_urandom;
+TEST(MountTest, DISABLED_DevUrandom) {
+ MountDevMock mnt;
+ ScopedMountNode dev_urandom;
int result_bytes = 0;
- 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_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_NE(NULL_NODE, dev_urandom.get());
// Writing to /dev/urandom should write everything.
@@ -353,8 +354,8 @@ TEST(FilesystemTest, 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) {