mirror of
https://gitlab.com/Nanolx/NanoDroid
synced 2024-10-31 09:20:23 +00:00
another try on improving /system mount code for various occasions
This commit is contained in:
parent
8d00391249
commit
521dc88d69
@ -220,6 +220,22 @@ is_mounted () {
|
|||||||
# mount partitions
|
# mount partitions
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
readlink -f ${tmp}
|
||||||
|
}
|
||||||
|
|
||||||
mount_partitions () {
|
mount_partitions () {
|
||||||
if ! ${BOOTMODE}; then
|
if ! ${BOOTMODE}; then
|
||||||
DEVICE_AB=FALSE
|
DEVICE_AB=FALSE
|
||||||
@ -242,34 +258,26 @@ mount_partitions () {
|
|||||||
|
|
||||||
mount -o bind /dev/urandom /dev/random
|
mount -o bind /dev/urandom /dev/random
|
||||||
|
|
||||||
system_tmp=$(find /dev/block \( -type b -o -type c -o -type l \) -name system${SLOT} | head -n 1)
|
SYSTEM_BLOCK=$(find_block system)
|
||||||
echo " INFO: #4 [system_tmp] ${system_tmp}"
|
|
||||||
SYSTEM_BLOCK=$(readlink -f ${system_tmp})
|
|
||||||
echo " INFO: #5 [SYSTEM_BLOCK] ${SYSTEM_BLOCK}"
|
echo " INFO: #5 [SYSTEM_BLOCK] ${SYSTEM_BLOCK}"
|
||||||
|
|
||||||
SYSTEM_AS_ROOT=$(grep_prop ro.build.ab_update /default.prop)
|
mkdir -p /system /system_root
|
||||||
if [ -L /system_root ]; then
|
mount -o rw ${SYSTEM_BLOCK} /system
|
||||||
mv /system_root /system_root_link
|
|
||||||
mkdir -p /system_root
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d /system_root ]; then
|
if [ -f /system/build.prop ]; then
|
||||||
mount -o rw /system_root || mount -orw ${SYSTEM_BLOCK} /system_root
|
SYSTEM=/system
|
||||||
if [ -d /system_root/system ]; then
|
elif [ -f /system/system/build.prop -o -f /system/init -o -L /system/init ]; then
|
||||||
mkdir -p /system
|
SYSTEM_AS_ROOT=true
|
||||||
|
SYSTEM=/system/system
|
||||||
|
if ! mount --move /system /system_root; then
|
||||||
|
umount /system
|
||||||
|
umount -l /system
|
||||||
|
moun -o rw ${SYSTEM_BLOCK} /system_root
|
||||||
|
fi
|
||||||
mount -o bind /system_root/system /system
|
mount -o bind /system_root/system /system
|
||||||
fi
|
fi
|
||||||
elif [ -d /system ]; then
|
|
||||||
mount -o rw /system || mount -o rw ${SYSTEM_BLOCK} /system
|
|
||||||
if [ -d /system/system ]; then
|
|
||||||
mkdir -p /system
|
|
||||||
mount -o bind /system/system
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
vendor_tmp=$(find /dev/block \( -type b -o -type c -o -type l \) -name vendor${SLOT} | head -n 1)
|
VENDOR_BLOCK=$(find_block vendor)
|
||||||
echo " INFO: #6 [vendor_tmp] ${vendor_tmp}"
|
|
||||||
VENDOR_BLOCK=$(readlink -f ${vendor_tmp})
|
|
||||||
echo " INFO: #7 [VENDOR_BLOCK] ${VENDOR_BLOCK}"
|
echo " INFO: #7 [VENDOR_BLOCK] ${VENDOR_BLOCK}"
|
||||||
|
|
||||||
! is_mounted /vendor && mount -o ro /vendor
|
! is_mounted /vendor && mount -o ro /vendor
|
||||||
|
@ -96,6 +96,22 @@ mount_apex () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# taken from Magisk, with minor modifications for NanoDroid
|
# taken from Magisk, with minor modifications for NanoDroid
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
readlink -f ${tmp}
|
||||||
|
}
|
||||||
|
|
||||||
mount_partitions () {
|
mount_partitions () {
|
||||||
if ! ${BOOTMODE}; then
|
if ! ${BOOTMODE}; then
|
||||||
DEVICE_AB=FALSE
|
DEVICE_AB=FALSE
|
||||||
@ -118,34 +134,26 @@ mount_partitions () {
|
|||||||
|
|
||||||
mount -o bind /dev/urandom /dev/random
|
mount -o bind /dev/urandom /dev/random
|
||||||
|
|
||||||
system_tmp=$(find /dev/block \( -type b -o -type c -o -type l \) -name system${SLOT} | head -n 1)
|
SYSTEM_BLOCK=$(find_block system)
|
||||||
echo " INFO: #4 [system_tmp] ${system_tmp}"
|
|
||||||
SYSTEM_BLOCK=$(readlink -f ${system_tmp})
|
|
||||||
echo " INFO: #5 [SYSTEM_BLOCK] ${SYSTEM_BLOCK}"
|
echo " INFO: #5 [SYSTEM_BLOCK] ${SYSTEM_BLOCK}"
|
||||||
|
|
||||||
SYSTEM_AS_ROOT=$(grep_prop ro.build.ab_update /default.prop)
|
mkdir -p /system /system_root
|
||||||
if [ -L /system_root ]; then
|
mount -o rw ${SYSTEM_BLOCK} /system
|
||||||
mv /system_root /system_root_link
|
|
||||||
mkdir -p /system_root
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d /system_root ]; then
|
if [ -f /system/build.prop ]; then
|
||||||
mount -o rw /system_root || mount -orw ${SYSTEM_BLOCK} /system_root
|
SYSTEM=/system
|
||||||
if [ -d /system_root/system ]; then
|
elif [ -f /system/system/build.prop -o -f /system/init -o -L /system/init ]; then
|
||||||
mkdir -p /system
|
SYSTEM_AS_ROOT=true
|
||||||
|
SYSTEM=/system/system
|
||||||
|
if ! mount --move /system /system_root; then
|
||||||
|
umount /system
|
||||||
|
umount -l /system
|
||||||
|
moun -o rw ${SYSTEM_BLOCK} /system_root
|
||||||
|
fi
|
||||||
mount -o bind /system_root/system /system
|
mount -o bind /system_root/system /system
|
||||||
fi
|
fi
|
||||||
elif [ -d /system ]; then
|
|
||||||
mount -o rw /system || mount -o rw ${SYSTEM_BLOCK} /system
|
|
||||||
if [ -d /system/system ]; then
|
|
||||||
mkdir -p /system
|
|
||||||
mount -o bind /system/system
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
vendor_tmp=$(find /dev/block \( -type b -o -type c -o -type l \) -name vendor${SLOT} | head -n 1)
|
VENDOR_BLOCK=$(find_block vendor)
|
||||||
echo " INFO: #6 [vendor_tmp] ${vendor_tmp}"
|
|
||||||
VENDOR_BLOCK=$(readlink -f ${vendor_tmp})
|
|
||||||
echo " INFO: #7 [VENDOR_BLOCK] ${VENDOR_BLOCK}"
|
echo " INFO: #7 [VENDOR_BLOCK] ${VENDOR_BLOCK}"
|
||||||
|
|
||||||
! is_mounted /vendor && mount -o ro /vendor
|
! is_mounted /vendor && mount -o ro /vendor
|
||||||
|
@ -85,7 +85,24 @@ mount_apex () {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# taken from Magisk, with minor modifications for NanoDroid
|
# taken from Magisk, with modifications for NanoDroid
|
||||||
|
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
readlink -f ${tmp}
|
||||||
|
}
|
||||||
|
|
||||||
mount_partitions () {
|
mount_partitions () {
|
||||||
DEVICE_AB=FALSE
|
DEVICE_AB=FALSE
|
||||||
VENDOR_COMPAT=FALSE
|
VENDOR_COMPAT=FALSE
|
||||||
@ -100,11 +117,8 @@ mount_partitions () {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
system_tmp=$(find /dev/block \( -type b -o -type c -o -type l \) -name system${SLOT} | head -n 1)
|
SYSTEM_BLOCK=$(find_block system)
|
||||||
SYSTEM_BLOCK=$(readlink -f ${system_tmp})
|
VENDOR_BLOCK=$(find_block vendor)
|
||||||
|
|
||||||
vendor_tmp=$(find /dev/block \( -type b -o -type c -o -type l \) -name vendor${SLOT} | head -n 1)
|
|
||||||
VENDOR_BLOCK=$(readlink -f ${vendor_tmp})
|
|
||||||
|
|
||||||
if ${BOOTMODE}; then
|
if ${BOOTMODE}; then
|
||||||
build_props=$(find /system /system_root /vendor -type f -name build.prop)
|
build_props=$(find /system /system_root /vendor -type f -name build.prop)
|
||||||
@ -119,25 +133,21 @@ mount_partitions () {
|
|||||||
|
|
||||||
mount -o bind /dev/urandom /dev/random
|
mount -o bind /dev/urandom /dev/random
|
||||||
|
|
||||||
SYSTEM_AS_ROOT=$(grep_prop ro.build.ab_update /default.prop)
|
mkdir -p /system /system_root
|
||||||
if [ -L /system_root ]; then
|
mount -o rw ${SYSTEM_BLOCK} /system
|
||||||
mv /system_root /system_root_link
|
|
||||||
mkdir -p /system_root
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d /system_root ]; then
|
if [ -f /system/build.prop ]; then
|
||||||
mount -o rw /system_root || mount -orw ${SYSTEM_BLOCK} /system_root
|
SYSTEM=/system
|
||||||
if [ -d /system_root/system ]; then
|
elif [ -f /system/system/build.prop -o -f /system/init -o -L /system/init ]; then
|
||||||
mkdir -p /system
|
SYSTEM_AS_ROOT=true
|
||||||
|
SYSTEM=/system/system
|
||||||
|
if ! mount --move /system /system_root; then
|
||||||
|
umount /system
|
||||||
|
umount -l /system
|
||||||
|
moun -o rw ${SYSTEM_BLOCK} /system_root
|
||||||
|
fi
|
||||||
mount -o bind /system_root/system /system
|
mount -o bind /system_root/system /system
|
||||||
fi
|
fi
|
||||||
elif [ -d /system ]; then
|
|
||||||
mount -o rw /system || mount -o rw ${SYSTEM_BLOCK} /system
|
|
||||||
if [ -d /system/system ]; then
|
|
||||||
mkdir -p /system
|
|
||||||
mount -o bind /system/system
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
! is_mounted /vendor && mount -o ro /vendor
|
! is_mounted /vendor && mount -o ro /vendor
|
||||||
! is_mounted /vendor && mount -o ro ${VENDOR_BLOCK} /vendor
|
! is_mounted /vendor && mount -o ro ${VENDOR_BLOCK} /vendor
|
||||||
@ -379,8 +389,8 @@ store_results () {
|
|||||||
add_log "DEVICE_AB=${DEVICE_AB}"
|
add_log "DEVICE_AB=${DEVICE_AB}"
|
||||||
add_log "VENDOR_COMPAT=${VENDOR_COMPAT}"
|
add_log "VENDOR_COMPAT=${VENDOR_COMPAT}"
|
||||||
add_log "SYSTEM_AS_ROOT=${SYSTEM_AS_ROOT}"
|
add_log "SYSTEM_AS_ROOT=${SYSTEM_AS_ROOT}"
|
||||||
add_log "SYSTEMBLOCK=${SYSTEM_BLOCK}"
|
add_log "SYSTEM_BLOCK=${SYSTEM_BLOCK}"
|
||||||
add_log "VENDORBLOCK=${VENDOR_BLOCK}"
|
add_log "VENDOR_BLOCK=${VENDOR_BLOCK}"
|
||||||
add_log "SLOT=${SLOT}"
|
add_log "SLOT=${SLOT}"
|
||||||
add_log ""
|
add_log ""
|
||||||
mount | sed '/magisk/d' | awk '{print $1 " on " $3 " params: " $6}' >> ${LOGFILE}
|
mount | sed '/magisk/d' | awk '{print $1 " on " $3 " params: " $6}' >> ${LOGFILE}
|
||||||
|
@ -112,6 +112,22 @@ error () {
|
|||||||
# mount partitions
|
# mount partitions
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
readlink -f ${tmp}
|
||||||
|
}
|
||||||
|
|
||||||
mount_partitions () {
|
mount_partitions () {
|
||||||
if ! ${BOOTMODE}; then
|
if ! ${BOOTMODE}; then
|
||||||
DEVICE_AB=FALSE
|
DEVICE_AB=FALSE
|
||||||
@ -134,29 +150,26 @@ mount_partitions () {
|
|||||||
|
|
||||||
mount -o bind /dev/urandom /dev/random
|
mount -o bind /dev/urandom /dev/random
|
||||||
|
|
||||||
SYSTEM_AS_ROOT=$(grep_prop ro.build.ab_update /default.prop)
|
SYSTEM_BLOCK=$(find_block system)
|
||||||
if [ -L /system_root ]; then
|
echo " INFO: #5 [SYSTEM_BLOCK] ${SYSTEM_BLOCK}"
|
||||||
mv /system_root /system_root_link
|
|
||||||
mkdir -p /system_root
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d /system_root ]; then
|
mkdir -p /system /system_root
|
||||||
mount -o rw /system_root || mount -orw ${SYSTEM_BLOCK} /system_root
|
mount -o rw ${SYSTEM_BLOCK} /system
|
||||||
if [ -d /system_root/system ]; then
|
|
||||||
mkdir -p /system
|
if [ -f /system/build.prop ]; then
|
||||||
|
SYSTEM=/system
|
||||||
|
elif [ -f /system/system/build.prop -o -f /system/init -o -L /system/init ]; then
|
||||||
|
SYSTEM_AS_ROOT=true
|
||||||
|
SYSTEM=/system/system
|
||||||
|
if ! mount --move /system /system_root; then
|
||||||
|
umount /system
|
||||||
|
umount -l /system
|
||||||
|
moun -o rw ${SYSTEM_BLOCK} /system_root
|
||||||
|
fi
|
||||||
mount -o bind /system_root/system /system
|
mount -o bind /system_root/system /system
|
||||||
fi
|
fi
|
||||||
elif [ -d /system ]; then
|
|
||||||
mount -o rw /system || mount -o rw ${SYSTEM_BLOCK} /system
|
|
||||||
if [ -d /system/system ]; then
|
|
||||||
mkdir -p /system
|
|
||||||
mount -o bind /system/system
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
vendor_tmp=$(find /dev/block \( -type b -o -type c -o -type l \) -name vendor${SLOT} | head -n 1)
|
VENDOR_BLOCK=$(find_block vendor)
|
||||||
echo " INFO: #6 [vendor_tmp] ${vendor_tmp}"
|
|
||||||
VENDOR_BLOCK=$(readlink -f ${vendor_tmp})
|
|
||||||
echo " INFO: #7 [VENDOR_BLOCK] ${VENDOR_BLOCK}"
|
echo " INFO: #7 [VENDOR_BLOCK] ${VENDOR_BLOCK}"
|
||||||
|
|
||||||
! is_mounted /vendor && mount -o ro /vendor
|
! is_mounted /vendor && mount -o ro /vendor
|
||||||
|
Loading…
Reference in New Issue
Block a user