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
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
  */
17
  */
18
 
18
 
19
+#include <string.h>
20
+#include <stdio.h>
19
 #include <errno.h>
21
 #include <errno.h>
20
 #include <gpxe/process.h>
22
 #include <gpxe/process.h>
21
 #include <console.h>
23
 #include <console.h>
54
 /**
56
 /**
55
  * Wait for single foreground job to complete
57
  * Wait for single foreground job to complete
56
  *
58
  *
59
+ * @v string		Job description to display
57
  * @ret rc		Job final status code
60
  * @ret rc		Job final status code
58
  */
61
  */
59
-int monojob_wait ( void ) {
62
+int monojob_wait ( const char *string ) {
60
 	int key;
63
 	int key;
64
+	int rc;
61
 
65
 
66
+	printf ( "%s... ", string );
62
 	monojob_rc = -EINPROGRESS;
67
 	monojob_rc = -EINPROGRESS;
63
 	while ( monojob_rc == -EINPROGRESS ) {
68
 	while ( monojob_rc == -EINPROGRESS ) {
64
 		step();
69
 		step();
67
 			switch ( key ) {
72
 			switch ( key ) {
68
 			case CTRL_C:
73
 			case CTRL_C:
69
 				job_kill ( &monojob );
74
 				job_kill ( &monojob );
70
-				return -ECANCELED;
71
-				break;
75
+				rc = -ECANCELED;
76
+				goto done;
72
 			default:
77
 			default:
73
 				break;
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
 struct job_interface;
10
 struct job_interface;
11
 
11
 
12
 extern struct job_interface monojob;
12
 extern struct job_interface monojob;
13
-extern int monojob_wait ( void );
13
+extern int monojob_wait ( const char *string );
14
 
14
 
15
 #endif /* _GPXE_MONOJOB_H */
15
 #endif /* _GPXE_MONOJOB_H */

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

61
 		return -ENOMEM;
61
 		return -ENOMEM;
62
 	}
62
 	}
63
 	if ( ( rc = imgfetch ( image, filename,
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
 		printf ( "Could not boot %s: %s\n",
70
 		printf ( "Could not boot %s: %s\n",
66
 			 filename, strerror ( rc ) );
71
 			 filename, strerror ( rc ) );
67
-		image_put ( image );
68
-		return rc;
72
+		goto done;
69
 	}
73
 	}
70
 
74
 
75
+ done:
71
 	image_put ( image );
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
 	}
56
 	}
57
 
57
 
58
 	/* Perform DHCP */
58
 	/* Perform DHCP */
59
-	printf ( "DHCP (%s %s)...", netdev->name, netdev_hwaddr ( netdev ) );
59
+	printf ( "DHCP (%s %s)", netdev->name, netdev_hwaddr ( netdev ) );
60
 	if ( ( rc = start_dhcp ( &monojob, netdev, dhcp_success ) ) == 0 )
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
 	return rc;
63
 	return rc;
70
 }
64
 }

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

53
 
53
 
54
 	if ( ( rc = create_downloader ( &monojob, image, image_register,
54
 	if ( ( rc = create_downloader ( &monojob, image, image_register,
55
 					LOCATION_URI, uri ) ) == 0 )
55
 					LOCATION_URI, uri ) ) == 0 )
56
-		rc = monojob_wait();
56
+		rc = monojob_wait ( uri_string );
57
 
57
 
58
 	uri_put ( uri );
58
 	uri_put ( uri );
59
 	return rc;
59
 	return rc;

Loading…
Cancel
Save