From: Michael Brown Date: Fri, 3 Aug 2007 11:49:21 +0000 (+0100) Subject: Display name and status of each file as it is downloaded. X-Git-Tag: v0.9.3~121^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=218651e1259da924a19db66e7cb9ae885075892f;p=thirdparty%2Fipxe.git Display name and status of each file as it is downloaded. --- diff --git a/src/core/monojob.c b/src/core/monojob.c index b4042a3d3..ea9bc8348 100644 --- a/src/core/monojob.c +++ b/src/core/monojob.c @@ -16,6 +16,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include +#include #include #include #include @@ -54,11 +56,14 @@ struct job_interface monojob = { /** * Wait for single foreground job to complete * + * @v string Job description to display * @ret rc Job final status code */ -int monojob_wait ( void ) { +int monojob_wait ( const char *string ) { int key; + int rc; + printf ( "%s... ", string ); monojob_rc = -EINPROGRESS; while ( monojob_rc == -EINPROGRESS ) { step(); @@ -67,12 +72,20 @@ int monojob_wait ( void ) { switch ( key ) { case CTRL_C: job_kill ( &monojob ); - return -ECANCELED; - break; + rc = -ECANCELED; + goto done; default: break; } } } - return monojob_rc; + rc = monojob_rc; + +done: + if ( rc ) { + printf ( "%s\n", strerror ( rc ) ); + } else { + printf ( "ok\n" ); + } + return rc; } diff --git a/src/include/gpxe/monojob.h b/src/include/gpxe/monojob.h index f6cebb6b8..aaa38d03c 100644 --- a/src/include/gpxe/monojob.h +++ b/src/include/gpxe/monojob.h @@ -10,6 +10,6 @@ struct job_interface; extern struct job_interface monojob; -extern int monojob_wait ( void ); +extern int monojob_wait ( const char *string ); #endif /* _GPXE_MONOJOB_H */ diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c index 2afe596eb..918369784 100644 --- a/src/usr/autoboot.c +++ b/src/usr/autoboot.c @@ -61,15 +61,20 @@ static int boot_filename ( const char *filename ) { return -ENOMEM; } if ( ( rc = imgfetch ( image, filename, - register_and_autoexec_image ) ) != 0 ) { + register_and_autoload_image ) ) != 0 ) { + printf ( "Could not load %s: %s\n", + filename, strerror ( rc ) ); + goto done; + } + if ( ( rc = imgexec ( image ) ) != 0 ) { printf ( "Could not boot %s: %s\n", filename, strerror ( rc ) ); - image_put ( image ); - return rc; + goto done; } + done: image_put ( image ); - return 0; + return rc; } /** diff --git a/src/usr/dhcpmgmt.c b/src/usr/dhcpmgmt.c index f1eb2d635..bd05c5ee0 100644 --- a/src/usr/dhcpmgmt.c +++ b/src/usr/dhcpmgmt.c @@ -56,15 +56,9 @@ int dhcp ( struct net_device *netdev ) { } /* Perform DHCP */ - printf ( "DHCP (%s %s)...", netdev->name, netdev_hwaddr ( netdev ) ); + printf ( "DHCP (%s %s)", netdev->name, netdev_hwaddr ( netdev ) ); if ( ( rc = start_dhcp ( &monojob, netdev, dhcp_success ) ) == 0 ) - rc = monojob_wait(); - - if ( rc == 0 ) { - printf ( "done\n" ); - } else { - printf ( "failed (%s)\n", strerror ( rc ) ); - } + rc = monojob_wait ( "" ); return rc; } diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c index 0a77469a9..bead48678 100644 --- a/src/usr/imgmgmt.c +++ b/src/usr/imgmgmt.c @@ -53,7 +53,7 @@ int imgfetch ( struct image *image, const char *uri_string, if ( ( rc = create_downloader ( &monojob, image, image_register, LOCATION_URI, uri ) ) == 0 ) - rc = monojob_wait(); + rc = monojob_wait ( uri_string ); uri_put ( uri ); return rc;