Fix removal of dirs from unmounted filesystems.

This commit is contained in:
vermaden 2022-02-20 22:35:05 +01:00
parent 1b69cda21f
commit 466712252a
1 changed files with 3 additions and 2 deletions

View File

@ -336,6 +336,7 @@ __remove_dir() { # 1=TARGET
then then
if [ -d "${1}" ] if [ -d "${1}" ]
then then
sleep 1
find "${1}" -type d -empty -maxdepth 1 -exec rm -r {} '+' 2> /dev/null find "${1}" -type d -empty -maxdepth 1 -exec rm -r {} '+' 2> /dev/null
fi fi
fi fi
@ -740,7 +741,7 @@ case ${2} in
( # put entire umount/find/rm block into background ( # put entire umount/find/rm block into background
umount -f "${TARGET}" 1> /dev/null 2>&1 umount -f "${TARGET}" 1> /dev/null 2>&1
__log "${DEV}: (state) umount '${TARGET}'" __log "${DEV}: (state) umount '${TARGET}'"
__remove_dir "${TARGET}" __remove_dir "${TARGET}" &
__log "${DEV}: (state) mount point '${TARGET}' removed" __log "${DEV}: (state) mount point '${TARGET}' removed"
) & ) &
unset TARGET unset TARGET
@ -751,7 +752,7 @@ case ${2} in
then then
umount -f "${MNT_PREFIX}/${1}" 1> /dev/null 2>&1 umount -f "${MNT_PREFIX}/${1}" 1> /dev/null 2>&1
__log "${DEV}: (direct) umount '${MNT_PREFIX}/${1}'" __log "${DEV}: (direct) umount '${MNT_PREFIX}/${1}'"
__remove_dir "${MNT_PREFIX}/${1}" __remove_dir "${MNT_PREFIX}/${1}" &
__log "${DEV}: (direct) mount point '${MNT_PREFIX}/${1}' removed" __log "${DEV}: (direct) mount point '${MNT_PREFIX}/${1}' removed"
fi fi
__show_message "Device '${DEV}' unmounted from '${MNT}' directory." __show_message "Device '${DEV}' unmounted from '${MNT}' directory."