Browse Source

Allow images to hold references to the originating URI.

Some shuffling around of the image management code; this needs tidying up.
tags/v0.9.3
Michael Brown 17 years ago
parent
commit
d4947c05b2

+ 1
- 1
src/arch/i386/image/bzimage.c View File

190
 		return 0;
190
 		return 0;
191
 
191
 
192
 	/* Create cpio header before non-prebuilt images */
192
 	/* Create cpio header before non-prebuilt images */
193
-	if ( filename[0] ) {
193
+	if ( filename && filename[0] ) {
194
 		size_t name_len = ( strlen ( filename ) + 1 );
194
 		size_t name_len = ( strlen ( filename ) + 1 );
195
 
195
 
196
 		DBGC ( image, "bzImage %p inserting initrd %p as %s\n",
196
 		DBGC ( image, "bzImage %p inserting initrd %p as %s\n",

+ 7
- 2
src/arch/i386/image/multiboot.c View File

135
 	unsigned int insert;
135
 	unsigned int insert;
136
 	physaddr_t start;
136
 	physaddr_t start;
137
 	physaddr_t end;
137
 	physaddr_t end;
138
+	char *cmdline;
138
 	unsigned int i;
139
 	unsigned int i;
139
 
140
 
140
 	/* Add each image as a multiboot module */
141
 	/* Add each image as a multiboot module */
169
 				  ( ( count - insert ) * sizeof ( *module ) ));
170
 				  ( ( count - insert ) * sizeof ( *module ) ));
170
 			module->mod_start = start;
171
 			module->mod_start = start;
171
 			module->mod_end = end;
172
 			module->mod_end = end;
172
-			module->string = virt_to_phys ( module_image->cmdline);
173
+			cmdline = ( module_image->cmdline ?
174
+				    module_image->cmdline : "" );
175
+			module->string = virt_to_phys ( cmdline );
173
 			module->reserved = 0;
176
 			module->reserved = 0;
174
 			
177
 			
175
 			/* We promise to page-align modules */
178
 			/* We promise to page-align modules */
222
  */
225
  */
223
 static int multiboot_exec ( struct image *image ) {
226
 static int multiboot_exec ( struct image *image ) {
224
 	physaddr_t entry = image->priv.phys;
227
 	physaddr_t entry = image->priv.phys;
228
+	char *cmdline;
225
 
229
 
226
 	/* Populate multiboot information structure */
230
 	/* Populate multiboot information structure */
227
 	memset ( &mbinfo, 0, sizeof ( mbinfo ) );
231
 	memset ( &mbinfo, 0, sizeof ( mbinfo ) );
229
 			 MBI_FLAG_CMDLINE | MBI_FLAG_MODS );
233
 			 MBI_FLAG_CMDLINE | MBI_FLAG_MODS );
230
 	multiboot_build_memmap ( image, &mbinfo, mbmemmap,
234
 	multiboot_build_memmap ( image, &mbinfo, mbmemmap,
231
 				 ( sizeof(mbmemmap) / sizeof(mbmemmap[0]) ) );
235
 				 ( sizeof(mbmemmap) / sizeof(mbmemmap[0]) ) );
232
-	mbinfo.cmdline = virt_to_phys ( image->cmdline );
236
+	cmdline = ( image->cmdline ? image->cmdline : "" );
237
+	mbinfo.cmdline = virt_to_phys ( cmdline );
233
 	mbinfo.mods_count = multiboot_build_module_list ( image, mbmodules,
238
 	mbinfo.mods_count = multiboot_build_module_list ( image, mbmodules,
234
 				( sizeof(mbmodules) / sizeof(mbmodules[0]) ) );
239
 				( sizeof(mbmodules) / sizeof(mbmodules[0]) ) );
235
 	mbinfo.mods_addr = virt_to_phys ( mbmodules );
240
 	mbinfo.mods_addr = virt_to_phys ( mbmodules );

+ 78
- 0
src/core/image.c View File

22
 #include <stdio.h>
22
 #include <stdio.h>
23
 #include <errno.h>
23
 #include <errno.h>
24
 #include <assert.h>
24
 #include <assert.h>
25
+#include <libgen.h>
25
 #include <gpxe/list.h>
26
 #include <gpxe/list.h>
26
 #include <gpxe/umalloc.h>
27
 #include <gpxe/umalloc.h>
28
+#include <gpxe/uri.h>
27
 #include <gpxe/image.h>
29
 #include <gpxe/image.h>
28
 
30
 
29
 /** @file
31
 /** @file
49
 static void free_image ( struct refcnt *refcnt ) {
51
 static void free_image ( struct refcnt *refcnt ) {
50
 	struct image *image = container_of ( refcnt, struct image, refcnt );
52
 	struct image *image = container_of ( refcnt, struct image, refcnt );
51
 
53
 
54
+	uri_put ( image->uri );
52
 	ufree ( image->data );
55
 	ufree ( image->data );
53
 	free ( image );
56
 	free ( image );
54
 	DBGC ( image, "IMAGE %p freed\n", image );
57
 	DBGC ( image, "IMAGE %p freed\n", image );
69
 	return image;
72
 	return image;
70
 }
73
 }
71
 
74
 
75
+/**
76
+ * Set image URI
77
+ *
78
+ * @v image		Image
79
+ * @v URI		New image URI
80
+ * @ret rc		Return status code
81
+ *
82
+ * If no name is set, the name will be updated to the base name of the
83
+ * URI path (if any).
84
+ */
85
+int image_set_uri ( struct image *image, struct uri *uri ) {
86
+	const char *path = uri->path;
87
+
88
+	/* Replace URI reference */
89
+	uri_put ( image->uri );
90
+	image->uri = uri_get ( uri );
91
+
92
+	/* Set name if none already specified */
93
+	if ( path && ( ! image->name[0] ) )
94
+		image_set_name ( image, basename ( ( char * ) path ) );
95
+
96
+	return 0;
97
+}
98
+
99
+/**
100
+ * Set image command line
101
+ *
102
+ * @v image		Image
103
+ * @v cmdline		New image command line
104
+ * @ret rc		Return status code
105
+ */
106
+int image_set_cmdline ( struct image *image, const char *cmdline ) {
107
+	free ( image->cmdline );
108
+	image->cmdline = strdup ( cmdline );
109
+	if ( ! image->cmdline )
110
+		return -ENOMEM;
111
+	return 0;
112
+}
113
+
72
 /**
114
 /**
73
  * Register executable/loadable image
115
  * Register executable/loadable image
74
  *
116
  *
220
 	/* Well, some formats might return... */
262
 	/* Well, some formats might return... */
221
 	return 0;
263
 	return 0;
222
 }
264
 }
265
+
266
+/**
267
+ * Register and autoload an image
268
+ *
269
+ * @v image		Image
270
+ * @ret rc		Return status code
271
+ */
272
+int register_and_autoload_image ( struct image *image ) {
273
+	int rc;
274
+
275
+	if ( ( rc = register_image ( image ) ) != 0 )
276
+		return rc;
277
+
278
+	if ( ( rc = image_autoload ( image ) ) != 0 )
279
+		return rc;
280
+
281
+	return 0;
282
+}
283
+
284
+/**
285
+ * Register and autoexec an image
286
+ *
287
+ * @v image		Image
288
+ * @ret rc		Return status code
289
+ */
290
+int register_and_autoexec_image ( struct image *image ) {
291
+	int rc;
292
+
293
+	if ( ( rc = register_and_autoload_image ( image ) ) != 0 )
294
+		return rc;
295
+
296
+	if ( ( rc = image_exec ( image ) ) != 0 )
297
+		return rc;
298
+
299
+	return 0;
300
+}

+ 59
- 24
src/hci/commands/image_cmd.c View File

33
  *
33
  *
34
  */
34
  */
35
 
35
 
36
-/**
37
- * Print image description
38
- *
39
- */
36
+enum image_action {
37
+	IMG_FETCH = 0,
38
+	IMG_LOAD,
39
+	IMG_EXEC,
40
+};
40
 
41
 
41
 /**
42
 /**
42
  * Fill in image command line
43
  * Fill in image command line
44
  * @v image		Image
45
  * @v image		Image
45
  * @v nargs		Argument count
46
  * @v nargs		Argument count
46
  * @v args		Argument list
47
  * @v args		Argument list
48
+ * @ret rc		Return status code
47
  */
49
  */
48
-static void imgfill_cmdline ( struct image *image, unsigned int nargs, 
49
-                              char **args ) {
50
+static int imgfill_cmdline ( struct image *image, unsigned int nargs, 
51
+			     char **args ) {
52
+	char buf[256];
50
 	size_t used = 0;
53
 	size_t used = 0;
51
 
54
 
52
-	image->cmdline[0] = '\0';
53
-	while ( ( used < sizeof ( image->cmdline ) ) && nargs-- ) {
54
-		used += snprintf ( &image->cmdline[used],
55
-				   ( sizeof ( image->cmdline ) - used ),
56
-				   "%s%s", ( used ? " " : "" ), *(args++) );
55
+	memset ( buf, 0, sizeof ( buf ) );
56
+	while ( ( used < sizeof ( buf ) ) && nargs-- ) {
57
+		used += snprintf ( &buf[used], ( sizeof ( buf ) - used ),
58
+				   " %s", *(args++) );
57
 	}
59
 	}
60
+
61
+	return image_set_cmdline ( image, &buf[1] );
58
 }
62
 }
59
 
63
 
60
 /**
64
 /**
62
  *
66
  *
63
  * @v argv		Argument list
67
  * @v argv		Argument list
64
  */
68
  */
65
-static void imgfetch_core_syntax ( char **argv, int load ) {
69
+static void imgfetch_core_syntax ( char **argv, enum image_action action ) {
70
+	static const char *actions[] = {
71
+		[IMG_FETCH]	= "Fetch",
72
+		[IMG_LOAD]	= "Fetch and load",
73
+		[IMG_EXEC]	= "Fetch and execute",
74
+	};
75
+
66
 	printf ( "Usage:\n"
76
 	printf ( "Usage:\n"
67
 		 "  %s [-n|--name <name>] filename [arguments...]\n"
77
 		 "  %s [-n|--name <name>] filename [arguments...]\n"
68
 		 "\n"
78
 		 "\n"
69
 		 "%s executable/loadable image\n",
79
 		 "%s executable/loadable image\n",
70
-		 argv[0], ( load ? "Fetch and load" : "Fetch" ) );
80
+		 argv[0], actions[action] );
71
 }
81
 }
72
 
82
 
73
 /**
83
 /**
79
  * @v argv		Argument list
89
  * @v argv		Argument list
80
  * @ret rc		Return status code
90
  * @ret rc		Return status code
81
  */
91
  */
82
-static int imgfetch_core_exec ( struct image_type *image_type, int load,
92
+static int imgfetch_core_exec ( struct image_type *image_type,
93
+				enum image_action action,
83
 				int argc, char **argv ) {
94
 				int argc, char **argv ) {
84
 	static struct option longopts[] = {
95
 	static struct option longopts[] = {
85
 		{ "help", 0, NULL, 'h' },
96
 		{ "help", 0, NULL, 'h' },
89
 	struct image *image;
100
 	struct image *image;
90
 	const char *name = NULL;
101
 	const char *name = NULL;
91
 	char *filename;
102
 	char *filename;
103
+	int ( * image_register ) ( struct image *image );
92
 	int c;
104
 	int c;
93
 	int rc;
105
 	int rc;
94
 
106
 
104
 			/* Display help text */
116
 			/* Display help text */
105
 		default:
117
 		default:
106
 			/* Unrecognised/invalid option */
118
 			/* Unrecognised/invalid option */
107
-			imgfetch_core_syntax ( argv, load );
119
+			imgfetch_core_syntax ( argv, action );
108
 			return -EINVAL;
120
 			return -EINVAL;
109
 		}
121
 		}
110
 	}
122
 	}
111
 
123
 
112
 	/* Need at least a filename remaining after the options */
124
 	/* Need at least a filename remaining after the options */
113
 	if ( optind == argc ) {
125
 	if ( optind == argc ) {
114
-		imgfetch_core_syntax ( argv, load );
126
+		imgfetch_core_syntax ( argv, action );
115
 		return -EINVAL;
127
 		return -EINVAL;
116
 	}
128
 	}
117
 	filename = argv[optind++];
129
 	filename = argv[optind++];
126
 	}
138
 	}
127
 
139
 
128
 	/* Fill in image name */
140
 	/* Fill in image name */
129
-	if ( name )
130
-		strncpy ( image->name, name, ( sizeof ( image->name ) - 1 ) );
141
+	if ( name ) {
142
+		if ( ( rc = image_set_name ( image, name ) ) != 0 )
143
+			return rc;
144
+	}
131
 
145
 
132
 	/* Set image type (if specified) */
146
 	/* Set image type (if specified) */
133
 	image->type = image_type;
147
 	image->type = image_type;
134
 
148
 
135
 	/* Fill in command line */
149
 	/* Fill in command line */
136
-	imgfill_cmdline ( image, ( argc - optind ), &argv[optind] );
150
+	if ( ( rc = imgfill_cmdline ( image, ( argc - optind ),
151
+				      &argv[optind] ) ) != 0 )
152
+		return rc;
137
 
153
 
138
 	/* Fetch the image */
154
 	/* Fetch the image */
139
-	if ( ( rc = imgfetch ( image, filename, load ) ) != 0 ) {
155
+	switch ( action ) {
156
+	case IMG_FETCH:
157
+		image_register = register_image;
158
+		break;
159
+	case IMG_LOAD:
160
+		image_register = register_and_autoload_image;
161
+		break;
162
+	case IMG_EXEC:
163
+		image_register = register_and_autoexec_image;
164
+		break;
165
+	default:
166
+		assert ( 0 );
167
+		return -EINVAL;
168
+	}
169
+	if ( ( rc = imgfetch ( image, filename, image_register ) ) != 0 ) {
140
 		printf ( "Could not fetch %s: %s\n", name, strerror ( rc ) );
170
 		printf ( "Could not fetch %s: %s\n", name, strerror ( rc ) );
141
 		image_put ( image );
171
 		image_put ( image );
142
 		return rc;
172
 		return rc;
156
 static int imgfetch_exec ( int argc, char **argv ) {
186
 static int imgfetch_exec ( int argc, char **argv ) {
157
 	int rc;
187
 	int rc;
158
 
188
 
159
-	if ( ( rc = imgfetch_core_exec ( NULL, 0, argc, argv ) ) != 0 )
189
+	if ( ( rc = imgfetch_core_exec ( NULL, IMG_FETCH,
190
+					 argc, argv ) ) != 0 )
160
 		return rc;
191
 		return rc;
161
 
192
 
162
 	return 0;
193
 	return 0;
172
 static int kernel_exec ( int argc, char **argv ) {
203
 static int kernel_exec ( int argc, char **argv ) {
173
 	int rc;
204
 	int rc;
174
 
205
 
175
-	if ( ( rc = imgfetch_core_exec ( NULL, 1, argc, argv ) ) != 0 )
206
+	if ( ( rc = imgfetch_core_exec ( NULL, IMG_LOAD, argc, argv ) ) != 0 )
176
 		return rc;
207
 		return rc;
177
 
208
 
178
 	return 0;
209
 	return 0;
188
 static int initrd_exec ( int argc, char **argv ) {
219
 static int initrd_exec ( int argc, char **argv ) {
189
 	int rc;
220
 	int rc;
190
 
221
 
191
-	if ( ( rc = imgfetch_core_exec ( &initrd_image_type, 0,
222
+	if ( ( rc = imgfetch_core_exec ( &initrd_image_type, IMG_FETCH,
192
 					 argc, argv ) ) != 0 )
223
 					 argc, argv ) ) != 0 )
193
 		return rc;
224
 		return rc;
194
 
225
 
286
 	struct image *image;
317
 	struct image *image;
287
 	const char *name;
318
 	const char *name;
288
 	int c;
319
 	int c;
320
+	int rc;
289
 
321
 
290
 	/* Parse options */
322
 	/* Parse options */
291
 	while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
323
 	while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
312
 		printf ( "No such image: %s\n", name );
344
 		printf ( "No such image: %s\n", name );
313
 		return 1;
345
 		return 1;
314
 	}
346
 	}
315
-	imgfill_cmdline ( image, ( argc - optind ), &argv[optind] );
347
+	if ( ( rc = imgfill_cmdline ( image, ( argc - optind ),
348
+				      &argv[optind] ) ) != 0 )
349
+		return rc;
350
+
316
 
351
 
317
 	return 0;
352
 	return 0;
318
 }
353
 }

+ 23
- 6
src/include/gpxe/image.h View File

13
 #include <gpxe/uaccess.h>
13
 #include <gpxe/uaccess.h>
14
 #include <gpxe/refcnt.h>
14
 #include <gpxe/refcnt.h>
15
 
15
 
16
+struct uri;
16
 struct image_type;
17
 struct image_type;
17
 
18
 
18
-/** Maximum length of a command line */
19
-#define CMDLINE_MAX 128
20
-
21
 /** An executable or loadable image */
19
 /** An executable or loadable image */
22
 struct image {
20
 struct image {
23
 	/** Reference count */
21
 	/** Reference count */
24
 	struct refcnt refcnt;
22
 	struct refcnt refcnt;
25
 
23
 
26
-	/** Name */
27
-	char name[16];
28
 	/** List of registered images */
24
 	/** List of registered images */
29
 	struct list_head list;
25
 	struct list_head list;
26
+
27
+	/** URI of image */
28
+	struct uri *uri;
29
+	/** Name */
30
+	char name[16];
30
 	/** Flags */
31
 	/** Flags */
31
 	unsigned int flags;
32
 	unsigned int flags;
32
 
33
 
33
 	/** Command line to pass to image */
34
 	/** Command line to pass to image */
34
-	char cmdline[CMDLINE_MAX];
35
+	char *cmdline;
35
 	/** Raw file image */
36
 	/** Raw file image */
36
 	userptr_t data;
37
 	userptr_t data;
37
 	/** Length of raw file image */
38
 	/** Length of raw file image */
114
 	list_for_each_entry ( (image), &images, list )
115
 	list_for_each_entry ( (image), &images, list )
115
 
116
 
116
 extern struct image * alloc_image ( void );
117
 extern struct image * alloc_image ( void );
118
+extern int image_set_uri ( struct image *image, struct uri *uri );
119
+extern int image_set_cmdline ( struct image *image, const char *cmdline );
117
 extern int register_image ( struct image *image );
120
 extern int register_image ( struct image *image );
118
 extern void unregister_image ( struct image *image );
121
 extern void unregister_image ( struct image *image );
119
 extern void promote_image ( struct image *image );
122
 extern void promote_image ( struct image *image );
121
 extern int image_load ( struct image *image );
124
 extern int image_load ( struct image *image );
122
 extern int image_autoload ( struct image *image );
125
 extern int image_autoload ( struct image *image );
123
 extern int image_exec ( struct image *image );
126
 extern int image_exec ( struct image *image );
127
+extern int register_and_autoload_image ( struct image *image );
128
+extern int register_and_autoexec_image ( struct image *image );
124
 
129
 
125
 /**
130
 /**
126
  * Increment reference count on an image
131
  * Increment reference count on an image
142
 	ref_put ( &image->refcnt );
147
 	ref_put ( &image->refcnt );
143
 }
148
 }
144
 
149
 
150
+/**
151
+ * Set image name
152
+ *
153
+ * @v image		Image
154
+ * @v name		New image name
155
+ * @ret rc		Return status code
156
+ */
157
+static inline int image_set_name ( struct image *image, const char *name ) {
158
+	strncpy ( image->name, name, ( sizeof ( image->name ) - 1 ) );
159
+	return 0;
160
+}
161
+
145
 #endif /* _GPXE_IMAGE_H */
162
 #endif /* _GPXE_IMAGE_H */

+ 2
- 2
src/include/gpxe/uri.h View File

94
  * @v uri			URI
94
  * @v uri			URI
95
  * @ret has_relative_path	URI has a relative path
95
  * @ret has_relative_path	URI has a relative path
96
  *
96
  *
97
- * An relative path begins with something other than a '/'.  Note that
97
+ * A relative path begins with something other than a '/'.  Note that
98
  * this is a separate concept from a relative URI.  Note also that a
98
  * this is a separate concept from a relative URI.  Note also that a
99
  * URI may not have a path at all.
99
  * URI may not have a path at all.
100
  */
100
  */
117
 /**
117
 /**
118
  * Decrement URI reference count
118
  * Decrement URI reference count
119
  *
119
  *
120
- * @v uri		URI
120
+ * @v uri		URI, or NULL
121
  */
121
  */
122
 static inline __attribute__ (( always_inline )) void
122
 static inline __attribute__ (( always_inline )) void
123
 uri_put ( struct uri *uri ) {
123
 uri_put ( struct uri *uri ) {

+ 2
- 1
src/include/usr/imgmgmt.h View File

9
 
9
 
10
 struct image;
10
 struct image;
11
 
11
 
12
-extern int imgfetch ( struct image *image, const char *filename, int load );
12
+extern int imgfetch ( struct image *image, const char *uri_string,
13
+		      int ( * image_register ) ( struct image *image ) );
13
 extern int imgload ( struct image *image );
14
 extern int imgload ( struct image *image );
14
 extern int imgexec ( struct image *image );
15
 extern int imgexec ( struct image *image );
15
 extern struct image * imgautoselect ( void );
16
 extern struct image * imgautoselect ( void );

+ 3
- 13
src/usr/autoboot.c View File

60
 		printf ( "Out of memory\n" );
60
 		printf ( "Out of memory\n" );
61
 		return -ENOMEM;
61
 		return -ENOMEM;
62
 	}
62
 	}
63
-	if ( ( rc = imgfetch ( image, filename, 0 ) ) != 0 ) {
63
+	if ( ( rc = imgfetch ( image, filename,
64
+			       register_and_autoexec_image ) ) != 0 ) {
64
 		printf ( "Could not retrieve %s: %s\n",
65
 		printf ( "Could not retrieve %s: %s\n",
65
 			 filename, strerror ( rc ) );
66
 			 filename, strerror ( rc ) );
66
 		image_put ( image );
67
 		image_put ( image );
67
 		return rc;
68
 		return rc;
68
 	}
69
 	}
69
-	if ( ( rc = imgload ( image ) ) != 0 ) {
70
-		printf ( "Could not load %s: %s\n", image->name,
71
-			 strerror ( rc ) );
72
-		image_put ( image );
73
-		return rc;
74
-	}
75
-	if ( ( rc = imgexec ( image ) ) != 0 ) {
76
-		printf ( "Could not execute %s: %s\n", image->name,
77
-			 strerror ( rc ) );
78
-		image_put ( image );
79
-		return rc;
80
-	}
81
 
70
 
71
+	image_put ( image );
82
 	return 0;
72
 	return 0;
83
 }
73
 }
84
 
74
 

+ 14
- 20
src/usr/imgmgmt.c View File

24
 #include <gpxe/downloader.h>
24
 #include <gpxe/downloader.h>
25
 #include <gpxe/monojob.h>
25
 #include <gpxe/monojob.h>
26
 #include <gpxe/open.h>
26
 #include <gpxe/open.h>
27
+#include <gpxe/uri.h>
27
 #include <usr/imgmgmt.h>
28
 #include <usr/imgmgmt.h>
28
 
29
 
29
 /** @file
30
 /** @file
32
  *
33
  *
33
  */
34
  */
34
 
35
 
35
-static int imgfetch_autoload ( struct image *image ) {
36
-	int rc;
37
-
38
-	if ( ( rc = register_image ( image ) ) != 0 )
39
-		return rc;
40
-
41
-	if ( ( rc = image_autoload ( image ) ) != 0 )
42
-		return rc;
43
-
44
-	return 0;
45
-}
46
-
47
 /**
36
 /**
48
  * Fetch an image
37
  * Fetch an image
49
  *
38
  *
50
  * @v uri_string	URI as a string (e.g. "http://www.nowhere.com/vmlinuz")
39
  * @v uri_string	URI as a string (e.g. "http://www.nowhere.com/vmlinuz")
51
  * @v name		Name for image, or NULL
40
  * @v name		Name for image, or NULL
52
- * @ret new_image	Newly created image
41
+ * @v register_image	Image registration routine
53
  * @ret rc		Return status code
42
  * @ret rc		Return status code
54
  */
43
  */
55
-int imgfetch ( struct image *image, const char *uri_string, int load ) {
44
+int imgfetch ( struct image *image, const char *uri_string,
45
+	       int ( * image_register ) ( struct image *image ) ) {
46
+	struct uri *uri;
56
 	int rc;
47
 	int rc;
57
 
48
 
58
-	if ( ( rc = create_downloader ( &monojob, image, 
59
-					( load ? imgfetch_autoload :
60
-					  register_image ),
61
-					LOCATION_URI_STRING,
62
-					uri_string ) ) == 0 )
49
+	if ( ! ( uri = parse_uri ( uri_string ) ) )
50
+		return -ENOMEM;
51
+
52
+	image_set_uri ( image, uri );
53
+
54
+	if ( ( rc = create_downloader ( &monojob, image, image_register,
55
+					LOCATION_URI, uri ) ) == 0 )
63
 		rc = monojob_wait();
56
 		rc = monojob_wait();
64
 
57
 
58
+	uri_put ( uri );
65
 	return rc;
59
 	return rc;
66
 }
60
 }
67
 
61
 
118
 		printf ( " [%s]", image->type->name );
112
 		printf ( " [%s]", image->type->name );
119
 	if ( image->flags & IMAGE_LOADED )
113
 	if ( image->flags & IMAGE_LOADED )
120
 		printf ( " [LOADED]" );
114
 		printf ( " [LOADED]" );
121
-	if ( image->cmdline[0] )
115
+	if ( image->cmdline )
122
 		printf ( " \"%s\"", image->cmdline );
116
 		printf ( " \"%s\"", image->cmdline );
123
 	printf ( "\n" );
117
 	printf ( "\n" );
124
 }
118
 }

Loading…
Cancel
Save