From 333373110c9a0cc51a7076ef902e2f13b968dc2f Mon Sep 17 00:00:00 2001 From: Stanislav Kinsburskiy Date: Mon, 29 Aug 2016 14:07:00 +0300 Subject: [PATCH] systemd-autofs-restart.sh: fix error handling in case of system limitation Without this patch any error in check_fs_type function is considered as a grant to process to bind-mount. This patch splits mount point fs type discovering and comparison to autofs type, thus allowing to check for discovery errors. Signed-off-by: Stanislav Kinsburskiy Signed-off-by: Pavel Emelyanov --- scripts/systemd-autofs-restart.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/systemd-autofs-restart.sh b/scripts/systemd-autofs-restart.sh index 01d9202cd..8d4f71ef5 100755 --- a/scripts/systemd-autofs-restart.sh +++ b/scripts/systemd-autofs-restart.sh @@ -52,9 +52,8 @@ function remove_bindmount { } trap remove_bindmount EXIT -function check_fs_type { +function get_fs_type { local mountpoint=$1 - local fs_type=$2 local top_mount_id="" local top_mount_fs_type="" @@ -74,7 +73,7 @@ function check_fs_type { top_mount_fs_type=$mnt_fs_type done < "/proc/$CRTOOLS_INIT_PID/mountinfo" - [ "$top_mount_fs_type" = "$fs_type" ] + echo $top_mount_fs_type } function bind_mount { @@ -89,9 +88,16 @@ function bind_mount { function save_mountpoint { local mountpoint=$1 + local top_mount_fs_type="" + + top_mount_fs_type=$(get_fs_type $mountpoint) + if [ $? -ne 0 ]; then + echo "Failed to discover $mountpoint mount point type" + return + fi # Nothing to do, if no file system is on top of autofs - check_fs_type $mountpoint "autofs" && return + [ "$top_mount_fs_type" = "autofs" ] && return bindmount=$($JOIN_CT mktemp -d) if [ -z "$bindmount" ]; then