From 3a2262dfb31d81ae6ed4ce02015f0464c3481c4f Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Wed, 13 Sep 2017 04:06:39 +0800 Subject: [PATCH] Use backup init if booted as recovery --- jni/magiskinit.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/jni/magiskinit.c b/jni/magiskinit.c index 2dd918c8f..28819f5ad 100644 --- a/jni/magiskinit.c +++ b/jni/magiskinit.c @@ -1,3 +1,14 @@ +/* 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 #include #include @@ -287,7 +298,7 @@ int main(int argc, char *argv[]) { // Recovery mode // Revert original init binary unlink("/init"); - rename("/init_orig", "/init"); + rename("/.backup/init", "/init"); } execv("/init", argv);