mirror of
https://gitlab.com/Nanolx/NanoDroid
synced 2024-10-31 09:20:23 +00:00
CommonInstaller: find_block() from Magisk
This commit is contained in:
parent
0f8db95609
commit
cac483552f
@ -229,39 +229,52 @@ is_mounted () {
|
||||
# mount partitions
|
||||
##########################################################################################
|
||||
|
||||
toupper() {
|
||||
echo "$@" | tr '[:lower:]' '[:upper:]'
|
||||
}
|
||||
|
||||
find_block () {
|
||||
unset tmp
|
||||
tmp=$(find /dev/block \( -type b -o -type c -o -type l \) -name ${1}${SLOT} | head -n 1)
|
||||
[ -z "${tmp}" ] && tmp=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${1}${SLOT} | head -n 1)
|
||||
if [ -z "${tmp}" ]; then
|
||||
for uevent in /sys/dev/block/*/uevent; do
|
||||
partname=$(awk -F= '/PARTNAME/{print $2}' ${uevent})
|
||||
if [ "${1}${SLOT}" = "${partname}" ]; then
|
||||
tmp="/dev/block/$(awk -F= '/DEVNAME/{print $2}' ${uevent})"
|
||||
break
|
||||
fi
|
||||
done
|
||||
local block tmp partname devname device
|
||||
|
||||
block=${1}${SLOT}
|
||||
device=$(find /dev/block \( -type b -o -type c -o -type l \) -name ${block} | head -n 1)
|
||||
|
||||
if [ ! -z ${device} ]; then
|
||||
readlink -f ${device}
|
||||
return 0
|
||||
fi
|
||||
readlink -f "${tmp}"
|
||||
|
||||
for uevent in /sys/dev/block/*/uevent; do
|
||||
partname=$(awk -F= '/PARTNAME/{print $2}' ${uevent})
|
||||
devname=$(awk -F= '/DEVNAME/{print $2}' ${uevent})
|
||||
if [ "$(toupper ${block})" = "$(toupper ${partname})" ]; then
|
||||
echo /dev/block/${devname}
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
device=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${block} | head -n 1)
|
||||
if [ ! -z ${device} ]; then
|
||||
readlink -f ${device}
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
|
||||
}
|
||||
|
||||
mount_partitions () {
|
||||
if ! ${BOOTMODE}; then
|
||||
DEVICE_AB=FALSE
|
||||
VENDOR_COMPAT=FALSE
|
||||
SYSTEM_AS_ROOT=FALSE
|
||||
|
||||
SLOT=$(grep_cmdline androidboot.slot_suffix)
|
||||
decho " INFO: #1 [SLOT] ${SLOT}"
|
||||
if [ -z ${SLOT} ]; then
|
||||
SLOT=$(grep_cmdline androidboot.slot)
|
||||
echo " INFO: #2 [SLOT] ${SLOT}"
|
||||
if [ ! -z ${SLOT} ]; then
|
||||
SLOT=_${SLOT}
|
||||
echo " INFO: #3 [SLOT] ${SLOT}"
|
||||
DEVICE_AB=TRUE
|
||||
fi
|
||||
[ -z ${SLOT} ] || SLOT=_${SLOT}
|
||||
fi
|
||||
[ -z ${SLOT} ] && DEVICE_AB=FALSE || DEVICE_AB=TRUE
|
||||
decho " INFO: #1 [SLOT] ${SLOT}"
|
||||
|
||||
is_mounted /data || mount /data || decho "failed to mount /data!"
|
||||
|
||||
@ -270,6 +283,11 @@ mount_partitions () {
|
||||
SYSTEM_BLOCK=$(find_block system)
|
||||
decho " INFO: #5 [SYSTEM_BLOCK] ${SYSTEM_BLOCK}"
|
||||
|
||||
if is_mounted /system_root; then
|
||||
umount /system 2&>/dev/null
|
||||
umount /system_root 2&>/dev/null
|
||||
fi
|
||||
|
||||
mkdir -p /system /system_root
|
||||
mount -o rw ${SYSTEM_BLOCK} /system
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user