void DirBackendFixedSize::RemoveSubsession (const fs::path& subsession_path) const
{
+ if (OS::is_mountpoint(subsession_path))
+ do_umount(subsession_path);
+
fs::remove(subsession_path);
const auto image_path = GetImagePathFromSubsessionPath(subsession_path);
void DirBackendFixedSize::SwitchSubsessionAway (const fs::path& subsession_path) const
{
- /* Note, we cannot keep the subsession mounted permanently,
- * from Add until Remove, because reboots happen. */
- do_umount(subsession_path);
+ /* Keep session mounted during switch to reuse it if another switch happen.
+ * Addionally, it leaves subsession in same state as if sessiond would be restarted */
+ if (getenv("SESSIOND_NO_KEEP_SESSION_MOUNTS")) {
+ LOGI("Unmouting session image at %s", subsession_path.c_str());
+ do_umount(subsession_path);
+ } else
+ LOGI("Switching away from subsession but keeping image mounted at %s", subsession_path.c_str());
}
void DirBackendFixedSize::SwitchSubsessionInto (const fs::path& subsession_path) const
const auto image_path = GetImagePathFromSubsessionPath(subsession_path);
if (OS::is_mountpoint(subsession_path)) {
- LOGW("Session image already mounted (maybe earlier sessiond instance died?), reusing");
+ LOGI("Session image already mounted at %s, reusing", subsession_path.c_str());
return;
}