Browse Source

[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.
tags/v1.0.0-rc1
Michael Brown 15 years ago
parent
commit
5bee2a2991

+ 0
- 2
src/arch/i386/interface/pcbios/aoeboot.c View File

20
 	memset ( &ata, 0, sizeof ( ata ) );
20
 	memset ( &ata, 0, sizeof ( ata ) );
21
 	memset ( &drive, 0, sizeof ( drive ) );
21
 	memset ( &drive, 0, sizeof ( drive ) );
22
 
22
 
23
-	printf ( "AoE booting from %s\n", root_path );
24
-
25
 	/* FIXME: ugly, ugly hack */
23
 	/* FIXME: ugly, ugly hack */
26
 	struct net_device *netdev = last_opened_netdev();
24
 	struct net_device *netdev = last_opened_netdev();
27
 
25
 

+ 0
- 2
src/arch/i386/interface/pcbios/iscsiboot.c View File

27
 		goto err_alloc_drive;
27
 		goto err_alloc_drive;
28
 	}
28
 	}
29
 
29
 
30
-	printf ( "iSCSI booting from %s\n", root_path );
31
-
32
 	if ( ( rc = iscsi_attach ( scsi, root_path ) ) != 0 ) {
30
 	if ( ( rc = iscsi_attach ( scsi, root_path ) ) != 0 ) {
33
 		printf ( "Could not attach iSCSI device: %s\n",
31
 		printf ( "Could not attach iSCSI device: %s\n",
34
 			 strerror ( rc ) );
32
 			 strerror ( rc ) );

+ 16
- 14
src/usr/autoboot.c View File

67
 
67
 
68
 	/* Construct URI */
68
 	/* Construct URI */
69
 	uri = parse_uri ( filename );
69
 	uri = parse_uri ( filename );
70
-	if ( ! uri ) {
71
-		printf ( "Out of memory\n" );
70
+	if ( ! uri )
72
 		return -ENOMEM;
71
 		return -ENOMEM;
73
-	}
74
 	filename_is_absolute = uri_is_absolute ( uri );
72
 	filename_is_absolute = uri_is_absolute ( uri );
75
 	uri_put ( uri );
73
 	uri_put ( uri );
76
 	if ( ! filename_is_absolute ) {
74
 	if ( ! filename_is_absolute ) {
86
 	}
84
 	}
87
 
85
 
88
 	image = alloc_image();
86
 	image = alloc_image();
89
-	if ( ! image ) {
90
-		printf ( "Out of memory\n" );
87
+	if ( ! image )
91
 		return -ENOMEM;
88
 		return -ENOMEM;
92
-	}
93
 	if ( ( rc = imgfetch ( image, filename,
89
 	if ( ( rc = imgfetch ( image, filename,
94
 			       register_and_autoload_image ) ) != 0 ) {
90
 			       register_and_autoload_image ) ) != 0 ) {
95
-		printf ( "Could not load %s: %s\n",
96
-			 filename, strerror ( rc ) );
97
 		goto done;
91
 		goto done;
98
 	}
92
 	}
99
-	if ( ( rc = imgexec ( image ) ) != 0 ) {
100
-		printf ( "Could not boot %s: %s\n",
101
-			 filename, strerror ( rc ) );
93
+	if ( ( rc = imgexec ( image ) ) != 0 )
102
 		goto done;
94
 		goto done;
103
-	}
104
 
95
 
105
  done:
96
  done:
106
 	image_put ( image );
97
 	image_put ( image );
173
 	fetch_string_setting ( NULL, &filename_setting, buf, sizeof ( buf ) );
164
 	fetch_string_setting ( NULL, &filename_setting, buf, sizeof ( buf ) );
174
 	if ( buf[0] ) {
165
 	if ( buf[0] ) {
175
 		printf ( "Booting from filename \"%s\"\n", buf );
166
 		printf ( "Booting from filename \"%s\"\n", buf );
176
-		return boot_next_server_and_filename ( next_server, buf );
167
+		if ( ( rc = boot_next_server_and_filename ( next_server,
168
+							    buf ) ) != 0 ) {
169
+			printf ( "Could not boot from filename \"%s\": %s\n",
170
+				 buf, strerror ( rc ) );
171
+			return rc;
172
+		}
173
+		return 0;
177
 	}
174
 	}
178
 	
175
 	
179
 	/* No filename; try the root path */
176
 	/* No filename; try the root path */
180
 	fetch_string_setting ( NULL, &root_path_setting, buf, sizeof ( buf ) );
177
 	fetch_string_setting ( NULL, &root_path_setting, buf, sizeof ( buf ) );
181
 	if ( buf[0] ) {
178
 	if ( buf[0] ) {
182
 		printf ( "Booting from root path \"%s\"\n", buf );
179
 		printf ( "Booting from root path \"%s\"\n", buf );
183
-		return boot_root_path ( buf );
180
+		if ( ( rc = boot_root_path ( buf ) ) != 0 ) {
181
+			printf ( "Could not boot from root path \"%s\": %s\n",
182
+				 buf, strerror ( rc ) );
183
+			return rc;
184
+		}
185
+		return 0;
184
 	}
186
 	}
185
 
187
 
186
 	printf ( "No filename or root path specified\n" );
188
 	printf ( "No filename or root path specified\n" );

Loading…
Cancel
Save