From b24983257121ea0ab05c0f6892ac002e14006f3f Mon Sep 17 00:00:00 2001 From: LoveSy Date: Sat, 11 Feb 2023 16:20:24 +0800 Subject: [PATCH] Use statfs to check rootfs This helps support adb remount --- native/src/init/twostage.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/native/src/init/twostage.cpp b/native/src/init/twostage.cpp index e7fd1ee31..ca4529aa7 100644 --- a/native/src/init/twostage.cpp +++ b/native/src/init/twostage.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "init.hpp" @@ -39,11 +40,7 @@ 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 different filesystems - struct stat root{}, system{}; - xstat("/", &root); - xstat("/system", &system); - if (root.st_dev != system.st_dev) { + if (struct statfs sfs{}; statfs("/", &sfs) == 0 && sfs.f_type == RAMFS_MAGIC) { // We are still on rootfs, so make sure we will execute the init of the 2nd stage unlink("/init"); xsymlink(INIT_PATH, "/init");