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) {
|
if (cmd.force_normal_boot) {
|
||||||
init = make_unique<ABFirstStageInit>(argv, &cmd);
|
init = make_unique<ABFirstStageInit>(argv, &cmd);
|
||||||
} else if (cmd.skip_initramfs) {
|
} else if (cmd.skip_initramfs) {
|
||||||
if (access("/overlay", F_OK) == 0) /* Compatible mode */
|
init = make_unique<SARInit>(argv, &cmd);
|
||||||
init = make_unique<SARCompatInit>(argv, &cmd);
|
|
||||||
else
|
|
||||||
init = make_unique<SARInit>(argv, &cmd);
|
|
||||||
} else {
|
} else {
|
||||||
decompress_ramdisk();
|
decompress_ramdisk();
|
||||||
if (access("/sbin/recovery", F_OK) == 0 || access("/system/bin/recovery", F_OK) == 0)
|
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) {};
|
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 {
|
class SARBase : public MagiskInit {
|
||||||
protected:
|
protected:
|
||||||
raw_data config;
|
raw_data config;
|
||||||
@ -95,7 +81,7 @@ public:
|
|||||||
* *************/
|
* *************/
|
||||||
|
|
||||||
class ABFirstStageInit : public BaseInit {
|
class ABFirstStageInit : public BaseInit {
|
||||||
protected:
|
private:
|
||||||
void prepare();
|
void prepare();
|
||||||
public:
|
public:
|
||||||
ABFirstStageInit(char *argv[], cmdline *cmd) : BaseInit(argv, cmd) {};
|
ABFirstStageInit(char *argv[], cmdline *cmd) : BaseInit(argv, cmd) {};
|
||||||
@ -106,7 +92,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class AFirstStageInit : public BaseInit {
|
class AFirstStageInit : public BaseInit {
|
||||||
protected:
|
private:
|
||||||
void prepare();
|
void prepare();
|
||||||
public:
|
public:
|
||||||
AFirstStageInit(char *argv[], cmdline *cmd) : BaseInit(argv, cmd) {};
|
AFirstStageInit(char *argv[], cmdline *cmd) : BaseInit(argv, cmd) {};
|
||||||
@ -139,23 +125,20 @@ public:
|
|||||||
* Initramfs
|
* Initramfs
|
||||||
* **********/
|
* **********/
|
||||||
|
|
||||||
class RootFSInit : public RootFSBase {
|
class RootFSInit : public MagiskInit {
|
||||||
|
private:
|
||||||
|
int root = -1;
|
||||||
|
void setup_rootfs();
|
||||||
protected:
|
protected:
|
||||||
void early_mount() override;
|
void early_mount() override;
|
||||||
public:
|
public:
|
||||||
RootFSInit(char *argv[], cmdline *cmd) : RootFSBase(argv, cmd) {};
|
RootFSInit(char *argv[], cmdline *cmd) : MagiskInit(argv, cmd) {};
|
||||||
};
|
|
||||||
|
|
||||||
/* ****************
|
void start() override {
|
||||||
* Compat-mode SAR
|
early_mount();
|
||||||
* ****************/
|
setup_rootfs();
|
||||||
|
exec_init();
|
||||||
class SARCompatInit : public RootFSBase {
|
}
|
||||||
protected:
|
|
||||||
void early_mount() override;
|
|
||||||
void setup_rootfs() override;
|
|
||||||
public:
|
|
||||||
SARCompatInit(char *argv[], cmdline *cmd) : RootFSBase(argv, cmd) {};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void load_kernel_info(cmdline *cmd);
|
void load_kernel_info(cmdline *cmd);
|
||||||
|
@ -112,10 +112,6 @@ static bool read_dt_fstab(cmdline *cmd, const char *name) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define link_root(name) \
|
|
||||||
if (is_lnk("/system_root" name)) \
|
|
||||||
cp_afc("/system_root" name, name)
|
|
||||||
|
|
||||||
#define mount_root(name) \
|
#define mount_root(name) \
|
||||||
if (!is_lnk("/" #name) && read_dt_fstab(cmd, #name)) { \
|
if (!is_lnk("/" #name) && read_dt_fstab(cmd, #name)) { \
|
||||||
LOGD("Early mount " #name "\n"); \
|
LOGD("Early mount " #name "\n"); \
|
||||||
@ -138,30 +134,6 @@ void RootFSInit::early_mount() {
|
|||||||
mount_root(odm);
|
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) {
|
static void switch_root(const string &path) {
|
||||||
LOGD("Switch root to %s\n", path.data());
|
LOGD("Switch root to %s\n", path.data());
|
||||||
vector<string> mounts;
|
vector<string> mounts;
|
||||||
|
@ -85,7 +85,7 @@ static void load_overlay_rc(int dirfd) {
|
|||||||
rewinddir(dir);
|
rewinddir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RootFSBase::setup_rootfs() {
|
void RootFSInit::setup_rootfs() {
|
||||||
if (patch_sepolicy()) {
|
if (patch_sepolicy()) {
|
||||||
char *addr;
|
char *addr;
|
||||||
size_t size;
|
size_t size;
|
||||||
@ -141,16 +141,6 @@ void RootFSBase::setup_rootfs() {
|
|||||||
close(fd);
|
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 MagiskInit::patch_sepolicy(const char *file) {
|
||||||
bool patch_init = false;
|
bool patch_init = false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user