summaryrefslogtreecommitdiffstats
path: root/src/usr/autoboot.c
diff options
context:
space:
mode:
authorMichael Brown2009-11-17 04:46:45 +0100
committerMichael Brown2009-11-18 03:44:40 +0100
commit5bee2a2991207e3b16930e0a58fb0aa0881ae486 (patch)
tree6491ce5ff446a7e9f4d5641fe4664c898a4382f6 /src/usr/autoboot.c
parent[linda] Re-import the latest register definitions (diff)
downloadipxe-5bee2a2991207e3b16930e0a58fb0aa0881ae486.tar.gz
ipxe-5bee2a2991207e3b16930e0a58fb0aa0881ae486.tar.xz
ipxe-5bee2a2991207e3b16930e0a58fb0aa0881ae486.zip
[autoboot] Ensure that an error message is always printed for a boot failure
The case of an unsupported SAN protocol will currently not result in any error message. Fix by printing the error message at the top level using strerror(), rather than using hard-coded error messages in the error paths.
Diffstat (limited to 'src/usr/autoboot.c')
-rw-r--r--src/usr/autoboot.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c
index 70b7e925..b9c1fdaa 100644
--- a/src/usr/autoboot.c
+++ b/src/usr/autoboot.c
@@ -67,10 +67,8 @@ int boot_next_server_and_filename ( struct in_addr next_server,
/* Construct URI */
uri = parse_uri ( filename );
- if ( ! uri ) {
- printf ( "Out of memory\n" );
+ if ( ! uri )
return -ENOMEM;
- }
filename_is_absolute = uri_is_absolute ( uri );
uri_put ( uri );
if ( ! filename_is_absolute ) {
@@ -86,21 +84,14 @@ int boot_next_server_and_filename ( struct in_addr next_server,
}
image = alloc_image();
- if ( ! image ) {
- printf ( "Out of memory\n" );
+ if ( ! image )
return -ENOMEM;
- }
if ( ( rc = imgfetch ( image, filename,
register_and_autoload_image ) ) != 0 ) {
- printf ( "Could not load %s: %s\n",
- filename, strerror ( rc ) );
goto done;
}
- if ( ( rc = imgexec ( image ) ) != 0 ) {
- printf ( "Could not boot %s: %s\n",
- filename, strerror ( rc ) );
+ if ( ( rc = imgexec ( image ) ) != 0 )
goto done;
- }
done:
image_put ( image );
@@ -173,14 +164,25 @@ static int netboot ( struct net_device *netdev ) {
fetch_string_setting ( NULL, &filename_setting, buf, sizeof ( buf ) );
if ( buf[0] ) {
printf ( "Booting from filename \"%s\"\n", buf );
- return boot_next_server_and_filename ( next_server, buf );
+ if ( ( rc = boot_next_server_and_filename ( next_server,
+ buf ) ) != 0 ) {
+ printf ( "Could not boot from filename \"%s\": %s\n",
+ buf, strerror ( rc ) );
+ return rc;
+ }
+ return 0;
}
/* No filename; try the root path */
fetch_string_setting ( NULL, &root_path_setting, buf, sizeof ( buf ) );
if ( buf[0] ) {
printf ( "Booting from root path \"%s\"\n", buf );
- return boot_root_path ( buf );
+ if ( ( rc = boot_root_path ( buf ) ) != 0 ) {
+ printf ( "Could not boot from root path \"%s\": %s\n",
+ buf, strerror ( rc ) );
+ return rc;
+ }
+ return 0;
}
printf ( "No filename or root path specified\n" );