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 e461578 commit 504787f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions app/magisk/update-binary
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,27 @@ if [ -f /sbin/recovery ] || [ -f /system/bin/recovery ]; then

slot=$(getprop ro.boot.slot_suffix)

if mount /system_root || mount /dev/block/mapper/system_root"${slot}" /system_root; then
try_mount_any() {
local target="${1}" path
shift

mount "${target}" && return 0

for path in "${@}"; do
mount "${path}" "${target}" && return 0
done

return 1
}

if try_mount_any /system_root \
/dev/block/mapper/system_root"${slot}" \
/dev/block/bootdevice/by-name/system_root; then
mount -o remount,rw /system_root
root_dir=/system_root
elif mount /system || mount /dev/block/mapper/system"${slot}" /system; then
elif try_mount_any /system \
/dev/block/mapper/system"${slot}" \
/dev/block/bootdevice/by-name/system; then
mount -o remount,rw /system
root_dir=/
else
Expand Down

0 comments on commit 504787f

Please sign in to comment.