Browse Source

Display name and status of each file as it is downloaded.

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
218651e125
5 changed files with 30 additions and 18 deletions
  1. 17
    4
      src/core/monojob.c
  2. 1
    1
      src/include/gpxe/monojob.h
  3. 9
    4
      src/usr/autoboot.c
  4. 2
    8
      src/usr/dhcpmgmt.c
  5. 1
    1
      src/usr/imgmgmt.c

+ 17
- 4
src/core/monojob.c View File

@@ -16,6 +16,8 @@
16 16
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 17
  */
18 18
 
19
+#include <string.h>
20
+#include <stdio.h>
19 21
 #include <errno.h>
20 22
 #include <gpxe/process.h>
21 23
 #include <console.h>
@@ -54,11 +56,14 @@ struct job_interface monojob = {
54 56
 /**
55 57
  * Wait for single foreground job to complete
56 58
  *
59
+ * @v string		Job description to display
57 60
  * @ret rc		Job final status code
58 61
  */
59
-int monojob_wait ( void ) {
62
+int monojob_wait ( const char *string ) {
60 63
 	int key;
64
+	int rc;
61 65
 
66
+	printf ( "%s... ", string );
62 67
 	monojob_rc = -EINPROGRESS;
63 68
 	while ( monojob_rc == -EINPROGRESS ) {
64 69
 		step();
@@ -67,12 +72,20 @@ int monojob_wait ( void ) {
67 72
 			switch ( key ) {
68 73
 			case CTRL_C:
69 74
 				job_kill ( &monojob );
70
-				return -ECANCELED;
71
-				break;
75
+				rc = -ECANCELED;
76
+				goto done;
72 77
 			default:
73 78
 				break;
74 79
 			}
75 80
 		}
76 81
 	}
77
-	return monojob_rc;
82
+	rc = monojob_rc;
83
+
84
+done:
85
+	if ( rc ) {
86
+		printf ( "%s\n", strerror ( rc ) );
87
+	} else {
88
+		printf ( "ok\n" );
89
+	}
90
+	return rc;
78 91
 }

+ 1
- 1
src/include/gpxe/monojob.h View File

@@ -10,6 +10,6 @@
10 10
 struct job_interface;
11 11
 
12 12
 extern struct job_interface monojob;
13
-extern int monojob_wait ( void );
13
+extern int monojob_wait ( const char *string );
14 14
 
15 15
 #endif /* _GPXE_MONOJOB_H */

+ 9
- 4
src/usr/autoboot.c View File

@@ -61,15 +61,20 @@ static int boot_filename ( const char *filename ) {
61 61
 		return -ENOMEM;
62 62
 	}
63 63
 	if ( ( rc = imgfetch ( image, filename,
64
-			       register_and_autoexec_image ) ) != 0 ) {
64
+			       register_and_autoload_image ) ) != 0 ) {
65
+		printf ( "Could not load %s: %s\n",
66
+			 filename, strerror ( rc ) );
67
+		goto done;
68
+	}
69
+	if ( ( rc = imgexec ( image ) ) != 0 ) {
65 70
 		printf ( "Could not boot %s: %s\n",
66 71
 			 filename, strerror ( rc ) );
67
-		image_put ( image );
68
-		return rc;
72
+		goto done;
69 73
 	}
70 74
 
75
+ done:
71 76
 	image_put ( image );
72
-	return 0;
77
+	return rc;
73 78
 }
74 79
 
75 80
 /**

+ 2
- 8
src/usr/dhcpmgmt.c View File

@@ -56,15 +56,9 @@ int dhcp ( struct net_device *netdev ) {
56 56
 	}
57 57
 
58 58
 	/* Perform DHCP */
59
-	printf ( "DHCP (%s %s)...", netdev->name, netdev_hwaddr ( netdev ) );
59
+	printf ( "DHCP (%s %s)", netdev->name, netdev_hwaddr ( netdev ) );
60 60
 	if ( ( rc = start_dhcp ( &monojob, netdev, dhcp_success ) ) == 0 )
61
-		rc = monojob_wait();
62
-
63
-	if ( rc == 0 ) {
64
-		printf ( "done\n" );
65
-	} else {
66
-		printf ( "failed (%s)\n", strerror ( rc ) );
67
-	}
61
+		rc = monojob_wait ( "" );
68 62
 
69 63
 	return rc;
70 64
 }

+ 1
- 1
src/usr/imgmgmt.c View File

@@ -53,7 +53,7 @@ int imgfetch ( struct image *image, const char *uri_string,
53 53
 
54 54
 	if ( ( rc = create_downloader ( &monojob, image, image_register,
55 55
 					LOCATION_URI, uri ) ) == 0 )
56
-		rc = monojob_wait();
56
+		rc = monojob_wait ( uri_string );
57 57
 
58 58
 	uri_put ( uri );
59 59
 	return rc;

Loading…
Cancel
Save