diff --git a/src/anbox/cmds/run.cpp b/src/anbox/cmds/run.cpp index ccd87f9..54c01b0 100644 --- a/src/anbox/cmds/run.cpp +++ b/src/anbox/cmds/run.cpp @@ -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"); diff --git a/src/anbox/config.cpp b/src/anbox/config.cpp index 91be9be..18bf49e 100644 --- a/src/anbox/config.cpp +++ b/src/anbox/config.cpp @@ -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 diff --git a/src/anbox/config.h b/src/anbox/config.h index 2d52290..5de04f5 100644 --- a/src/anbox/config.h +++ b/src/anbox/config.h @@ -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 diff --git a/src/anbox/daemon.cpp b/src/anbox/daemon.cpp index 0882d51..da7735e 100644 --- a/src/anbox/daemon.cpp +++ b/src/anbox/daemon.cpp @@ -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 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