wip sandbox/klewandowski/generate-skel
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 25 Apr 2025 20:58:00 +0000 (22:58 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 25 Apr 2025 20:58:00 +0000 (22:58 +0200)
Change-Id: Ie6a75c79b92feff86a8a0c53d56105adcd4e13c6

src/service/src/dir_backend_fixed_size.cpp

index bb087b478bfff3f771d62bedee49bb6f23e5500c..811259cca404f98681f0090490b512c21956db69 100644 (file)
@@ -121,25 +121,31 @@ void DirBackendAddFixedSize::AddSubsessionCleanupFailure (const fs::path& tmpdir
 void DirBackendAddFixedSize::AddSubsessionFinalize (const fs::path& tmpdir_path, const fs::path& subsession_path, int uid, int gid) const
 {
        // XXX keep mounts! it should be possible to reuse this dir too!
+       // XXX this is pointless step, need to introduce mount --move
         // umount_and_remove(tmpdir_path);
+       if (OS::is_mountpoint(tmpdir_path))
+               do_umount(tmpdir_path);
 
        const auto image_path = DirBackendFixedSize::GetImagePathFromSubsessionPath(subsession_path);
-       auto temp_image_path = image_path;
-       temp_image_path.replace_filename(TMP_NEW_PREFIX + image_path.filename().native());
-       LOGI("rename %s %s", temp_image_path.data(), image_path.data());
-       fs::rename(temp_image_path, image_path);
+       auto tmp_image_path = image_path;
+       tmp_image_path.replace_filename(TMP_NEW_PREFIX + image_path.filename().native());
 
        /* The image file (as opposed to the FS inside it) doesn't
         * really need any rights, and maybe it would even be better
         * if it was harder to disrupt. This way all three concepts,
         * i.e. the image, the mount dir, and the FS root, are all
         * consistent with their rights though. */
-       OS::change_owner_and_group(image_path, uid, gid);
+       //LOGI("change_owner_and_group %s %s", tmp_image_path.c_str(), image_path.c_str());
+       OS::change_owner_and_group(tmp_image_path, uid, gid);
 
        /* 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);
+
+       //LOGI("rename %s %s", tmp_image_path.c_str(), image_path.c_str());
+       fs::rename(tmp_image_path, image_path);
+       //LOGI("rename %s %s", tmpdir_path.c_str(), subsession_path.c_str());
        fs::rename(tmpdir_path, subsession_path);
 
        /* The mountpoint's properties don't actually matter, since