]> git.ipfire.org Git - pakfire.git/commitdiff
pakfire: Ignore if we cannot mount tmpfs
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 22 Nov 2024 11:30:33 +0000 (11:30 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 22 Nov 2024 11:30:33 +0000 (11:30 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/pakfire.c

index 462ecf1ac9a0335555da104fb4a89b1f7439d227..4aff554b2ce5709a2773159c90d3188cd0cab94d 100644 (file)
@@ -796,6 +796,30 @@ ERROR:
        return r;
 }
 
+static int pakfire_mount_tmpfs(struct pakfire* pakfire, const char* path) {
+       int r;
+
+       // Mount!
+       r = mount("pakfire_root", path, "tmpfs", 0, NULL);
+       if (r) {
+               switch (errno) {
+                       // We might not have permission to mount tmpfs. Ignore that...
+                       case EPERM:
+                               DEBUG(pakfire->ctx, "We don't have permission to mount tmpfs. Ignoring.\n");
+                               return 0;
+
+                       default:
+                               ERROR(pakfire->ctx, "Could not mount tmpfs: %m\n");
+                               return -errno;
+               }
+       }
+
+       // Umount path later
+       pakfire->internal_flags |= PAKFIRE_UMOUNT_PATH;
+
+       return 0;
+}
+
 PAKFIRE_EXPORT int pakfire_create(struct pakfire** pakfire, struct pakfire_ctx* ctx,
                const char* path, const char* arch, FILE* conf, int flags) {
        struct pakfire* p = NULL;
@@ -933,15 +957,9 @@ PAKFIRE_EXPORT int pakfire_create(struct pakfire** pakfire, struct pakfire_ctx*
 
                // Mount a tmpfs
                } else {
-                       r = mount("pakfire_root", path, "tmpfs", 0, NULL);
-                       if (r) {
-                               ERROR(p->ctx, "Could not mount tmpfs: %m\n");
-                               r = -errno;
+                       r = pakfire_mount_tmpfs(p, path);
+                       if (r < 0)
                                goto ERROR;
-                       }
-
-                       // Umount path later
-                       p->internal_flags |= PAKFIRE_UMOUNT_PATH;
                }
        }