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.
This commit is contained in:
canyie 2022-06-19 15:25:56 +08:00 committed by John Wu
parent 3c75f474c6
commit 00247c7901

View File

@ -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;
}