Maintain global mount list

This commit is contained in:
topjohnwu 2021-01-14 21:14:54 -08:00
parent b100d0c503
commit 71b083794c
2 changed files with 9 additions and 5 deletions

View File

@ -11,6 +11,8 @@
using namespace std; using namespace std;
vector<string> mount_list;
template<typename Func> template<typename Func>
static void parse_cmdline(const Func &fn) { static void parse_cmdline(const Func &fn) {
char cmdline[4096]; char cmdline[4096];
@ -147,10 +149,13 @@ void load_kernel_info(cmdline *cmd) {
xmkdir("/sys", 0755); xmkdir("/sys", 0755);
xmount("sysfs", "/sys", "sysfs", 0, nullptr); xmount("sysfs", "/sys", "sysfs", 0, nullptr);
mount_list.emplace_back("/proc");
mount_list.emplace_back("/sys");
// Log to kernel // Log to kernel
setup_klog(); setup_klog();
parse_cmdline([=](string_view key, const char *value) -> void { parse_cmdline([=](string_view key, const char *value) {
if (key == "androidboot.slot_suffix") { if (key == "androidboot.slot_suffix") {
strcpy(cmd->slot, value); strcpy(cmd->slot, value);
} else if (key == "androidboot.slot") { } else if (key == "androidboot.slot") {

View File

@ -29,6 +29,8 @@ struct fstab_entry {
#define INIT_SOCKET "MAGISKINIT" #define INIT_SOCKET "MAGISKINIT"
#define DEFAULT_DT_DIR "/proc/device-tree/firmware/android" #define DEFAULT_DT_DIR "/proc/device-tree/firmware/android"
extern std::vector<std::string> mount_list;
void load_kernel_info(cmdline *cmd); void load_kernel_info(cmdline *cmd);
bool check_two_stage(); bool check_two_stage();
int dump_magisk(const char *path, mode_t mode); int dump_magisk(const char *path, mode_t mode);
@ -42,12 +44,11 @@ class BaseInit {
protected: protected:
cmdline *cmd; cmdline *cmd;
char **argv; char **argv;
std::vector<std::string> mount_list;
[[noreturn]] void exec_init(); [[noreturn]] void exec_init();
void read_dt_fstab(std::vector<fstab_entry> &fstab); void read_dt_fstab(std::vector<fstab_entry> &fstab);
public: public:
BaseInit(char *argv[], cmdline *cmd) : cmd(cmd), argv(argv), mount_list{"/sys", "/proc"} {} BaseInit(char *argv[], cmdline *cmd) : cmd(cmd), argv(argv) {}
virtual ~BaseInit() = default; virtual ~BaseInit() = default;
virtual void start() = 0; virtual void start() = 0;
}; };
@ -100,8 +101,6 @@ private:
public: public:
SecondStageInit(char *argv[]) : SARBase(argv, nullptr) { SecondStageInit(char *argv[]) : SARBase(argv, nullptr) {
LOGD("%s\n", __FUNCTION__); LOGD("%s\n", __FUNCTION__);
// Do not unmount /sys and /proc
mount_list.clear();
}; };
void start() override { void start() override {
prepare(); prepare();