]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: Move root into mount map
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 21 Mar 2021 14:37:42 +0000 (14:37 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 21 Mar 2021 14:37:42 +0000 (14:37 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/pakfire.c

index bca06dd637b042bb6df4104e95239a126d68eddc..4c12ad5eaaa446e57da2cb0e1fd482bfb96348c0 100644 (file)
@@ -84,6 +84,8 @@ static const struct pakfire_mountpoint {
        int flags;
        const char* options;
 } mountpoints[] = {
+       { "pakfire_root",  "",             "tmpfs", 0, NULL },
+
        { "pakfire_proc",  "proc",         "proc",  MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL },
 
        // Bind mount /proc/sys as read-only with the following exceptions:
@@ -134,6 +136,10 @@ static int pakfire_mount(Pakfire pakfire) {
        int r;
 
        for (const struct pakfire_mountpoint* mp = mountpoints; mp->source; mp++) {
+               // Skip mounting root when operating in /
+               if (strcmp(pakfire->path, "/") == 0 && !*mp->target)
+                       continue;
+
                DEBUG(pakfire, "Mounting /%s\n", mp->target);
 
                char* target = pakfire_path_join(pakfire->path, mp->target);
@@ -419,11 +425,6 @@ 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(p, "pakfire_root", path, "tmpfs", 0, NULL);
-               if (r)
-                       goto ERROR;
        }
 
        // Set path