[make-initrd] [PATCH v1 19/41] fork pipeline: waitdev: use optional waitdev_timeout

Leonid Krivoshein klark.devel at gmail.com
Fri Sep 24 18:57:30 MSK 2021


---
  .../data/lib/bootchain/waitdev                 | 18 ++++++++++++++++++
  1 file changed, 18 insertions(+)

diff --git 
a/make-initrd/features/bootchain-waitdev/data/lib/bootchain/waitdev 
b/make-initrd/features/bootchain-waitdev/data/lib/bootchain/waitdev
index 60464d9..fa99c45 100755
--- a/make-initrd/features/bootchain-waitdev/data/lib/bootchain/waitdev
+++ b/make-initrd/features/bootchain-waitdev/data/lib/bootchain/waitdev
@@ -3,6 +3,14 @@
  . bootchain-sh-functions
   check_parameter WAITDEV
+
+timeout=
+timecnt=/.initrd/bootchain/waitdev/TIMECNT
+
+[ ! -s "$timecnt" ] ||
+	read -r timeout < "$timecnt" ||:
+[ "$timeout" != 0 ] ||
+	exit 0
  devspec="$(get_parameter WAITDEV)"
   while [ -n "$devspec" ]; do
@@ -25,4 +33,14 @@ while [ -n "$devspec" ]; do
  	fi
   	sleep 1
+	[ -n "$timeout" ] ||
+		continue
+	timeout=$(($timeout - 1))
+
+	if [ "$timeout" = 0 ]; then
+		message "device waiting timeout exceedded"
+		break
+	fi
  done
+
+[ -z "$timeout" ] || printf '%s\n' "$timeout" > "$timecnt"
-- 
2.21.0




More information about the Make-initrd mailing list