Commit 9f899374 authored by Stanislav Kinsburskiy's avatar Stanislav Kinsburskiy Committed by Pavel Emelyanov

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

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: 's avatarStanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 40682f15
......@@ -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 {
......
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