[CRIU] [PATCH] systemd-autofs-restart.sh: fix error handling in case of system limitation
Stanislav Kinsburskiy
skinsbursky at virtuozzo.com
Mon Aug 29 04:07:08 PDT 2016
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 at virtuozzo.com>
---
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 01d9202..8d4f71e 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
More information about the CRIU
mailing list