1 # Functions used from inside of initrd.
4 # Wait for specific /dev files to appear but only one
5 # time regardless how often this function is called
6 # in one initrd run. Needs writable /tmp.
8 local i=0 timeout=30 all_found not_found wff_dir fpath file
9 while getopts t: opt "$@"; do
16 echo "$0: wait_for_files: unknown option" >&2
23 wff_dir="/tmp/wait_for_files"
25 [ ! -d "$wff_dir" ] && mkdir "$wff_dir"
27 echo "Waiting for files ($@) with ${timeout}s timeout"
29 timeout=$((timeout * 4))
30 while [ $i -lt $timeout ]; do
33 fpath="$wff_dir/${file}"
34 [ -e "$fpath" -o -e "$file" ] && continue
37 if [ $all_found -eq 1 ]; then
44 # mark files that we have waited for
46 fpath="$wff_dir/${file}"
47 [ ! -e "$fpath" ] && mkdir -p "$fpath"
48 [ ! -e "$file" ] && not_found="$not_found $file"
50 echo "Waiting for files ($@) finished. Missing files: $not_found"