Gabriele M | 5b33c6c | 2017-01-22 22:50:02 +0100 | [diff] [blame] | 1 | #!/sbin/sh |
| 2 | |
Christopher N. Hesse | 1f94c93 | 2018-06-11 21:56:24 +0200 | [diff] [blame] | 3 | # Modern devices use /system as root ("/") |
| 4 | system_as_root=`getprop ro.build.system_root_image` |
| 5 | if [ "$system_as_root" == "true" ]; then |
Michael Bestas | 79e91fe | 2019-02-11 19:04:11 +0200 | [diff] [blame] | 6 | if mount /system_root; then |
| 7 | exit 0 |
| 8 | fi |
| 9 | |
Christopher N. Hesse | 1f94c93 | 2018-06-11 21:56:24 +0200 | [diff] [blame] | 10 | 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 Bestas | 79e91fe | 2019-02-11 19:04:11 +0200 | [diff] [blame] | 17 | if mount -o rw $block /system_root; then |
| 18 | exit 0 |
| 19 | fi |
| 20 | else |
| 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. Hesse | 1f94c93 | 2018-06-11 21:56:24 +0200 | [diff] [blame] | 28 | exit 0 |
| 29 | fi |
| 30 | fi |
| 31 | |
Gabriele M | 5b33c6c | 2017-01-22 22:50:02 +0100 | [diff] [blame] | 32 | exit 1 |