platform_vendor_tequila/addonsu/mount-system.sh
Christopher N. Hesse 1f94c931e0 addonsu: Fix package for modern devices
Recent devices (e.g. Pixel 2XL aka taimen) do not define any "system"
partition in their fstab, so a plain "mount /system" fails.

Furthermore, trying to get the entry from /etc/recovery.fstab also fails
because the partitions have slot suffixes (e.g. system_a).
So for these devices, we need to figure out the active slot, mount the
system partition (which really contains the whole root) and lastly mount
the actual system partition from the rootfs.

Change-Id: Ibb73a82896c1f6ce6af9c334b8d0908a183913b9
2018-06-22 16:34:05 +02:00

28 lines
724 B
Bash

#!/sbin/sh
if mount /system; then
exit 0
fi
# Try to get the block from /etc/recovery.fstab
block=`cat /etc/recovery.fstab | cut -d '#' -f 1 | grep /system | grep -o '/dev/[^ ]*' | head -1`
if [ -n "$block" ] && mount $block /system; then
exit 0
fi
# Modern devices use /system as root ("/")
system_as_root=`getprop ro.build.system_root_image`
if [ "$system_as_root" == "true" ]; then
active_slot=`getprop ro.boot.slot_suffix`
if [ ! -z "$active_slot" ]; then
block=/dev/block/bootdevice/by-name/system$active_slot
else
block=/dev/block/bootdevice/by-name/system
fi
mkdir -p /system_root
if mount -o rw $block /system_root && mount /system_root/system /system; then
exit 0
fi
fi
exit 1