blob: e5cc81cec63029d1a75f9dd2ed62a37836598dcb [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
LuK1337dd5fecb2019-06-24 13:19:15 +020017 if mount -o rw $block /system_root ||
18 mount -o rw $block /system_root -t ext4 ||
19 mount -o rw $block /system_root -t f2fs; then
Michael Bestas79e91fe2019-02-11 19:04:11 +020020 exit 0
21 fi
22else
23 if mount /system; then
24 exit 0
25 fi
26
27 # Try to get the block from /etc/recovery.fstab
28 block=`cat /etc/recovery.fstab | cut -d '#' -f 1 | grep /system | grep -o '/dev/[^ ]*' | head -1`
29 if [ -n "$block" ] && mount $block /system; then
Christopher N. Hesse1f94c932018-06-11 21:56:24 +020030 exit 0
31 fi
32fi
33
Gabriele M5b33c6c2017-01-22 22:50:02 +010034exit 1