|
@@ -40,11 +40,11 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
40
|
40
|
*
|
41
|
41
|
* @v image Image
|
42
|
42
|
* @v uri URI
|
43
|
|
- * @v image_register Action to take upon a successful download
|
|
43
|
+ * @v action Action to take upon a successful download
|
44
|
44
|
* @ret rc Return status code
|
45
|
45
|
*/
|
46
|
46
|
int imgdownload ( struct image *image, struct uri *uri,
|
47
|
|
- int ( * image_register ) ( struct image *image ) ) {
|
|
47
|
+ int ( * action ) ( struct image *image ) ) {
|
48
|
48
|
size_t len = ( unparse_uri ( NULL, 0, uri, URI_ALL ) + 1 );
|
49
|
49
|
char uri_string_redacted[len];
|
50
|
50
|
const char *password;
|
|
@@ -62,14 +62,18 @@ int imgdownload ( struct image *image, struct uri *uri,
|
62
|
62
|
uri->password = password;
|
63
|
63
|
|
64
|
64
|
/* Create downloader */
|
65
|
|
- if ( ( rc = create_downloader ( &monojob, image, image_register,
|
66
|
|
- LOCATION_URI, uri ) ) != 0 )
|
|
65
|
+ if ( ( rc = create_downloader ( &monojob, image, LOCATION_URI,
|
|
66
|
+ uri ) ) != 0 )
|
67
|
67
|
return rc;
|
68
|
68
|
|
69
|
69
|
/* Wait for download to complete */
|
70
|
70
|
if ( ( rc = monojob_wait ( uri_string_redacted ) ) != 0 )
|
71
|
71
|
return rc;
|
72
|
72
|
|
|
73
|
+ /* Act upon downloaded image */
|
|
74
|
+ if ( ( rc = action ( image ) ) != 0 )
|
|
75
|
+ return rc;
|
|
76
|
+
|
73
|
77
|
return 0;
|
74
|
78
|
}
|
75
|
79
|
|
|
@@ -78,18 +82,18 @@ int imgdownload ( struct image *image, struct uri *uri,
|
78
|
82
|
*
|
79
|
83
|
* @v image Image
|
80
|
84
|
* @v uri_string URI as a string (e.g. "http://www.nowhere.com/vmlinuz")
|
81
|
|
- * @v image_register Action to take upon a successful fetch
|
|
85
|
+ * @v action Action to take upon a successful download
|
82
|
86
|
* @ret rc Return status code
|
83
|
87
|
*/
|
84
|
88
|
int imgfetch ( struct image *image, const char *uri_string,
|
85
|
|
- int ( * image_register ) ( struct image *image ) ) {
|
|
89
|
+ int ( * action ) ( struct image *image ) ) {
|
86
|
90
|
struct uri *uri;
|
87
|
91
|
int rc;
|
88
|
92
|
|
89
|
93
|
if ( ! ( uri = parse_uri ( uri_string ) ) )
|
90
|
94
|
return -ENOMEM;
|
91
|
95
|
|
92
|
|
- rc = imgdownload ( image, uri, image_register );
|
|
96
|
+ rc = imgdownload ( image, uri, action );
|
93
|
97
|
|
94
|
98
|
uri_put ( uri );
|
95
|
99
|
return rc;
|