]> git.ipfire.org Git - pakfire.git/commitdiff
Always create temporary environments in tmpfs
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 21 Mar 2021 13:16:42 +0000 (13:16 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 21 Mar 2021 13:16:42 +0000 (13:16 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/pakfire.c

index 9f15401a02f02409a7ea246536d730356f1f40f0..1fc0f31e313f411ad5ab0be8f823302034e91a43 100644 (file)
@@ -138,9 +138,13 @@ ERROR:
 static void pakfire_free(Pakfire pakfire) {
        DEBUG(pakfire, "Releasing Pakfire at %p\n", pakfire);
 
-       if (pakfire->destroy_on_free) {
+       if (pakfire->destroy_on_free && *pakfire->path) {
                DEBUG(pakfire, "Destroying %s\n", pakfire->path);
 
+               // Umount the temporary file system
+               umount(pakfire->path);
+
+               // Destroy the temporary directory
                pakfire_rmtree(pakfire->path, 0);
        }
 
@@ -214,6 +218,11 @@ PAKFIRE_EXPORT int pakfire_create(Pakfire* pakfire, const char* path, const char
 
                // Destroy everything when done
                p->destroy_on_free = 1;
+
+               // Mount tmpfs
+               r = mount("pakfire_root", path, "tmpfs", 0, NULL);
+               if (r)
+                       goto ERROR;
        }
 
        // Set path