]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[ui] Add progress dots while waiting on any foreground job
authorMichael Brown <mcb30@etherboot.org>
Thu, 24 Jul 2008 19:08:31 +0000 (20:08 +0100)
committerMichael Brown <mcb30@etherboot.org>
Thu, 24 Jul 2008 19:08:31 +0000 (20:08 +0100)
Print one dot per second while waiting in monojob.c (e.g. for DHCP,
for file downloads, etc.), to inform user that the system has not
locked up.

Patch contributed by Andrew Schran <aschran@google.com>, minor
modification by me.

src/core/monojob.c

index ea9bc83482c3a080240ef3a2274c403f7ea58e12..2c91e132287d47c8ee3be2fd2db3a6912da1eb9a 100644 (file)
@@ -24,6 +24,7 @@
 #include <gpxe/keys.h>
 #include <gpxe/job.h>
 #include <gpxe/monojob.h>
+#include <gpxe/timer.h>
 
 /** @file
  *
@@ -62,9 +63,11 @@ struct job_interface monojob = {
 int monojob_wait ( const char *string ) {
        int key;
        int rc;
+       tick_t last_progress_dot;
 
-       printf ( "%s... ", string );
+       printf ( "%s.", string );
        monojob_rc = -EINPROGRESS;
+       last_progress_dot = currticks();
        while ( monojob_rc == -EINPROGRESS ) {
                step();
                if ( iskey() ) {
@@ -78,14 +81,18 @@ int monojob_wait ( const char *string ) {
                                break;
                        }
                }
+               if ( ( currticks() - last_progress_dot ) > TICKS_PER_SEC ) {
+                       printf ( "." );
+                       last_progress_dot = currticks();
+               }
        }
        rc = monojob_rc;
 
 done:
        if ( rc ) {
-               printf ( "%s\n", strerror ( rc ) );
+               printf ( " %s\n", strerror ( rc ) );
        } else {
-               printf ( "ok\n" );
+               printf ( " ok\n" );
        }
        return rc;
 }