init: make resolve_device() more readable

This commit is contained in:
illiliti 2021-05-10 14:40:38 +03:00
parent 1d8b2ca1e9
commit 50d18b28a5

11
init
View File

@ -33,14 +33,17 @@ resolve_device()
# Race condition may occur if device manager is not yet initialized device.
# To fix this, we simply waiting until device is available. If device
# didn't appear in specified time, we panic.
while [ ! -b "$device" ]; do
if [ "$((count += 1))" = "${rootdelay:=30}" ]; then
panic "failed to lookup partition"
while :; do
if [ -b "$device" ]; then
return 0
elif [ "$((count += 1))" = "${rootdelay:=30}" ]; then
break
else
sleep 1
fi
done || :
done
panic "failed to lookup partition"
}
run_hook()