-
Notifications
You must be signed in to change notification settings - Fork 1
/
Node.cc
52 lines (44 loc) · 1.67 KB
/
Node.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright Boston University SESA Group 2013 - 2014.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <signal.h>
#include <boost/filesystem.hpp>
#include <ebbrt/hosted/Context.h>
#include <ebbrt/hosted/ContextActivation.h>
#include <ebbrt/GlobalIdMap.h>
#include <ebbrt/hosted/NodeAllocator.h>
#include <ebbrt/Runtime.h>
#include <ebbrt-cmdline/CmdLineArgs.h>
#include <ebbrt-filesystem/FileSystem.h>
enum : ebbrt::EbbId {
kCmdLineArgsId = ebbrt::kFirstStaticUserId,
kFileSystemId
};
int main(int argc, char **argv) {
auto bindir = boost::filesystem::system_complete(argv[0]).parent_path() /
"/bm/node.elf32";
ebbrt::Runtime runtime;
ebbrt::Context c(runtime);
boost::asio::signal_set sig(c.io_service_, SIGINT);
{
ebbrt::ContextActivation activation(c);
// ensure clean quit on ctrl-c
sig.async_wait([&c](const boost::system::error_code &ec,
int signal_number) { c.io_service_.stop(); });
CmdLineArgs::Create(argc, argv, kCmdLineArgsId)
.Then([bindir](ebbrt::Future<ebbrt::EbbRef<CmdLineArgs>> f) {
f.Get();
// TODO(dschatz): Don't chain these futures, instead when_all them
FileSystem::PreCreate(kFileSystemId)
.Then([bindir](ebbrt::Future<void> f) {
f.Get();
FileSystem::Create(&FileSystem::CreateRep(kFileSystemId),
kFileSystemId);
ebbrt::node_allocator->AllocateNode(bindir.string(), 1, 1);
});
});
}
c.Run();
return 0;
}