|
|
@@ -34,13 +34,18 @@
|
|
34
|
34
|
#include <gpxe/dhcp.h>
|
|
35
|
35
|
|
|
36
|
36
|
/**
|
|
37
|
|
- * Fetch file as executable/loadable image
|
|
|
37
|
+ * Fetch file
|
|
38
|
38
|
*
|
|
39
|
|
- * @v image Executable/loadable image
|
|
40
|
|
- * @v filename Filename
|
|
|
39
|
+ * @v filename Filename to fetch
|
|
|
40
|
+ * @ret data Loaded file
|
|
|
41
|
+ * @ret len Length of loaded file
|
|
41
|
42
|
* @ret rc Return status code
|
|
|
43
|
+ *
|
|
|
44
|
+ * Fetch file to an external buffer allocated with emalloc(). The
|
|
|
45
|
+ * caller is responsible for eventually freeing the buffer with
|
|
|
46
|
+ * efree().
|
|
42
|
47
|
*/
|
|
43
|
|
-int fetch ( struct image *image, const char *filename ) {
|
|
|
48
|
+int fetch ( const char *filename, userptr_t *data, size_t *len ) {
|
|
44
|
49
|
struct buffer buffer;
|
|
45
|
50
|
int rc;
|
|
46
|
51
|
|
|
|
@@ -69,10 +74,9 @@ int fetch ( struct image *image, const char *filename ) {
|
|
69
|
74
|
return rc;
|
|
70
|
75
|
}
|
|
71
|
76
|
|
|
72
|
|
- /* Transfer ownserhip of the data buffer to the image */
|
|
73
|
|
- image->data = buffer.addr;
|
|
74
|
|
- image->len = buffer.fill;
|
|
75
|
|
- image->free = efree;
|
|
|
77
|
+ /* Fill in buffer address and length */
|
|
|
78
|
+ *data = buffer.addr;
|
|
|
79
|
+ *len = buffer.fill;
|
|
76
|
80
|
|
|
77
|
81
|
return 0;
|
|
78
|
82
|
}
|