Skip to content

Commit

Permalink
module: Try to explicitly mount common system partition block devices
Browse files Browse the repository at this point in the history
The source field for dm-linear block devices in the recovery's fstab is
not an actual file path.

Fixes: #338

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
  • Loading branch information
chenxiaolong committed Sep 10, 2023
1 parent ae0c4ab commit 2f5f0b6
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions app/magisk/update-binary
Original file line number Diff line number Diff line change
@@ -14,13 +14,41 @@ if [ -f /sbin/recovery ] || [ -f /system/bin/recovery ]; then
set -exu

ui_print 'Mounting system'
if mount /system_root; then
mount -o remount,rw /system_root
root_dir=/system_root

if [[ "$(getprop ro.boot.dynamic_partitions)" == true ]]; then
ui_print "- Device uses dynamic partitions"
slot=$(getprop ro.boot.slot_suffix)
block_dev=/dev/block/mapper/system"${slot}"
blockdev --setrw "${block_dev}"
else
ui_print "- Device uses static partitions"
block_dev=/dev/block/bootdevice/by-name/system
fi

ui_print "- System block device: ${block_dev}"

if [[ -d /mnt/system ]]; then
mount_point=/mnt/system
root_dir=${mount_point}
elif [[ -d /system_root ]]; then
mount_point=/system_root
root_dir=${mount_point}
else
mount_point=/system
if [[ "$(getprop ro.build.system_root_image)" == true ]]; then
root_dir=${mount_point}
else
root_dir=/
fi
fi

ui_print "- System mount point: ${mount_point}"
ui_print "- Root directory: ${root_dir}"

if mountpoint -q "${mount_point}"; then
mount -o remount,rw "${mount_point}"
else
mount /system
mount -o remount,rw /system
root_dir=/
mount "${block_dev}" "${mount_point}"
fi

ui_print 'Extracting files'

0 comments on commit 2f5f0b6

Please sign in to comment.