]> git.ipfire.org Git - people/ms/pakfire.git/blobdiff - src/libpakfire/mount.c
mount: Mount the interpreter every time
[people/ms/pakfire.git] / src / libpakfire / mount.c
index f7b1b966ad4ee16c584541a831c7b4dae02b80f0..52eb381cb1b5cfcc33c0614e26bfa1c051470ba4 100644 (file)
@@ -29,6 +29,7 @@
 // libmount
 #include <libmount/libmount.h>
 
+#include <pakfire/arch.h>
 #include <pakfire/logging.h>
 #include <pakfire/pakfire.h>
 #include <pakfire/mount.h>
@@ -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;
 }