Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a0583ca7 authored by Davide Garberi's avatar Davide Garberi Committed by Aaron Kling
Browse files

prebuilt: backuptool: Implement dynamic system mount for A-only

* Dynamically mount system to the path chosen by the recovery through backuptool
* This can be helpful because of the fragmentation that will happen with system mount in recovery after Q

Change-Id: I2d1e775efcf87e33319bc7790d1e54bca72116d3
parent 81890e35
Loading
Loading
Loading
Loading
+33 −1
Original line number Diff line number Diff line
@@ -4,7 +4,8 @@
#

export C=/tmp/backupdir
export S=$2
export SYSDEV="$(readlink -nf "$2")"
export SYSFS="$3"
export V=16.0

export ADDOND_VERSION=1
@@ -94,11 +95,38 @@ if [ -d /tmp/addon.d/ ]; then
fi
}

determine_system_mount() {
  if grep -q -e"^$SYSDEV" /proc/mounts; then
    umount $(grep -e"^$SYSDEV" /proc/mounts | cut -d" " -f2)
  fi

  if [ -d /system_root ]; then
    SYSMOUNT="/system_root"
    export S=/system_root/system
  else
    SYSMOUNT="/system"
    export S=/system
  fi

}

mount_system() {
  mount -t $SYSFS $SYSDEV $SYSMOUNT -o rw,discard
}

unmount_system() {
  umount $SYSMOUNT
}

determine_system_mount

case "$1" in
  backup)
    mount_system
    mkdir -p $C
    if check_prereq; then
        if check_whitelist system; then
            unmount_system
            exit 127
        fi
    fi
@@ -107,10 +135,13 @@ case "$1" in
    run_stage pre-backup
    run_stage backup
    run_stage post-backup
    unmount_system
  ;;
  restore)
    mount_system
    if check_prereq; then
        if check_whitelist tmp; then
            unmount_system
            exit 127
        fi
    fi
@@ -121,6 +152,7 @@ case "$1" in
    restore_addon_d
    rm -rf $C
    sync
    unmount_system
  ;;
  *)
    echo "Usage: $0 {backup|restore}"