mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-06-13 13:47:44 +02:00
Clean rootfs in switch_root
This commit is contained in:
@ -121,6 +121,7 @@ if (!is_lnk("/" #name) && read_dt_fstab(cmd, #name)) { \
|
||||
|
||||
static void switch_root(const string &path) {
|
||||
LOGD("Switch root to %s\n", path.data());
|
||||
int root = xopen("/", O_RDONLY);
|
||||
vector<string> mounts;
|
||||
parse_mnt("/proc/mounts", [&](mntent *me) {
|
||||
// Skip root and self
|
||||
@ -142,6 +143,9 @@ static void switch_root(const string &path) {
|
||||
chdir(path.data());
|
||||
xmount(path.data(), "/", nullptr, MS_MOVE, nullptr);
|
||||
chroot(".");
|
||||
|
||||
LOGD("Cleaning rootfs\n");
|
||||
frm_rf(root);
|
||||
}
|
||||
|
||||
static void mount_persist(const char *dev_base, const char *mnt_base) {
|
||||
@ -219,11 +223,6 @@ void SARInit::early_mount() {
|
||||
|
||||
backup_files();
|
||||
|
||||
LOGD("Cleaning rootfs\n");
|
||||
int root = xopen("/", O_RDONLY | O_CLOEXEC);
|
||||
frm_rf(root, { "proc", "sys", "dev" });
|
||||
close(root);
|
||||
|
||||
mount_system_root();
|
||||
switch_root("/system_root");
|
||||
|
||||
|
Reference in New Issue
Block a user