show_mounted_info(){
echo "+++++++"
echo "Loopback devices :"
- sudo losetup -a
+ sudo /sbin/losetup -a
echo "Are mounted on :"
mount|grep loop
echo "For these Union :"
}
mountPnd() {
- MOUNT_TARGET=${1:-$PND_MOUNT_DIR}
+ MOUNT_TARGET="${1:-$PND_MOUNT_DIR}"
if ! is_pnd_mounted;then
#check if pnd is already attached to loop
- LOOP=$(losetup -a | grep "$PND" | tail -n1 | awk -F: '{print $1}')
+ LOOP=$(/sbin/losetup -a | grep "$PND" | tail -n1 | awk -F: '{print $1}')
#check if the loop device is already mounted
if ! [ -z "$LOOP" ];then
echo "Found a loop ($LOOP), using it"
#detect fs
case $PND_FSTYPE in
ISO)
- /sbin/losetup $FREELOOP "$PND" #attach the pnd to the loop device
- mntline="mount" #setup the mountline for later
+ /sbin/losetup -r $FREELOOP "$PND" #attach the pnd to the loop device
+ mntline="mount -o ro" #setup the mountline for later
mntdev="${FREELOOP}"
;;
directory)
mntdev="${PND}"
;;
Squashfs)
- /sbin/losetup $FREELOOP "$PND" #attach the pnd to the loop device
- mntline="mount -t squashfs"
+ /sbin/losetup -r $FREELOOP "$PND" #attach the pnd to the loop device
+ mntline="mount -t squashfs -o ro"
mntdev="${FREELOOP}"
;;
*)
# Clean the loopback device
if [ $PND_FSTYPE = ISO ] || [ $PND_FSTYPE = Squashfs ]; then # check if we where running an iso, clean up loop device if we did
- LOOP=$(losetup -a | grep "$(basename $PND)" | tail -n1 | awk -F: '{print $1}')
+ LOOP=$(/sbin/losetup -a | grep "$(basename $PND)" | tail -n1 | awk -F: '{print $1}')
/sbin/losetup -d $LOOP
#rm $LOOP
fi
- losetup -a|cut -d':' -f 1|while read l;do
+ /sbin/losetup -a|cut -d':' -f 1|while read l;do
if ! mount|grep -q $l;then
echo "WARNING Found $l loop as unused. flushing"
/sbin/losetup -d $l
}
umountPnd() {
+ MOUNT_TARGET="${1:-$PND_MOUNT_DIR}"
if is_pnd_mounted;then
PND_WaitFor noMoreProcessPnd "Waiting the PND mount dir to be free"
- umount "$PND_MOUNT_DIR/$PND_NAME"
+ umount "$MOUNT_TARGET/$PND_NAME"
fi
if is_pnd_mounted; then
echo WARNING umount PND failed, didnt clean up. Process still using this FS :
- list_using_fs "$PND_MOUNT_DIR/$PND_NAME"
+ list_using_fs "$MOUNT_TARGET/$PND_NAME"
show_mounted_info
else
# removing the now useless mountpoint
- if [ -d $PND_MOUNT_DIR/$PND_NAME ];then
- rmdir "$PND_MOUNT_DIR/$PND_NAME"
+ if [ -d "$MOUNT_TARGET/$PND_NAME" ];then
+ rmdir "$MOUNT_TARGET/$PND_NAME"
+ fi
+ if [ -h "$PND_MOUNT_DIR/$PND_NAME" ];then
+ rm "$PND_MOUNT_DIR/$PND_NAME"
fi
# All went well, cleaning
fi
fi
# Try umounting the PND
- umountPnd
+ umountPnd $UNION_MOUNT_DIR
fi
}
fi
export XDG_CONFIG_HOME="$UNION_MOUNT_DIR/$PND_NAME"
+ export REAL_HOME="$HOME"
+ export HOME="$UNION_MOUNT_DIR/$PND_NAME"
if echo "$EXENAME"|grep -q ^\.\/;then
"$EXENAME" $ARGUMENTS
else
"./$EXENAME" $ARGUMENTS
+ fi
RC=$?
#the app could have exited now, OR it went into bg, we still need to wait in that case till it really quits!
sleep 10s
PID=`pidof -o %PPID -x \"$EXENAME\"`
done
+ export HOME="$REAL_HOME"
return $RC
}
PND_EndTask
fi
oPWD=$(pwd)
+ old_fb0_geometry=$(fbset -fb /dev/fb0 -s | grep geometry | awk '{print $2, $3, $4, $5, $6}')
if [ -e "${APPDATADIR}/PND_pre_script.sh" ]; then
PND_BeginTask "Starting user configured pre-script"
. ${APPDATADIR}/PND_pre_script.sh # Sourcing so it can shared vars with post-script ;)
PND_resetCPUSpeed
PND_EndTask
fi
+ PND_BeginTask "Restoring the frame buffer status"
+ fbset -fb /dev/fb0 -g $old_fb0_geometry
+ if ! lsof /dev/fb1 > /dev/null; then
+ ofbset -fb /dev/fb1 -mem 0 -size 0 0 -en 0
+ fi
+ PND_EndTask
PND_BeginTask "uMount the PND"
umountUnion
PND_EndTask