OSDN Git Service

Probably finally fixed the part to detect and recover remained unmount.
authorMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Tue, 24 Jul 2018 18:26:20 +0000 (02:26 +0800)
committerMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Tue, 24 Jul 2018 18:26:20 +0000 (02:26 +0800)
 Changes to be committed:
modified:   lib/chroot/libfs.sh
modified:   lib/libfs.sh

lib/chroot/libfs.sh
lib/libfs.sh

index 3023746..770f532 100644 (file)
@@ -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
index 934d5de..9dc703a 100644 (file)
@@ -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"
 }