aboutsummaryrefslogtreecommitdiffstats
path: root/init/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'init/util.c')
-rw-r--r--init/util.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/init/util.c b/init/util.c
index b955e7e7..761c51b3 100644
--- a/init/util.c
+++ b/init/util.c
@@ -378,3 +378,15 @@ void remove_link(const char *oldpath, const char *newpath)
if (!strcmp(path, oldpath))
unlink(newpath);
}
+
+int wait_for_file(const char *filename, int timeout)
+{
+ struct stat info;
+ time_t timeout_time = gettime() + timeout;
+ int ret = -1;
+
+ while (gettime() < timeout_time && ((ret = stat(filename, &info)) < 0))
+ usleep(10000);
+
+ return ret;
+}