Eliminate unnecessarily copy on magiskinit

This patch reuses the abused /data tmpfs for magisktmp
This commit is contained in:
LoveSy
2022-12-14 21:14:12 +08:00
committed by John Wu
parent 0d38c94c9c
commit 4ed34cd648
4 changed files with 30 additions and 76 deletions

View File

@@ -25,6 +25,7 @@ struct BootConfig {
#define DEFAULT_DT_DIR "/proc/device-tree/firmware/android"
#define INIT_PATH "/system/bin/init"
#define REDIR_PATH "/data/magiskinit"
extern std::vector<std::string> mount_list;
@@ -48,6 +49,7 @@ protected:
char **argv = nullptr;
[[noreturn]] void exec_init();
void prepare_data();
public:
BaseInit(char *argv[], BootConfig *config = nullptr) : config(config), argv(argv) {}
virtual ~BaseInit() = default;
@@ -58,8 +60,6 @@ class MagiskInit : public BaseInit {
private:
void mount_rules_dir();
protected:
mmap_data self;
mmap_data magisk_cfg;
std::string custom_rules_dir;
#if ENABLE_AVD_HACK
@@ -72,16 +72,12 @@ protected:
bool hijack_sepolicy();
void setup_tmp(const char *path);
void patch_rw_root();
void patch_ro_root();
public:
using BaseInit::BaseInit;
};
class SARBase : public MagiskInit {
protected:
std::vector<raw_file> overlays;
void backup_files();
void patch_ro_root();
public:
using MagiskInit::MagiskInit;
};
@@ -134,6 +130,7 @@ public:
LOGD("%s\n", __FUNCTION__);
};
void start() override {
prepare_data();
if (mount_system_root())
first_stage_prep();
else