+static bool wait_for_file(const char *filename)
+{
+ uint32_t timeout= 6;
+ uint32_t waited;
+ uint32_t this_wait;
+ uint32_t retry;
+
+ for (waited= 0, retry= 1; ; retry++, waited+= this_wait)
+ {
+ if ((! access(filename, R_OK)) || (waited >= timeout))
+ {
+ return true;
+ }
+
+ this_wait= retry * retry / 3 + 1;
+ sleep(this_wait);
+ }
+
+ return false;
+}
+