try {
fs::create_directory(tmp_subsession_path);
} catch (const std::exception& ex) {
+ LOGE("Failed to create temp subsession dir '%s', uid=%d, gid=%d: %s", tmp_subsession_path.c_str(), uid, gid, ex.what());
fs::remove(image_path);
throw;
}
try {
+ /* The mountpoint's properties don't actually matter, since
+ * they are completely replaced with the image filesystem's
+ * root dir's, but this way they are consistent regardless of
+ * whether the image is mounted or not. */
+ OS::change_owner_and_group(tmp_subsession_path, uid, gid);
+
OS::do_mount(image_path, tmp_subsession_path);
} catch (const std::exception& ex) {
+ LOGE("Failed to change owner/group, path='%s', uid=%d, gid=%d: %s", tmp_subsession_path.c_str(), uid, gid, ex.what());
fs::remove(tmp_subsession_path);
fs::remove(image_path);
throw;
void DirBackendAddFixedSize::AddSubsessionFinalize (const fs::path& tmpdir_path, const fs::path& subsession_path, int uid, int gid) const
{
- umount_and_remove(tmpdir_path);
+ /* TODO: keep mounts! It should be possible to reuse the mount too,
+ * would need to introduce some sort of `mount --move` here */
+ if (OS::is_mountpoint(tmpdir_path))
+ OS::do_umount(tmpdir_path);
const auto image_path = DirBackendFixedSize::GetImagePathFromSubsessionPath(subsession_path);
auto temp_image_path = image_path;
/* Order matters - handle .img first and the directory last,
* since all other logic assumes that the existence of the dir
* signifies that a valid subsession exists. */
- fs::create_directory(subsession_path);
-
- /* The mountpoint's properties don't actually matter, since
- * they are completely replaced with the image filesystem's
- * root dir's, but this way they are consistent regardless of
- * whether the image is mounted or not. */
- OS::change_owner_and_group(subsession_path, uid, gid);
+ fs::rename(tmpdir_path, subsession_path);
}
void DirBackendFixedSize::RemoveSubsession (const fs::path& subsession_path) const