From 5b0ccac2677bfaf1821c13571f68d3191dd10e5b Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 22 Nov 2024 11:30:33 +0000 Subject: [PATCH] pakfire: Ignore if we cannot mount tmpfs Signed-off-by: Michael Tremer --- src/libpakfire/pakfire.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index 462ecf1ac..4aff554b2 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -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; } } -- 2.39.5