blob: ae2e2729653a4f0e6fad30d85f976419d21dbe1a [file] [log] [blame]
Gabriele M5b33c6c2017-01-22 22:50:02 +01001#!/sbin/sh
2
Christopher N. Hesse1f94c932018-06-11 21:56:24 +02003# Modern devices use /system as root ("/")
4system_as_root=`getprop ro.build.system_root_image`
5if [ "$system_as_root" == "true" ]; then
Michael Bestas79e91fe2019-02-11 19:04:11 +02006 if mount /system_root; then
7 exit 0
8 fi
9
Christopher N. Hesse1f94c932018-06-11 21:56:24 +020010 active_slot=`getprop ro.boot.slot_suffix`
11 if [ ! -z "$active_slot" ]; then
12 block=/dev/block/bootdevice/by-name/system$active_slot
13 else
14 block=/dev/block/bootdevice/by-name/system
15 fi
16 mkdir -p /system_root
Michael Bestas79e91fe2019-02-11 19:04:11 +020017 if mount -o rw $block /system_root; then
18 exit 0
19 fi
20else
21 if mount /system; then
22 exit 0
23 fi
24
25 # Try to get the block from /etc/recovery.fstab
26 block=`cat /etc/recovery.fstab | cut -d '#' -f 1 | grep /system | grep -o '/dev/[^ ]*' | head -1`
27 if [ -n "$block" ] && mount $block /system; then
Christopher N. Hesse1f94c932018-06-11 21:56:24 +020028 exit 0
29 fi
30fi
31
Gabriele M5b33c6c2017-01-22 22:50:02 +010032exit 1