2019-05-27 07:29:43 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
struct cmdline {
|
|
|
|
bool system_as_root;
|
|
|
|
char slot[3];
|
|
|
|
char dt_dir[128];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct raw_data {
|
|
|
|
void *buf;
|
|
|
|
size_t sz;
|
|
|
|
};
|
|
|
|
|
2019-06-16 19:45:32 +00:00
|
|
|
class BaseInit {
|
|
|
|
protected:
|
2019-06-16 05:25:09 +00:00
|
|
|
cmdline *cmd;
|
2019-05-27 07:29:43 +00:00
|
|
|
raw_data self{};
|
|
|
|
raw_data config{};
|
|
|
|
char **argv;
|
2019-06-16 19:45:32 +00:00
|
|
|
int root = -1;
|
2019-05-27 07:29:43 +00:00
|
|
|
bool load_sepol = false;
|
|
|
|
bool mnt_system = false;
|
|
|
|
bool mnt_vendor = false;
|
|
|
|
bool mnt_product = false;
|
|
|
|
bool mnt_odm = false;
|
|
|
|
|
2019-06-16 19:45:32 +00:00
|
|
|
virtual void preset() {};
|
|
|
|
virtual void early_mount() {}
|
2019-05-27 07:29:43 +00:00
|
|
|
void setup_rootfs();
|
2019-05-27 09:55:46 +00:00
|
|
|
bool read_dt_fstab(const char *name, char *partname, char *fstype);
|
2019-05-27 07:29:43 +00:00
|
|
|
bool patch_sepolicy();
|
|
|
|
void cleanup();
|
|
|
|
void re_exec_init();
|
|
|
|
|
|
|
|
public:
|
2019-06-16 19:45:32 +00:00
|
|
|
BaseInit(char *argv[], cmdline *cmd) : cmd(cmd), argv(argv) {}
|
|
|
|
virtual ~BaseInit() = default;
|
|
|
|
virtual void start();
|
|
|
|
};
|
|
|
|
|
|
|
|
class LegacyInit : public BaseInit {
|
|
|
|
protected:
|
|
|
|
void preset() override;
|
|
|
|
void early_mount() override;
|
|
|
|
public:
|
|
|
|
LegacyInit(char *argv[], cmdline *cmd) : BaseInit(argv, cmd) {};
|
|
|
|
};
|
|
|
|
|
|
|
|
class SARInit : public BaseInit {
|
|
|
|
protected:
|
|
|
|
void preset() override;
|
|
|
|
void early_mount() override;
|
|
|
|
public:
|
|
|
|
SARInit(char *argv[], cmdline *cmd) : BaseInit(argv, cmd) {};
|
2019-05-27 07:29:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline bool is_lnk(const char *name) {
|
|
|
|
struct stat st;
|
|
|
|
if (lstat(name, &st))
|
|
|
|
return false;
|
|
|
|
return S_ISLNK(st.st_mode);
|
|
|
|
}
|
|
|
|
|
2019-06-16 05:25:09 +00:00
|
|
|
void load_kernel_info(cmdline *cmd);
|
2019-05-27 07:29:43 +00:00
|
|
|
int dump_magisk(const char *path, mode_t mode);
|