From: Mamoru Sakaue / MwGhennndo Date: Tue, 24 Jul 2018 18:26:20 +0000 (+0800) Subject: Probably finally fixed the part to detect and recover remained unmount. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=9c01eb6fcbb04759cf8ef914d31af93ff6c204dc;hp=1e4b98464e53df296d287823d26b73e7ff176731;p=portsreinstall%2Fcurrent.git Probably finally fixed the part to detect and recover remained unmount. Changes to be committed: modified: lib/chroot/libfs.sh modified: lib/libfs.sh --- diff --git a/lib/chroot/libfs.sh b/lib/chroot/libfs.sh index 3023746..770f532 100644 --- a/lib/chroot/libfs.sh +++ b/lib/chroot/libfs.sh @@ -7,6 +7,9 @@ # This software is distributed under the 2-Clause BSD License. # ============================================================================== +FS_UNMOUNT_RETIAL_MAXNUM=5 # Number of retrial of unmounting +FS_UNMOUNT_RETIAL_WAIT=3 # Wait seconds in retrial of unmounting + # ============= Check the safety of the base directory of builder chroot environment ============= fs_chk_safety_basedir () { @@ -372,7 +375,16 @@ fs_unmount () message_echo "Unmounting the file systems for builder chroot." fs_gen_fstab umount -F "${DBDIR}/fstab" -af 2> /dev/null || : - if ! fs_chk_unmount "$systembase" + itrial=${FS_UNMOUNT_RETIAL_MAXNUM} + while [ $itrial -gt 0 ] + do + fs_chk_unmount "$systembase" && break + message_echo "(Retrying to unmount the file systems...)" >&2 + sleep ${FS_UNMOUNT_RETIAL_WAIT} + umount -F "${DBDIR}/fstab" -af 2> /dev/null || : + itrial=$(($itrial-1)) + done + if [ $itrial -eq 0 ] then message_echo "WARNING: Failed to unmount the file systems. Some of them remain mounted." >&2 return 1 diff --git a/lib/libfs.sh b/lib/libfs.sh index 934d5de..9dc703a 100644 --- a/lib/libfs.sh +++ b/lib/libfs.sh @@ -127,10 +127,25 @@ fs_get_actual_mount_point_pattern () { local mountpoint basedir mountpoint_real mountpoint=$1 - [ -e "$mountpoint" ] || return fs_inspect_fs_privilege basedir=`cat "${TMPDIR}"/fs_privilege/basedir 2> /dev/null || :` - mountpoint_real=`realpath "$mountpoint"` + if [ -e "$mountpoint" ] + then + mountpoint_real=`realpath "$mountpoint"` + else + curdir=$mountpoint + curnode=$mountpoint + relative= + while { curbase=`basename "$curdir"`; curdir=`dirname "$curdir"`; [ -n "$curdir" ]; } + do + relative=$curbase/$relative + if [ -e "$curdir" ] + then + mountpoint_real=`realpath "$curdir"`/$relative + break + fi + done + fi mountpoint_real_full=`str_regularize_df_path "$basedir/$mountpoint_real"` str_escape_regexp "$mountpoint_real_full" }