Thanks Captain_Throwback! This testing with readlink stuff is new to me, but I worked through it in adb shell and it makes enough sense to me now that I adapted the above to the rest of my usual script so the latter changes aren't necessary. No real functional changes necessary as you can see.
I did touch up Chainfire's new su.img loop mount script more to my liking though and made sure it all works with CMR's toybox implementation (as I'm sure was also his main concern with it), as well as saves us a few steps if we're using a more sensible recovery like TWRP:
Just reviewing and making the mount changes on my adb and nano installers then I'll have all 3 updated. :good:
Code:
# embedded mode support
readlink /proc/$$/fd/$2 2>/dev/null | grep /tmp >/dev/null;
if [ "$?" -eq "0" ]; then
# rerouted to log file, so suppress recovery ui commands
OUTFD=/proc/self/fd/0;
# try to find the actual fd (pipe with parent updater likely started as 'update-binary 3 fd zipfile')
for FD in `ls /proc/$$/fd`; do
readlink /proc/$$/fd/$FD 2>/dev/null | grep pipe >/dev/null;
if [ "$?" -eq "0" ]; then
ps | grep " 3 $FD " | grep -v grep >/dev/null;
if [ "$?" -eq "0" ]; then
OUTFD=/proc/self/fd/$FD;
break;
fi;
fi;
done;
fi;
ui_print() { echo -e "ui_print $1\nui_print" >> $OUTFD; }
show_progress() { echo "progress $1 $2" >> $OUTFD; }
set_progress() { echo "set_progress $1" >> $OUTFD; }
I did touch up Chainfire's new su.img loop mount script more to my liking though and made sure it all works with CMR's toybox implementation (as I'm sure was also his main concern with it), as well as saves us a few steps if we're using a more sensible recovery like TWRP:
Code:
mount /data;
mount /cache;
suimg=$(ls /cache/su.img /data/su.img 2>/dev/null);
if [ "$suimg" ]; then
umount /su;
test ! -e /su && mkdir /su;
mount -t ext4 -o rw,noatime $suimg /su;
for i in 0 1 2 3 4 5 6 7; do
case `mount` in
*" /su "*) break;;
esac;
loop=/dev/block/loop$i;
mknod $loop b 7 $i;
if [ ! -f "$loop" -o ! -b "$loop" ]; then
mknod $loop b 7 $i;
fi;
losetup $loop $suimg && mount -t ext4 -o loop $loop /su;
done;
test -d /su/xbin && target=/su/xbin || target=/su/bin;
else
mount -o rw,remount /system;
target=/system/xbin;
fi;
Just reviewing and making the mount changes on my adb and nano installers then I'll have all 3 updated. :good:
Last edited: