소스 검색

[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
 ASFLAGS		+= $(EXTRA_ASFLAGS)
286
 ASFLAGS		+= $(EXTRA_ASFLAGS)
287
 LDFLAGS		+= $(EXTRA_LDFLAGS)
287
 LDFLAGS		+= $(EXTRA_LDFLAGS)
288
 
288
 
289
-# Embedded image(s), or default if not set
290
-#
291
-EMBEDDED_IMAGE	= image/default.gpxe
292
-
293
 # Inhibit -Werror if NO_WERROR is specified on make command line
289
 # Inhibit -Werror if NO_WERROR is specified on make command line
294
 #
290
 #
295
 ifneq ($(NO_WERROR),1)
291
 ifneq ($(NO_WERROR),1)

+ 10
- 6
src/core/main.c 파일 보기

71
 		shell();
71
 		shell();
72
 	} else {
72
 	} else {
73
 		/* User doesn't want shell; load and execute the first
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
 		if ( shell_banner() )
87
 		if ( shell_banner() )

+ 4
- 4
src/hci/commands/image_cmd.c 파일 보기

222
 }
222
 }
223
 
223
 
224
 /**
224
 /**
225
- * The "imgauto" command
225
+ * The "chain" command
226
  *
226
  *
227
  * @v argc		Argument count
227
  * @v argc		Argument count
228
  * @v argv		Argument list
228
  * @v argv		Argument list
229
  * @ret rc		Exit code
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
 	int rc;
232
 	int rc;
233
 
233
 
234
 	if ( ( rc = imgfetch_core_exec ( NULL, IMG_EXEC, argc, argv ) ) != 0 )
234
 	if ( ( rc = imgfetch_core_exec ( NULL, IMG_EXEC, argc, argv ) ) != 0 )
563
 		.exec = kernel_exec,
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
 		.name = "imgload",
570
 		.name = "imgload",

+ 0
- 2
src/image/default.gpxe 파일 보기

1
-#!gpxe
2
-autoboot

+ 9
- 4
src/image/embedded.c 파일 보기

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

+ 9
- 0
src/include/gpxe/image.h 파일 보기

133
 #define for_each_image( image ) \
133
 #define for_each_image( image ) \
134
 	list_for_each_entry ( (image), &images, list )
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
 extern struct image * alloc_image ( void );
145
 extern struct image * alloc_image ( void );
137
 extern int image_set_uri ( struct image *image, struct uri *uri );
146
 extern int image_set_uri ( struct image *image, struct uri *uri );
138
 extern int image_set_cmdline ( struct image *image, const char *cmdline );
147
 extern int image_set_cmdline ( struct image *image, const char *cmdline );

Loading…
취소
저장