mount-system.sh 846 Bytes
Newer Older
1
2
#!/sbin/sh

3
4
5
# Modern devices use /system as root ("/")
system_as_root=`getprop ro.build.system_root_image`
if [ "$system_as_root" == "true" ]; then
6
7
8
9
  if mount /system_root; then
    exit 0
  fi

10
11
12
13
14
15
16
  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
17
18
19
  if mount -o rw $block /system_root ||
     mount -o rw $block /system_root -t ext4 ||
     mount -o rw $block /system_root -t f2fs; then
20
21
22
23
24
25
26
27
28
29
    exit 0
  fi
else
  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
30
31
32
33
    exit 0
  fi
fi

34
exit 1