Bläddra i källkod

Scripts temporarily deregister themselves while executing. This

allows us to avoid execution loops without having to hack around the
image registration order.
tags/v0.9.3
Michael Brown 17 år sedan
förälder
incheckning
b256900d4f
3 ändrade filer med 18 tillägg och 18 borttagningar
  1. 0
    14
      src/core/image.c
  2. 16
    3
      src/image/script.c
  3. 2
    1
      src/usr/imgmgmt.c

+ 0
- 14
src/core/image.c Visa fil

106
 	DBGC ( image, "IMAGE %p unregistered\n", image );
106
 	DBGC ( image, "IMAGE %p unregistered\n", image );
107
 }
107
 }
108
 
108
 
109
-/**
110
- * Move image to start of list of registered images
111
- *
112
- * @v image		Executable/loadable image
113
- *
114
- * Move the image to the start of the image list.  This makes it
115
- * easier to keep track of which of the images marked as loaded is
116
- * likely to still be valid.
117
- */
118
-void promote_image ( struct image *image ) {
119
-	list_del ( &image->list );
120
-	list_add ( &image->list, &images );
121
-}
122
-
123
 /**
109
 /**
124
  * Find image by name
110
  * Find image by name
125
  *
111
  *

+ 16
- 3
src/image/script.c Visa fil

44
 	char *eol;
44
 	char *eol;
45
 	int rc;
45
 	int rc;
46
 
46
 
47
+	/* Temporarily de-register image, so that a "boot" command
48
+	 * doesn't throw us into an execution loop.  Hold a reference
49
+	 * to avoid the image's being freed.
50
+	 */
51
+	image_get ( image );
52
+	unregister_image ( image );
53
+
47
 	while ( offset < image->len ) {
54
 	while ( offset < image->len ) {
48
 	
55
 	
49
 		/* Read up to cmdbuf bytes from script into buffer */
56
 		/* Read up to cmdbuf bytes from script into buffer */
60
 		if ( ! eol ) {
67
 		if ( ! eol ) {
61
 			DBG ( "Script line too long (max %d bytes)\n",
68
 			DBG ( "Script line too long (max %d bytes)\n",
62
 			      sizeof ( cmdbuf ) );
69
 			      sizeof ( cmdbuf ) );
63
-			return -ENOEXEC;
70
+			rc = -ENOEXEC;
71
+			goto done;
64
 		}
72
 		}
65
 
73
 
66
 		/* Mark end of line and execute command */
74
 		/* Mark end of line and execute command */
69
 		if ( ( rc = system ( cmdbuf ) ) != 0 ) {
77
 		if ( ( rc = system ( cmdbuf ) ) != 0 ) {
70
 			DBG ( "Command \"%s\" exited with status %d\n",
78
 			DBG ( "Command \"%s\" exited with status %d\n",
71
 			      cmdbuf, rc );
79
 			      cmdbuf, rc );
72
-			return rc;
80
+			goto done;
73
 		}
81
 		}
74
 		
82
 		
75
 		/* Move to next line */
83
 		/* Move to next line */
76
 		offset += ( ( eol - cmdbuf ) + 1 );
84
 		offset += ( ( eol - cmdbuf ) + 1 );
77
 	}
85
 	}
78
 
86
 
79
-	return 0;
87
+	rc = 0;
88
+ done:
89
+	/* Re-register image and return */
90
+	register_image ( image );
91
+	image_put ( image );
92
+	return rc;
80
 }
93
 }
81
 
94
 
82
 /**
95
 /**

+ 2
- 1
src/usr/imgmgmt.c Visa fil

89
 		return rc;
89
 		return rc;
90
 
90
 
91
 	/* If we succeed, move the image to the start of the list */
91
 	/* If we succeed, move the image to the start of the list */
92
-	promote_image ( image );
92
+#warning "No longer exists"
93
+	//	promote_image ( image );
93
 
94
 
94
 	return 0;
95
 	return 0;
95
 }
96
 }

Laddar…
Avbryt
Spara