2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00

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 <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
Stanislav Kinsburskiy
2016-08-29 14:07:00 +03:00
committed by Pavel Emelyanov
parent 6b06210603
commit 333373110c

View File

@@ -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