Force kernel to load rootfs only for legacy SAR devices

This commit is contained in:
vvb2060
2023-07-09 23:53:59 +08:00
committed by John Wu
parent 275208e81b
commit d12d9e82f1
6 changed files with 23 additions and 7 deletions

View File

@ -6,7 +6,7 @@
# Usage: boot_patch.sh <bootimage>
#
# The following flags can be set in environment variables:
# KEEPVERITY, KEEPFORCEENCRYPT, PATCHVBMETAFLAG, RECOVERYMODE, SYSTEM_ROOT
# KEEPVERITY, KEEPFORCEENCRYPT, PATCHVBMETAFLAG, RECOVERYMODE, LEGACYSAR
#
# This script should be placed in a directory with the following files:
#
@ -73,7 +73,7 @@ fi
[ -z $KEEPFORCEENCRYPT ] && KEEPFORCEENCRYPT=false
[ -z $PATCHVBMETAFLAG ] && PATCHVBMETAFLAG=false
[ -z $RECOVERYMODE ] && RECOVERYMODE=false
[ -z $SYSTEM_ROOT ] && SYSTEM_ROOT=false
[ -z $LEGACYSAR ] && LEGACYSAR=false
export KEEPVERITY
export KEEPFORCEENCRYPT
export PATCHVBMETAFLAG
@ -233,7 +233,7 @@ if [ -f kernel ]; then
# Force kernel to load rootfs for legacy SAR devices
# skip_initramfs -> want_initramfs
$SYSTEM_ROOT && ./magiskboot hexpatch kernel \
$LEGACYSAR && ./magiskboot hexpatch kernel \
736B69705F696E697472616D667300 \
77616E745F696E697472616D667300 \
&& PATCHEDKERNEL=true

View File

@ -312,7 +312,7 @@ mount_partitions() {
# After calling this method, the following variables will be set:
# KEEPVERITY, KEEPFORCEENCRYPT, RECOVERYMODE, PATCHVBMETAFLAG,
# ISENCRYPTED, VBMETAEXIST
# ISENCRYPTED, VBMETAEXIST, LEGACYSAR
get_flags() {
getvar KEEPVERITY
getvar KEEPFORCEENCRYPT
@ -350,6 +350,15 @@ get_flags() {
fi
fi
[ -z $RECOVERYMODE ] && RECOVERYMODE=false
local IS_DYNAMIC=false
grep -q 'androidboot.super_partition' /proc/cmdline && IS_DYNAMIC=true
[ -b "/dev/block/by-name/super" ] && IS_DYNAMIC=true
if $SYSTEM_ROOT && ! $IS_DYNAMIC; then
LEGACYSAR=true
ui_print "- legacy SAR, force kernel to load rootfs"
else
LEGACYSAR=false
fi
}
find_boot_image() {