From: Michael Tremer Date: Sun, 17 Jul 2022 18:25:48 +0000 (+0000) Subject: mount: Mount the interpreter every time X-Git-Tag: 0.9.28~693 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=660120b6447255777d26beb39da116bafd353797;p=pakfire.git mount: Mount the interpreter every time Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/mount.c b/src/libpakfire/mount.c index f7b1b966a..52eb381cb 100644 --- a/src/libpakfire/mount.c +++ b/src/libpakfire/mount.c @@ -29,6 +29,7 @@ // libmount #include +#include #include #include #include @@ -327,6 +328,44 @@ static int pakfire_populate_dev(struct pakfire* pakfire) { return 0; } +static int pakfire_mount_interpreter(struct pakfire* pakfire) { + char target[PATH_MAX]; + + // Fetch the target architecture + const char* arch = pakfire_get_arch(pakfire); + + // Can we emulate this architecture? + char* interpreter = pakfire_arch_find_interpreter(arch); + + // No interpreter required + if (!interpreter) + return 0; + + DEBUG(pakfire, "Mounting interpreter %s for %s\n", interpreter, arch); + + // Where to mount this? + int r = pakfire_make_path(pakfire, target, interpreter); + if (r < 0) + return r; + + // Create directory + r = pakfire_mkparentdir(target, 0); + if (r) + return r; + + // Create an empty file + FILE* f = fopen(target, "w"); + if (!f) + return 1; + fclose(f); + + r = pakfire_mount(pakfire, interpreter, target, NULL, MS_BIND|MS_RDONLY, NULL); + if (r) + ERROR(pakfire, "Could not mount interpreter %s to %s: %m\n", interpreter, target); + + return r; +} + int pakfire_mount_all(struct pakfire* pakfire) { char target[PATH_MAX]; char options[PATH_MAX]; @@ -369,6 +408,11 @@ RETRY: if (r) return r; + // Mount the interpreter (if needed) + r = pakfire_mount_interpreter(pakfire); + if (r) + return r; + return 0; } diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index 6547bd811..0c5bc8833 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -265,41 +265,6 @@ ERROR: return r; } -static int pakfire_mount_interpreter(struct pakfire* pakfire) { - char target[PATH_MAX]; - - // Can we emulate this architecture? - char* interpreter = pakfire_arch_find_interpreter(pakfire->arch); - - // No interpreter required - if (!interpreter) - return 0; - - DEBUG(pakfire, "Mounting interpreter %s for %s\n", interpreter, pakfire->arch); - - // Where to mount this? - int r = pakfire_make_path(pakfire, target, interpreter); - if (r < 0) - return r; - - // Create directory - r = pakfire_mkparentdir(target, 0); - if (r) - return r; - - // Create an empty file - FILE* f = fopen(target, "w"); - if (!f) - return 1; - fclose(f); - - r = pakfire_mount(pakfire, interpreter, target, NULL, MS_BIND|MS_RDONLY, NULL); - if (r) - ERROR(pakfire, "Could not mount interpreter %s to %s: %m\n", interpreter, target); - - return r; -} - static void pakfire_free(struct pakfire* pakfire) { struct pakfire_repo* repo = NULL; int r; @@ -765,11 +730,6 @@ PAKFIRE_EXPORT int pakfire_create(struct pakfire** pakfire, const char* path, goto ERROR; } - // Mount the interpreter (if needed) - r = pakfire_mount_interpreter(p); - if (r) - goto ERROR; - // Make path for private files char private_dir[PATH_MAX]; r = pakfire_make_path(p, private_dir, PAKFIRE_PRIVATE_DIR);