summaryrefslogtreecommitdiffstats
path: root/src/usr/imgmgmt.c
diff options
context:
space:
mode:
authorMichael Brown2011-01-27 19:48:47 +0100
committerMichael Brown2011-01-27 21:41:27 +0100
commite088892a81e428aa4982b1c97001a1196d91acb7 (patch)
tree252e2ca31404c299be9808869f3b6e8ec96114bf /src/usr/imgmgmt.c
parent[init] Remove concept of "shutdown exit flags" (diff)
downloadipxe-e088892a81e428aa4982b1c97001a1196d91acb7.tar.gz
ipxe-e088892a81e428aa4982b1c97001a1196d91acb7.tar.xz
ipxe-e088892a81e428aa4982b1c97001a1196d91acb7.zip
[autoboot] Connect SAN disk during a filename boot, if applicable
For performing installations direct to a SAN target, it can be very useful to hook a SAN disk and then proceed to perform a filename boot. For example, the user may wish to hook the (empty) SAN installation disk and then boot into the OS installer via TFTP. This provides an alternative mechanism to using "keep-san" and relying on the BIOS to fall through to boot from the installation media, which is unreliable on many BIOSes. When a root-path is specified in addition to a boot filename, attempt to hook the root-path as a SAN disk before booting from the specified filename. Since the root-path may be used for non-SAN purposes (e.g. an NFS root mount point), ignore the root-path if it contains a URI scheme that we do not support. Originally-implemented-by: Jarrod Johnson <jarrod.b.johnson@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/usr/imgmgmt.c')
-rw-r--r--src/usr/imgmgmt.c51
1 files changed, 37 insertions, 14 deletions
diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c
index 5e7629a6..e958bc19 100644
--- a/src/usr/imgmgmt.c
+++ b/src/usr/imgmgmt.c
@@ -36,24 +36,21 @@ FILE_LICENCE ( GPL2_OR_LATER );
*/
/**
- * Fetch an image
+ * Download an image
*
- * @v uri_string URI as a string (e.g. "http://www.nowhere.com/vmlinuz")
- * @v name Name for image, or NULL
- * @v register_image Image registration routine
+ * @v image Image
+ * @v uri URI
+ * @v image_register Action to take upon a successful download
* @ret rc Return status code
*/
-int imgfetch ( struct image *image, const char *uri_string,
- int ( * image_register ) ( struct image *image ) ) {
- char uri_string_redacted[ strlen ( uri_string ) + 3 /* "***" */
- + 1 /* NUL */ ];
- struct uri *uri;
+int imgdownload ( struct image *image, struct uri *uri,
+ int ( * image_register ) ( struct image *image ) ) {
+ size_t len = ( unparse_uri ( NULL, 0, uri, URI_ALL ) + 1 );
+ char uri_string_redacted[len];
const char *password;
int rc;
- if ( ! ( uri = parse_uri ( uri_string ) ) )
- return -ENOMEM;
-
+ /* Set image URI */
image_set_uri ( image, uri );
/* Redact password portion of URI, if necessary */
@@ -64,9 +61,35 @@ int imgfetch ( struct image *image, const char *uri_string,
uri, URI_ALL );
uri->password = password;
+ /* Create downloader */
if ( ( rc = create_downloader ( &monojob, image, image_register,
- LOCATION_URI, uri ) ) == 0 )
- rc = monojob_wait ( uri_string_redacted );
+ LOCATION_URI, uri ) ) != 0 )
+ return rc;
+
+ /* Wait for download to complete */
+ if ( ( rc = monojob_wait ( uri_string_redacted ) ) != 0 )
+ return rc;
+
+ return 0;
+}
+
+/**
+ * Fetch an image
+ *
+ * @v image Image
+ * @v uri_string URI as a string (e.g. "http://www.nowhere.com/vmlinuz")
+ * @v image_register Action to take upon a successful fetch
+ * @ret rc Return status code
+ */
+int imgfetch ( struct image *image, const char *uri_string,
+ int ( * image_register ) ( struct image *image ) ) {
+ struct uri *uri;
+ int rc;
+
+ if ( ! ( uri = parse_uri ( uri_string ) ) )
+ return -ENOMEM;
+
+ rc = imgdownload ( image, uri, image_register );
uri_put ( uri );
return rc;