ソースを参照

[image] Allow for zero embedded images

Having a default script containing

  #!gpxe
  autoboot

can cause problems when entering commands to load and start a kernel
manually; the default script image will still be present when the
kernel is started and so will be treated as an initrd.  It is possible
to work around this by typing "imgfree" before any other commands, but
this is counter-intuitive.

Fix by allowing the embedded image list to be empty (in which case we
just call autoboot()), and making this the default.

Reported by alkisg@gmail.com.
tags/v0.9.7
Michael Brown 15年前
コミット
4f3bab1a55
6個のファイルの変更32行の追加20行の削除
  1. 0
    4
      src/Makefile.housekeeping
  2. 10
    6
      src/core/main.c
  3. 4
    4
      src/hci/commands/image_cmd.c
  4. 0
    2
      src/image/default.gpxe
  5. 9
    4
      src/image/embedded.c
  6. 9
    0
      src/include/gpxe/image.h

+ 0
- 4
src/Makefile.housekeeping ファイルの表示

@@ -286,10 +286,6 @@ CFLAGS		+= $(EXTRA_CFLAGS)
286 286
 ASFLAGS		+= $(EXTRA_ASFLAGS)
287 287
 LDFLAGS		+= $(EXTRA_LDFLAGS)
288 288
 
289
-# Embedded image(s), or default if not set
290
-#
291
-EMBEDDED_IMAGE	= image/default.gpxe
292
-
293 289
 # Inhibit -Werror if NO_WERROR is specified on make command line
294 290
 #
295 291
 ifneq ($(NO_WERROR),1)

+ 10
- 6
src/core/main.c ファイルの表示

@@ -71,13 +71,17 @@ __asmcall int main ( void ) {
71 71
 		shell();
72 72
 	} else {
73 73
 		/* User doesn't want shell; load and execute the first
74
-		 * image.  If booting fails (i.e. if the image
75
-		 * returns, or fails to execute), offer a second
76
-		 * chance to enter the shell for diagnostics.
74
+		 * image, or autoboot() if we have no images.  If
75
+		 * booting fails for any reason, offer a second chance
76
+		 * to enter the shell for diagnostics.
77 77
 		 */
78
-		for_each_image ( image ) {
79
-			image_exec ( image );
80
-			break;
78
+		if ( have_images() ) {
79
+			for_each_image ( image ) {
80
+				image_exec ( image );
81
+				break;
82
+			}
83
+		} else {
84
+			autoboot();
81 85
 		}
82 86
 
83 87
 		if ( shell_banner() )

+ 4
- 4
src/hci/commands/image_cmd.c ファイルの表示

@@ -222,13 +222,13 @@ static int kernel_exec ( int argc, char **argv ) {
222 222
 }
223 223
 
224 224
 /**
225
- * The "imgauto" command
225
+ * The "chain" command
226 226
  *
227 227
  * @v argc		Argument count
228 228
  * @v argv		Argument list
229 229
  * @ret rc		Exit code
230 230
  */
231
-static int imgauto_exec ( int argc, char **argv) {
231
+static int chain_exec ( int argc, char **argv) {
232 232
 	int rc;
233 233
 
234 234
 	if ( ( rc = imgfetch_core_exec ( NULL, IMG_EXEC, argc, argv ) ) != 0 )
@@ -563,8 +563,8 @@ struct command image_commands[] __command = {
563 563
 		.exec = kernel_exec,
564 564
 	},
565 565
 	{
566
-		.name = "imgauto",
567
-		.exec = imgauto_exec,
566
+		.name = "chain",
567
+		.exec = chain_exec,
568 568
 	},
569 569
 	{
570 570
 		.name = "imgload",

+ 0
- 2
src/image/default.gpxe ファイルの表示

@@ -1,2 +0,0 @@
1
-#!gpxe
2
-autoboot

+ 9
- 4
src/image/embedded.c ファイルの表示

@@ -16,7 +16,8 @@
16 16
  *
17 17
  * @v refcnt		Reference counter
18 18
  */
19
-static void embedded_image_free ( struct refcnt *refcnt __unused ) {
19
+static void __attribute__ (( unused ))
20
+embedded_image_free ( struct refcnt *refcnt __unused ) {
20 21
 	/* Do nothing */
21 22
 }
22 23
 
@@ -51,14 +52,18 @@ static struct image embedded_images[] = {
51 52
  * Register all embedded images
52 53
  */
53 54
 static void embedded_init ( void ) {
54
-	unsigned int i;
55
+	int i;
55 56
 	struct image *image;
56 57
 	void *data;
57 58
 	int rc;
58 59
 
60
+	/* Skip if we have no embedded images */
61
+	if ( ! sizeof ( embedded_images ) )
62
+		return;
63
+
59 64
 	/* Fix up data pointers and register images */
60
-	for ( i = 0 ; i < ( sizeof ( embedded_images ) /
61
-			    sizeof ( embedded_images[0] ) ) ; i++ ) {
65
+	for ( i = 0 ; i < ( int ) ( sizeof ( embedded_images ) /
66
+				    sizeof ( embedded_images[0] ) ) ; i++ ) {
62 67
 		image = &embedded_images[i];
63 68
 
64 69
 		/* virt_to_user() cannot be used in a static

+ 9
- 0
src/include/gpxe/image.h ファイルの表示

@@ -133,6 +133,15 @@ extern struct list_head images;
133 133
 #define for_each_image( image ) \
134 134
 	list_for_each_entry ( (image), &images, list )
135 135
 
136
+/**
137
+ * Test for existence of images
138
+ *
139
+ * @ret existence	Some images exist
140
+ */
141
+static inline int have_images ( void ) {
142
+	return ( ! list_empty ( &images ) );
143
+}
144
+
136 145
 extern struct image * alloc_image ( void );
137 146
 extern int image_set_uri ( struct image *image, struct uri *uri );
138 147
 extern int image_set_cmdline ( struct image *image, const char *cmdline );

読み込み中…
キャンセル
保存