소스 검색

[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 년 전
부모
커밋
5bee2a2991
3개의 변경된 파일16개의 추가작업 그리고 18개의 파일을 삭제
  1. 0
    2
      src/arch/i386/interface/pcbios/aoeboot.c
  2. 0
    2
      src/arch/i386/interface/pcbios/iscsiboot.c
  3. 16
    14
      src/usr/autoboot.c

+ 0
- 2
src/arch/i386/interface/pcbios/aoeboot.c 파일 보기

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

+ 0
- 2
src/arch/i386/interface/pcbios/iscsiboot.c 파일 보기

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

+ 16
- 14
src/usr/autoboot.c 파일 보기

@@ -67,10 +67,8 @@ int boot_next_server_and_filename ( struct in_addr next_server,
67 67
 
68 68
 	/* Construct URI */
69 69
 	uri = parse_uri ( filename );
70
-	if ( ! uri ) {
71
-		printf ( "Out of memory\n" );
70
+	if ( ! uri )
72 71
 		return -ENOMEM;
73
-	}
74 72
 	filename_is_absolute = uri_is_absolute ( uri );
75 73
 	uri_put ( uri );
76 74
 	if ( ! filename_is_absolute ) {
@@ -86,21 +84,14 @@ int boot_next_server_and_filename ( struct in_addr next_server,
86 84
 	}
87 85
 
88 86
 	image = alloc_image();
89
-	if ( ! image ) {
90
-		printf ( "Out of memory\n" );
87
+	if ( ! image )
91 88
 		return -ENOMEM;
92
-	}
93 89
 	if ( ( rc = imgfetch ( image, filename,
94 90
 			       register_and_autoload_image ) ) != 0 ) {
95
-		printf ( "Could not load %s: %s\n",
96
-			 filename, strerror ( rc ) );
97 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 94
 		goto done;
103
-	}
104 95
 
105 96
  done:
106 97
 	image_put ( image );
@@ -173,14 +164,25 @@ static int netboot ( struct net_device *netdev ) {
173 164
 	fetch_string_setting ( NULL, &filename_setting, buf, sizeof ( buf ) );
174 165
 	if ( buf[0] ) {
175 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 176
 	/* No filename; try the root path */
180 177
 	fetch_string_setting ( NULL, &root_path_setting, buf, sizeof ( buf ) );
181 178
 	if ( buf[0] ) {
182 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 188
 	printf ( "No filename or root path specified\n" );

Loading…
취소
저장