mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-06-13 13:47:44 +02:00
@ -126,6 +126,13 @@ void RootFSInit::early_mount() {
|
||||
root = xopen("/", O_RDONLY | O_CLOEXEC);
|
||||
rename("/.backup/init", "/init");
|
||||
|
||||
// Mount sbin overlay for persist, but move it and add to cleanup list
|
||||
mount_sbin();
|
||||
xmount("/sbin", "/dev", nullptr, MS_MOVE, nullptr);
|
||||
mount_list.emplace_back("/dev");
|
||||
mount_list.emplace_back("/dev/.magisk/mirror/persist");
|
||||
mount_list.emplace_back("/dev/.magisk/mirror/cache");
|
||||
|
||||
mount_root(system);
|
||||
mount_root(vendor);
|
||||
mount_root(product);
|
||||
@ -169,6 +176,7 @@ void SARInit::early_mount() {
|
||||
// Make dev writable
|
||||
xmkdir("/dev", 0755);
|
||||
xmount("tmpfs", "/dev", "tmpfs", 0, "mode=755");
|
||||
mount_list.emplace_back("/dev");
|
||||
|
||||
backup_files();
|
||||
|
||||
@ -227,9 +235,11 @@ void SecondStageInit::early_mount() {
|
||||
void BaseInit::cleanup() {
|
||||
// Unmount in reverse order
|
||||
for (auto &p : reversed(mount_list)) {
|
||||
LOGD("Unmount [%s]\n", p.data());
|
||||
umount(p.data());
|
||||
if (xumount(p.data()) == 0)
|
||||
LOGD("Unmount [%s]\n", p.data());
|
||||
}
|
||||
mount_list.clear();
|
||||
mount_list.shrink_to_fit();
|
||||
}
|
||||
|
||||
void mount_sbin() {
|
||||
@ -248,8 +258,12 @@ void mount_sbin() {
|
||||
// Fallback to cache
|
||||
strcpy(partname, "cache");
|
||||
strcpy(block_dev, BLOCKDIR "/cache");
|
||||
if (setup_block(false) < 0)
|
||||
return;
|
||||
if (setup_block(false) < 0) {
|
||||
// Try NVIDIA's BS
|
||||
strcpy(partname, "CAC");
|
||||
if (setup_block(false) < 0)
|
||||
return;
|
||||
}
|
||||
mnt_point = MIRRDIR "/cache";
|
||||
xsymlink("./cache", MIRRDIR "/persist");
|
||||
}
|
||||
|
Reference in New Issue
Block a user