Improvements to system_root devices booting as recovery

This commit is contained in:
topjohnwu 2018-08-07 02:20:40 +08:00
parent e139f4fc13
commit 9159f86a9e

View File

@ -357,6 +357,8 @@ int main(int argc, char *argv[]) {
* ***********/
int root = open("/", O_RDONLY | O_CLOEXEC);
int mnt_system = 0;
int mnt_vendor = 0;
if (cmd.skip_initramfs) {
// Clear rootfs
@ -384,12 +386,14 @@ int main(int argc, char *argv[]) {
link("/.backup/init", "/init");
}
// Do not go further if system_root device is booting as recovery
if (!cmd.skip_initramfs && access("/sbin/recovery", F_OK) == 0)
goto exec_init;
/* ************
* Early Mount
* ************/
int mnt_system = 0;
int mnt_vendor = 0;
struct device dev;
char partname[32];
@ -423,8 +427,6 @@ int main(int argc, char *argv[]) {
* Ramdisk Patches
* ****************/
// Only patch rootfs if not intended to run in recovery
if (access("/sbin/recovery", F_OK) != 0) {
// Handle ramdisk overlays
int fd = open("/overlay", O_RDONLY | O_CLOEXEC);
if (fd >= 0) {
@ -464,8 +466,8 @@ int main(int argc, char *argv[]) {
dump_magisk("/sbin/magisk", 0755);
patch_socket_name("/sbin/magisk");
rename("/init.bak", "/sbin/magiskinit");
}
exec_init:
// Clean up
close(root);
umount("/proc");