From 00247c790128ad2b464baae9fa555b9cf2f8e546 Mon Sep 17 00:00:00 2001 From: canyie Date: Sun, 19 Jun 2022 15:25:56 +0800 Subject: [PATCH] Fix meizu non-SAR 2SI compatibility again Meizu devices using 2SI won't switch root to /system and still on rootfs, and /init is the 1st stage's, which cannot handle the 2nd stage. So we have to manually execute /system/bin/init for the 2nd stage. --- native/jni/init/twostage.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/native/jni/init/twostage.cpp b/native/jni/init/twostage.cpp index 6622ac852..b91f97259 100644 --- a/native/jni/init/twostage.cpp +++ b/native/jni/init/twostage.cpp @@ -80,9 +80,15 @@ bool SecondStageInit::prepare() { argv[0] = (char *) INIT_PATH; // Some weird devices like meizu, uses 2SI but still have legacy rootfs - // Check if root and system are on the same filesystem + // Check if root and system are on different filesystems struct stat root{}, system{}; xstat("/", &root); xstat("/system", &system); - return root.st_dev != system.st_dev; + if (root.st_dev != system.st_dev) { + // We are still on rootfs, so make sure we will execute the init of the 2nd stage + unlink("/init"); + xsymlink(INIT_PATH, "/init"); + return true; + } + return false; }