From d0032dedcbb36dd22f52b11ed858bb828c1d15f3 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Tue, 30 Jan 2018 12:47:47 -0600 Subject: cdinit: Wait 5 seconds and try again if no system is found --- cdinit-ppc | Bin 69128 -> 74080 bytes cdinit.c | 27 +++++++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/cdinit-ppc b/cdinit-ppc index 5739320..3a478c9 100755 Binary files a/cdinit-ppc and b/cdinit-ppc differ diff --git a/cdinit.c b/cdinit.c index 6ee72a8..c24134e 100644 --- a/cdinit.c +++ b/cdinit.c @@ -91,7 +91,7 @@ bool cdi_find_media(void) udev = udev_new(); if(udev == NULL) { - fprintf(stderr, "Cannot establish link to udev.\n"); + fprintf(stderr, "Cannot establish udev link.\n"); return false; } @@ -135,15 +135,10 @@ bool cdi_find_media(void) continue; /* worthless */ } -#ifdef DEBUG - fprintf(stderr, "cdi_find_media: testing candidate %s\n", - dev_node); -#endif - if((fstype = blkid_get_tag_value(NULL, "TYPE", dev_node)) == NULL) { #ifdef DEBUG - fprintf(stderr, "cdi_find_media: %s has unknown FS\n", + fprintf(stderr, "cdi_find_media: %s: unknown FS\n", dev_node); #endif continue; @@ -151,10 +146,8 @@ bool cdi_find_media(void) if(mount(dev_node, "/media", fstype, MS_RDONLY, NULL) != 0) { -#ifdef DEBUG - fprintf(stderr, "cdi_find_media: %s cannot be mounted:" + fprintf(stderr, "cdi_find_media: mounting %s:" " %s\n", dev_node, strerror(errno)); -#endif free(fstype); continue; } @@ -163,7 +156,7 @@ bool cdi_find_media(void) if(access("/media/adelie.squashfs", F_OK) != 0) { #ifdef DEBUG - fprintf(stderr, "cdi_find_media: %s has no squash root:" + fprintf(stderr, "cdi_find_media: %s: system not found:" " %s\n", dev_node, strerror(errno)); #endif umount("/media"); @@ -224,6 +217,8 @@ bool cdi_find_media(void) int main(void) { pid_t our_pid; + bool found = false; + unsigned char tries = 4; #ifndef DEBUG if(getpid() != 1) @@ -297,7 +292,15 @@ int main(void) /* Now we need to iterate over the available block devices, trying to * find our CD media. */ - if(!cdi_find_media()) + found = cdi_find_media(); + while(!found && tries--) + { + fprintf(stderr, "Attempting to acquiesce...\n"); + sleep(5); + found = cdi_find_media(); + } + + if(!found) { fprintf(stderr, "FATAL: no boot media found\n"); return EXIT_FAILURE; -- cgit v1.2.3-70-g09d2