Remove SAR compatibility mode
This commit is contained in:
parent
490e6a6f23
commit
8c500709e4
@ -220,10 +220,7 @@ int main(int argc, char *argv[]) {
|
||||
if (cmd.force_normal_boot) {
|
||||
init = make_unique<ABFirstStageInit>(argv, &cmd);
|
||||
} else if (cmd.skip_initramfs) {
|
||||
if (access("/overlay", F_OK) == 0) /* Compatible mode */
|
||||
init = make_unique<SARCompatInit>(argv, &cmd);
|
||||
else
|
||||
init = make_unique<SARInit>(argv, &cmd);
|
||||
init = make_unique<SARInit>(argv, &cmd);
|
||||
} else {
|
||||
decompress_ramdisk();
|
||||
if (access("/sbin/recovery", F_OK) == 0 || access("/system/bin/recovery", F_OK) == 0)
|
||||
|
@ -60,20 +60,6 @@ public:
|
||||
MagiskInit(char *argv[], cmdline *cmd) : BaseInit(argv, cmd) {};
|
||||
};
|
||||
|
||||
class RootFSBase : public MagiskInit {
|
||||
protected:
|
||||
int root = -1;
|
||||
|
||||
virtual void setup_rootfs();
|
||||
public:
|
||||
RootFSBase(char *argv[], cmdline *cmd) : MagiskInit(argv, cmd) {};
|
||||
void start() override {
|
||||
early_mount();
|
||||
setup_rootfs();
|
||||
exec_init();
|
||||
}
|
||||
};
|
||||
|
||||
class SARBase : public MagiskInit {
|
||||
protected:
|
||||
raw_data config;
|
||||
@ -95,7 +81,7 @@ public:
|
||||
* *************/
|
||||
|
||||
class ABFirstStageInit : public BaseInit {
|
||||
protected:
|
||||
private:
|
||||
void prepare();
|
||||
public:
|
||||
ABFirstStageInit(char *argv[], cmdline *cmd) : BaseInit(argv, cmd) {};
|
||||
@ -106,7 +92,7 @@ public:
|
||||
};
|
||||
|
||||
class AFirstStageInit : public BaseInit {
|
||||
protected:
|
||||
private:
|
||||
void prepare();
|
||||
public:
|
||||
AFirstStageInit(char *argv[], cmdline *cmd) : BaseInit(argv, cmd) {};
|
||||
@ -139,23 +125,20 @@ public:
|
||||
* Initramfs
|
||||
* **********/
|
||||
|
||||
class RootFSInit : public RootFSBase {
|
||||
class RootFSInit : public MagiskInit {
|
||||
private:
|
||||
int root = -1;
|
||||
void setup_rootfs();
|
||||
protected:
|
||||
void early_mount() override;
|
||||
public:
|
||||
RootFSInit(char *argv[], cmdline *cmd) : RootFSBase(argv, cmd) {};
|
||||
};
|
||||
RootFSInit(char *argv[], cmdline *cmd) : MagiskInit(argv, cmd) {};
|
||||
|
||||
/* ****************
|
||||
* Compat-mode SAR
|
||||
* ****************/
|
||||
|
||||
class SARCompatInit : public RootFSBase {
|
||||
protected:
|
||||
void early_mount() override;
|
||||
void setup_rootfs() override;
|
||||
public:
|
||||
SARCompatInit(char *argv[], cmdline *cmd) : RootFSBase(argv, cmd) {};
|
||||
void start() override {
|
||||
early_mount();
|
||||
setup_rootfs();
|
||||
exec_init();
|
||||
}
|
||||
};
|
||||
|
||||
void load_kernel_info(cmdline *cmd);
|
||||
|
@ -112,10 +112,6 @@ static bool read_dt_fstab(cmdline *cmd, const char *name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#define link_root(name) \
|
||||
if (is_lnk("/system_root" name)) \
|
||||
cp_afc("/system_root" name, name)
|
||||
|
||||
#define mount_root(name) \
|
||||
if (!is_lnk("/" #name) && read_dt_fstab(cmd, #name)) { \
|
||||
LOGD("Early mount " #name "\n"); \
|
||||
@ -138,30 +134,6 @@ void RootFSInit::early_mount() {
|
||||
mount_root(odm);
|
||||
}
|
||||
|
||||
void SARCompatInit::early_mount() {
|
||||
full_read("/init", self.buf, self.sz);
|
||||
|
||||
LOGD("Cleaning rootfs\n");
|
||||
root = xopen("/", O_RDONLY | O_CLOEXEC);
|
||||
frm_rf(root, { ".backup", "overlay", "overlay.d", "proc", "sys" });
|
||||
|
||||
LOGD("Early mount system_root\n");
|
||||
sprintf(partname, "system%s", cmd->slot);
|
||||
setup_block();
|
||||
xmkdir("/system_root", 0755);
|
||||
if (xmount(block_dev, "/system_root", "ext4", MS_RDONLY, nullptr))
|
||||
xmount(block_dev, "/system_root", "erofs", MS_RDONLY, nullptr);
|
||||
xmkdir("/system", 0755);
|
||||
xmount("/system_root/system", "/system", nullptr, MS_BIND, nullptr);
|
||||
|
||||
link_root("/vendor");
|
||||
link_root("/product");
|
||||
link_root("/odm");
|
||||
mount_root(vendor);
|
||||
mount_root(product);
|
||||
mount_root(odm);
|
||||
}
|
||||
|
||||
static void switch_root(const string &path) {
|
||||
LOGD("Switch root to %s\n", path.data());
|
||||
vector<string> mounts;
|
||||
|
@ -85,7 +85,7 @@ static void load_overlay_rc(int dirfd) {
|
||||
rewinddir(dir);
|
||||
}
|
||||
|
||||
void RootFSBase::setup_rootfs() {
|
||||
void RootFSInit::setup_rootfs() {
|
||||
if (patch_sepolicy()) {
|
||||
char *addr;
|
||||
size_t size;
|
||||
@ -141,16 +141,6 @@ void RootFSBase::setup_rootfs() {
|
||||
close(fd);
|
||||
}
|
||||
|
||||
void SARCompatInit::setup_rootfs() {
|
||||
// Clone rootfs
|
||||
LOGD("Clone root dir from system to rootfs\n");
|
||||
int system_root = xopen("/system_root", O_RDONLY | O_CLOEXEC);
|
||||
clone_dir(system_root, root, false);
|
||||
close(system_root);
|
||||
|
||||
RootFSBase::setup_rootfs();
|
||||
}
|
||||
|
||||
bool MagiskInit::patch_sepolicy(const char *file) {
|
||||
bool patch_init = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user