[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.
This commit is contained in:
Michael Brown
2009-11-17 03:46:45 +00:00
parent f406edefae
commit 5bee2a2991
3 changed files with 16 additions and 18 deletions

View File

@@ -20,8 +20,6 @@ static int aoeboot ( const char *root_path ) {
memset ( &ata, 0, sizeof ( ata ) ); memset ( &ata, 0, sizeof ( ata ) );
memset ( &drive, 0, sizeof ( drive ) ); memset ( &drive, 0, sizeof ( drive ) );
printf ( "AoE booting from %s\n", root_path );
/* FIXME: ugly, ugly hack */ /* FIXME: ugly, ugly hack */
struct net_device *netdev = last_opened_netdev(); struct net_device *netdev = last_opened_netdev();

View File

@@ -27,8 +27,6 @@ static int iscsiboot ( const char *root_path ) {
goto err_alloc_drive; goto err_alloc_drive;
} }
printf ( "iSCSI booting from %s\n", root_path );
if ( ( rc = iscsi_attach ( scsi, root_path ) ) != 0 ) { if ( ( rc = iscsi_attach ( scsi, root_path ) ) != 0 ) {
printf ( "Could not attach iSCSI device: %s\n", printf ( "Could not attach iSCSI device: %s\n",
strerror ( rc ) ); strerror ( rc ) );

View File

@@ -67,10 +67,8 @@ int boot_next_server_and_filename ( struct in_addr next_server,
/* Construct URI */ /* Construct URI */
uri = parse_uri ( filename ); uri = parse_uri ( filename );
if ( ! uri ) { if ( ! uri )
printf ( "Out of memory\n" );
return -ENOMEM; return -ENOMEM;
}
filename_is_absolute = uri_is_absolute ( uri ); filename_is_absolute = uri_is_absolute ( uri );
uri_put ( uri ); uri_put ( uri );
if ( ! filename_is_absolute ) { if ( ! filename_is_absolute ) {
@@ -86,21 +84,14 @@ int boot_next_server_and_filename ( struct in_addr next_server,
} }
image = alloc_image(); image = alloc_image();
if ( ! image ) { if ( ! image )
printf ( "Out of memory\n" );
return -ENOMEM; return -ENOMEM;
}
if ( ( rc = imgfetch ( image, filename, if ( ( rc = imgfetch ( image, filename,
register_and_autoload_image ) ) != 0 ) { register_and_autoload_image ) ) != 0 ) {
printf ( "Could not load %s: %s\n",
filename, strerror ( rc ) );
goto done; goto done;
} }
if ( ( rc = imgexec ( image ) ) != 0 ) { if ( ( rc = imgexec ( image ) ) != 0 )
printf ( "Could not boot %s: %s\n",
filename, strerror ( rc ) );
goto done; goto done;
}
done: done:
image_put ( image ); image_put ( image );
@@ -173,14 +164,25 @@ static int netboot ( struct net_device *netdev ) {
fetch_string_setting ( NULL, &filename_setting, buf, sizeof ( buf ) ); fetch_string_setting ( NULL, &filename_setting, buf, sizeof ( buf ) );
if ( buf[0] ) { if ( buf[0] ) {
printf ( "Booting from filename \"%s\"\n", buf ); 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 */ /* No filename; try the root path */
fetch_string_setting ( NULL, &root_path_setting, buf, sizeof ( buf ) ); fetch_string_setting ( NULL, &root_path_setting, buf, sizeof ( buf ) );
if ( buf[0] ) { if ( buf[0] ) {
printf ( "Booting from root path \"%s\"\n", buf ); 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" ); printf ( "No filename or root path specified\n" );