Stale device link detection completed and tested. More testing required.

This commit is contained in:
erdgeist 2007-03-23 16:08:43 +00:00
parent 59dde63a40
commit 312c276483
2 changed files with 8 additions and 3 deletions

View File

@ -120,7 +120,12 @@ fetchjailinfo () {
if [ -n "${ezjail_image}" -a -L "${ezjail_rootdir}.device" ]; then
# Fetch destination of soft link
ezjail_device=`stat -f "%Y" ${ezjail_rootdir}.device`
[ -e "${ezjail_device}" ] && ezjail_attached="YES"
mount -p -v | grep -q -E "^${ezjail_rootdir}.device.${ezjail_rootdir}" && ezjail_attached="YES"
mount -p -v | grep -q -E "^${ezjail_device}.${ezjail_rootdir}" && ezjail_attached="YES"
# Stale device link detected. Remove and clean.
[ -z "${ezjail_attached}" ] && unset ezjail_device && rm -f ${ezjail_rootdir}.device
fi
[ -f /var/run/jail_${ezjail_safename}.id ] && ezjail_id=`cat /var/run/jail_${ezjail_safename}.id` || return

View File

@ -102,8 +102,8 @@ attach_detach_pre ()
# Fetch destination of soft link
ezjail_device=`stat -f "%Y" ${ezjail_rootdir}.device`
mount -p -v | grep -E "^${ezjail_rootdir}.device.${ezjail_rootdir}" && echo "Jail image file ${ezjail} already attached as ${ezjail_device}. 'ezjail-admin config -i detach' it first." && return 1
mount -p -v | grep -E "^${ezjail_device}.${ezjail_rootdir}" && echo "Jail image file ${ezjail} already attached as ${ezjail_device}. 'ezjail-admin config -i detach' it first." && return 1
mount -p -v | grep -E "^${ezjail_rootdir}.device.${ezjail_rootdir}" && echo "Warning: Skipping jail. Jail image file ${ezjail} already attached as ${ezjail_device}. 'ezjail-admin config -i detach' it first." && return 1
mount -p -v | grep -E "^${ezjail_device}.${ezjail_rootdir}" && echo "Warning: Skipping jail. Jail image file ${ezjail} already attached as ${ezjail_device}. 'ezjail-admin config -i detach' it first." && return 1
# Remove stale device link
rm -f ${ezjail_rootdir}.device