@@ -358,7 +358,7 @@ bool exec_command(char *restrict buf, size_t len, const char *restrict file, cha
358358 dup2 (link [1 ], STDOUT_FILENO );
359359 close (link [0 ]);
360360 close (link [1 ]);
361-
361+
362362 execv (file , argv );
363363
364364 LOGE ("execv failed: %s\n" , strerror (errno ));
@@ -626,7 +626,7 @@ enum mns_umount_state unmount_root(bool modules_only, struct root_impl impl) {
626626 char source_name [LONGEST_ROOT_IMPL_NAME ];
627627 if (impl .impl == KernelSU ) strcpy (source_name , "KSU" );
628628 else strcpy (source_name , "APatch" );
629-
629+
630630 const char * * targets_to_unmount = NULL ;
631631 size_t num_targets = 0 ;
632632
@@ -639,6 +639,8 @@ enum mns_umount_state unmount_root(bool modules_only, struct root_impl impl) {
639639 if (strncmp (mount .target , "/debug_ramdisk" , strlen ("/debug_ramdisk" )) == 0 )
640640 should_unmount = true;
641641 } else {
642+ if (strncmp (mount .target , "/system/" , strlen ("/system/" )) == 0 ) continue ;
643+
642644 if (strcmp (mount .source , source_name ) == 0 ) should_unmount = true;
643645 if (strncmp (mount .root , "/adb/modules" , strlen ("/adb/modules" )) == 0 ) should_unmount = true;
644646 if (strncmp (mount .target , "/data/adb/modules" , strlen ("/data/adb/modules" )) == 0 ) should_unmount = true;
@@ -675,35 +677,26 @@ enum mns_umount_state unmount_root(bool modules_only, struct root_impl impl) {
675677 }
676678 case Magisk : {
677679 LOGI ("[Magisk] Unmounting root %s modules\n" , modules_only ? "only" : "with" );
678-
680+
679681 const char * * targets_to_unmount = NULL ;
680682 size_t num_targets = 0 ;
681683
682684 for (size_t i = 0 ; i < mounts .length ; i ++ ) {
683685 struct mountinfo mount = mounts .mounts [i ];
684686
685687 bool should_unmount = false;
686- if (
687- (
688- modules_only &&
689- (
690- strcmp (mount .source , "magisk" ) == 0 ||
691- strncmp (mount .target , "/debug_ramdisk" , strlen ("/debug_ramdisk" )) == 0 ||
692- strncmp (mount .target , "/system/bin" , strlen ("/system/bin" )) == 0
693- )
694- ) ||
695- (
696- !modules_only &&
697- (
698- strcmp (mount .source , "magisk" ) == 0 ||
699- strncmp (mount .target , "/debug_ramdisk" , strlen ("/debug_ramdisk" )) == 0 ||
700- strncmp (mount .target , "/data/adb/modules" , strlen ("/data/adb/modules" )) == 0 ||
701- strncmp (mount .root , "/adb/modules" , strlen ("/adb/modules" )) == 0 ||
702- strncmp (mount .target , "/system/bin" , strlen ("/system/bin" )) == 0
703- )
704- )
705- ) {
706- should_unmount = true;
688+ if (modules_only ) {
689+ if (strcmp (mount .source , "magisk" ) == 0 ) should_unmount = true;
690+ if (strncmp (mount .target , "/debug_ramdisk" , strlen ("/debug_ramdisk" )) == 0 ) should_unmount = true;
691+ if (strncmp (mount .target , "/system/bin" , strlen ("/system/bin" )) == 0 ) should_unmount = true;
692+ } else {
693+ if (strncmp (mount .target , "/system/" , strlen ("/system/" )) == 0 ) continue ;
694+
695+ if (strcmp (mount .source , "magisk" ) == 0 ) should_unmount = true;
696+ if (strncmp (mount .target , "/debug_ramdisk" , strlen ("/debug_ramdisk" )) == 0 ) should_unmount = true;
697+ if (strncmp (mount .target , "/data/adb/modules" , strlen ("/data/adb/modules" )) == 0 ) should_unmount = true;
698+ if (strncmp (mount .root , "/adb/modules" , strlen ("/adb/modules" )) == 0 ) should_unmount = true;
699+ if (strncmp (mount .target , "/system/bin" , strlen ("/system/bin" )) == 0 ) should_unmount = true;
707700 }
708701
709702 if (!should_unmount ) continue ;
0 commit comments