Commit 33337311 authored by Stanislav Kinsburskiy's avatar Stanislav Kinsburskiy Committed by Pavel Emelyanov

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: 's avatarStanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 6b062106
...@@ -52,9 +52,8 @@ function remove_bindmount { ...@@ -52,9 +52,8 @@ function remove_bindmount {
} }
trap remove_bindmount EXIT trap remove_bindmount EXIT
function check_fs_type { function get_fs_type {
local mountpoint=$1 local mountpoint=$1
local fs_type=$2
local top_mount_id="" local top_mount_id=""
local top_mount_fs_type="" local top_mount_fs_type=""
...@@ -74,7 +73,7 @@ function check_fs_type { ...@@ -74,7 +73,7 @@ function check_fs_type {
top_mount_fs_type=$mnt_fs_type top_mount_fs_type=$mnt_fs_type
done < "/proc/$CRTOOLS_INIT_PID/mountinfo" done < "/proc/$CRTOOLS_INIT_PID/mountinfo"
[ "$top_mount_fs_type" = "$fs_type" ] echo $top_mount_fs_type
} }
function bind_mount { function bind_mount {
...@@ -89,9 +88,16 @@ function bind_mount { ...@@ -89,9 +88,16 @@ function bind_mount {
function save_mountpoint { function save_mountpoint {
local mountpoint=$1 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 # 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) bindmount=$($JOIN_CT mktemp -d)
if [ -z "$bindmount" ]; then if [ -z "$bindmount" ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment