Commit 3a2262df authored by topjohnwu's avatar topjohnwu

Use backup init if booted as recovery

parent ff7c38f8
/* magiskinit.c - Workaround for skip_initramfs devices
*
* This code has to be compiled statically to work properly.
*
* Magiskinit will mount sysfs, parse through uevent files to make the system block device,
* then it'll mount the system partition and clone rootfs except files under /system.
* Folders placed in "overlay" will then be overlayed to the root.
* Lastly before giving control back to the real init, it'll patch the root files to load Magisk.
*/
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
...@@ -287,7 +298,7 @@ int main(int argc, char *argv[]) { ...@@ -287,7 +298,7 @@ int main(int argc, char *argv[]) {
// Recovery mode // Recovery mode
// Revert original init binary // Revert original init binary
unlink("/init"); unlink("/init");
rename("/init_orig", "/init"); rename("/.backup/init", "/init");
} }
execv("/init", argv); execv("/init", argv);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment