---
init/init.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/init/init.c b/init/init.c
index 473a5c5..a6279b8 100644
--- a/init/init.c
+++ b/init/init.c
@@ -101,13 +101,19 @@ main ()
char *root, *path;
size_t len;
int dax = 0;
- uint64_t delay_ns = 250000;
+ uint64_t delay_ns;
int virtio_message = 0;
- struct timespec t;
int major, minor;
char *p;
const char *mount_options = "";
+ struct timespec t;
+#define NANOSLEEP(ns) do { \
+ t.tv_sec = delay_ns / 1000000000; \
+ t.tv_nsec = delay_ns % 1000000000; \
+ nanosleep (&t, NULL); \
+ } while(0)
+
mount_proc ();
fprintf (stderr, "supermin: ext2 mini initrd starting up: "
@@ -184,7 +190,9 @@ main ()
asprintf (&path, "/sys/block/%s/dev", root);
- while (delay_ns <= MAX_ROOT_WAIT * UINT64_C(1000000000)) {
+ for (delay_ns = 250000;
+ delay_ns <= MAX_ROOT_WAIT * UINT64_C(1000000000);
+ delay_ns *= 2) {
fp = fopen (path, "r");
if (fp != NULL)
break;
@@ -201,10 +209,7 @@ main ()
}
}
- t.tv_sec = delay_ns / 1000000000;
- t.tv_nsec = delay_ns % 1000000000;
- nanosleep (&t, NULL);
- delay_ns *= 2;
+ NANOSLEEP (delay_ns);
}
if (!quiet)
--
2.12.0