From e2131ed3b2f725334d31b939902df07ded60176e Mon Sep 17 00:00:00 2001 From: Mamoru Sakaue / MwGhennndo Date: Wed, 11 Jul 2018 22:19:29 +0800 Subject: [PATCH] Modefined fs_mount () and fs_unmount () to use a custom fstab. Changes to be committed: modified: lib/chroot/libfs.sh modified: lib/libmain.sh --- lib/chroot/libfs.sh | 50 +++++++++++++++++++++++--------------------------- lib/libmain.sh | 2 +- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/lib/chroot/libfs.sh b/lib/chroot/libfs.sh index 3ff26bc..490f5e6 100644 --- a/lib/chroot/libfs.sh +++ b/lib/chroot/libfs.sh @@ -235,27 +235,35 @@ fs_terminate_if_mount_unavailable () exit 2 } -# ============= Mount the file systems for the builder chroot environment if not yet ============= -fs_mount () +# ============= Generate a custom fstab file for the builder chroot environment ============= +# Output to the standard output +fs_gen_fstab () { local systembase systembase=$1 - message_echo "Mounting the file systems for builder chroot environment." fs_safeguard_basedir "$opt_basedir" while read srcline do type=`echo "$srcline" | cut -f 1` target=`echo "$srcline" | cut -f 2` - [ "x$type" = xnullfs -o "x$type" = xunionfs ] && target=$systembase/$target directory=`echo "$srcline" | cut -f 3` - opt=`echo "$srcline" | cut -f 4` - mp=`echo "$systembase/$opt_basedir/builder/$directory" | sed 's|//*|/|g;s|/$||'` - if ! fs_chk_mounted "$type" "$target" "$mp" - then - mount -t "$type" -o "$opt" "$target" "$mp" - fi + opt=`echo "$srcline" | cut -f 4 | sed 's/[[:space:]]/\\040/g'` + [ "x$type" = xnullfs -o "x$type" = xunionfs ] && target=$systembase/$target + target=`echo "$target" | sed 's/[[:space:]]/\\040/g'` + mp=`echo "$systembase/$opt_basedir/builder/$directory" | sed 's|//*|/|g;s|/$||;s/[[:space:]]/\\040/g'` + echo "$target $mp $type $opt 0 0" done < ${DBDIR}/mount_manifest - if ! fs_chk_mount "$systembase" +} + +# ============= Mount the file systems for the builder chroot environment if not yet ============= +fs_mount () +{ + local systembase tmp_fstab + systembase=$1 + tmp_fstab=${TMPDIR}/fs_mount:fstab + message_echo "Mounting the file systems for builder chroot environment." + fs_gen_fstab > $tmp_fstab + if ! mount -F "$tmp_fstab" -a || ! fs_chk_mount "$systembase" then message_echo "Error: Failed to mount the file systems. Some of them remain unmounted." >&2 exit 1 @@ -329,26 +337,14 @@ fs_terminate_if_unmount_unavailable () # ============= Unmount file systems for the chroot environment ============= fs_unmount () { - local systembase + local systembase tmp_fstab systembase=$1 + tmp_fstab=${TMPDIR}/fs_unmount:fstab [ ! -d "$systembase/$opt_basedir"/builder ] && return [ -e "${DBDIR}/mount_manifest" ] || return 0 message_echo "Unmounting the file systems for builder chroot." - fs_safeguard_basedir "$opt_basedir" - tail -r "${DBDIR}/mount_manifest" | while read srcline - do - type=`echo "$srcline" | cut -f 1` - target=`echo "$srcline" | cut -f 2` - [ "x$type" = xnullfs -o "x$type" = xunionfs ] && target=$systembase/$target - directory=`echo "$srcline" | cut -f 3` - opt=`echo "$srcline" | cut -f 4` - mp=`echo "$systembase/$opt_basedir/builder/$directory" | sed 's|//*|/|g;s|/$||'` - if fs_chk_mounted "$type" "$target" "$mp" - then - umount -f "$mp" || break - fi - done - if ! fs_chk_unmount "$systembase" + fs_gen_fstab > $tmp_fstab + if ! umount -F "$tmp_fstab" -af || ! fs_chk_unmount "$systembase" then message_echo "Error: Failed to unmount the file systems. Some of them remain mounted." >&2 exit 1 diff --git a/lib/libmain.sh b/lib/libmain.sh index 1b6c7f3..32d3c54 100644 --- a/lib/libmain.sh +++ b/lib/libmain.sh @@ -12,7 +12,7 @@ main_set_version () MYVERSION=4.0.1 COMPATIBLE_VERSIONS='^(4\.[0]\.[0-1])$' # Template for development versions - MYVERSION=4.0.0+toward_4.0.1_20180711213452 + MYVERSION=4.0.0+toward_4.0.1_20180711221910 COMPATIBLE_VERSIONS='^(4\.[0]\.[0]|4\.[0]\.[0]+(|\+toward_4\.[0]\.[1]+_[0-9]+))$' } -- 2.11.0