[CRIU] [PATCH] scripts: do not use stat to discover fs type in systemd-autofs-restart.sh

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Mon May 2 09:43:55 PDT 2016


Unfortunatelly, autofs doesn't allow to discover it's type. At least without
accessing master process. That means, that stat can be used to determine
whether some other file system is mounted on top of autofs (which we need to
take a decision whether to move restore fs aside or not), because it simply
stuck.
This patch does fs type discovering by parsing CTs mountinfo.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
 scripts/systemd-autofs-restart.sh |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/scripts/systemd-autofs-restart.sh b/scripts/systemd-autofs-restart.sh
index 9b02e11..af4ad8f 100755
--- a/scripts/systemd-autofs-restart.sh
+++ b/scripts/systemd-autofs-restart.sh
@@ -56,7 +56,25 @@ function check_fs_type {
 	local mountpoint=$1
 	local fs_type=$2
 
-	[  "$($JOIN_CT stat -f --printf=%T $mountpoint)" = "$fs_type" ]
+	local top_mount_id=""
+	local top_mount_fs_type=""
+
+	while IFS='' read -r line || [[ -n "$line" ]]; do
+		# Skip those entries which do not match the mountpoint
+		[ $(echo $line | awk '{print $5;}') = $mountpoint ] || continue
+
+		local mnt_id=$(echo $line | awk '{print $1;}')
+		local mnt_parent_id=$(echo $line | awk '{print $2;}')
+		local mnt_fs_type=$(echo $line | awk '{print $9;}')
+
+		# Skip mount entry, if not the first one and not a child
+		[ -n "$top_mount_id" ] && [ "$mnt_parent_id" != "$top_mount_id" ] && continue
+
+		top_mount_id=$mnt_id
+		top_mount_fs_type=$mnt_fs_type
+	done < "/proc/$CRTOOLS_INIT_PID/mountinfo"
+
+	[ $top_mount_fs_type = $fs_type ]
 }
 
 function bind_mount {



More information about the CRIU mailing list