提交 f59a768b 编写于 作者: S Simon Fels

Use writable and persistent bind mounts for data, cache and storage

上级 09ec800e
......@@ -160,11 +160,9 @@ anbox::cmds::Run::Run(const BusFactory& bus_factory)
// A place where we can exchange files with the container
spec.bind_paths.insert({config::host_share_path(), config::container_share_path()});
// FIXME(morphis): those directories should be really somewhere on our
// persistent data directory so we keep any runtime data accross restarts.
spec.temporary_dirs.push_back("/data");
spec.temporary_dirs.push_back("/cache");
spec.temporary_dirs.push_back("/storage");
spec.bind_paths.insert({ config::host_android_data_path(), "/data" });
spec.bind_paths.insert({ config::host_android_cache_path(), "/cache" });
spec.bind_paths.insert({ config::host_android_storage_path(), "/storage" });
spec.temporary_dirs.push_back("/dev/input");
......
......@@ -46,5 +46,26 @@ std::string host_share_path() {
std::string container_share_path() {
return "/data/anbox-share";
}
std::string host_android_data_path() {
static std::string path;
if (path.length() == 0)
path = utils::string_format("%s/android-data", data_path());
return path;
}
std::string host_android_cache_path() {
static std::string path;
if (path.length() == 0)
path = utils::string_format("%s/android-cache", data_path());
return path;
}
std::string host_android_storage_path() {
static std::string path;
if (path.length() == 0)
path = utils::string_format("%s/android-storage", data_path());
return path;
}
} // namespace config
} // namespace anbox
......@@ -25,7 +25,9 @@ namespace config {
std::string data_path();
std::string host_share_path();
std::string container_share_path();
std::string host_android_data_path();
std::string host_android_cache_path();
std::string host_android_storage_path();
} // namespace config
} // namespace anbox
......
......@@ -54,10 +54,17 @@ catch(std::exception &err) {
}
void Daemon::ensure_data_path() {
if (!fs::is_directory(fs::path(config::data_path())))
fs::create_directories(fs::path(config::data_path()));
std::vector<std::string> paths = {
config::data_path(),
config::host_share_path(),
config::host_android_data_path(),
config::host_android_cache_path(),
config::host_android_storage_path()
};
if (!fs::is_directory(fs::path(config::host_share_path())))
fs::create_directories(fs::path(config::host_share_path()));
for (const auto &path: paths) {
if (!fs::is_directory(fs::path(path)))
fs::create_directories(fs::path(config::host_share_path()));
}
}
} // namespace anbox
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册