aboutsummaryrefslogtreecommitdiffstats
path: root/android/cmdline-option.c
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2009-05-25 18:01:03 +0200
committerDavid 'Digit' Turner <digit@google.com>2009-05-26 17:23:25 +0200
commit318e4f294c181df33cf2541763904565b29bcccb (patch)
tree35b5085c9e35e91967e2d4a4db80e28ec086e1d3 /android/cmdline-option.c
parent0d47fe5756b1f243e8d65968cd73c0119363f909 (diff)
downloadexternal_qemu-318e4f294c181df33cf2541763904565b29bcccb.zip
external_qemu-318e4f294c181df33cf2541763904565b29bcccb.tar.gz
external_qemu-318e4f294c181df33cf2541763904565b29bcccb.tar.bz2
This adds the '-prop <name>=<value>' option which is used to set
boot-time system properties from the command line. This is done by implementing a new 'boot-properties' qemud service in the emulator. This is to be used by the 'qemu-props' helper program that will be invoked by /system/etc/init.goldfish.rc to read a list of system properties from the emulator and set them in the emulated system during boot.
Diffstat (limited to 'android/cmdline-option.c')
-rw-r--r--android/cmdline-option.c61
1 files changed, 53 insertions, 8 deletions
diff --git a/android/cmdline-option.c b/android/cmdline-option.c
index b773d9d..fb5aa23 100644
--- a/android/cmdline-option.c
+++ b/android/cmdline-option.c
@@ -1,6 +1,7 @@
#include "android/cmdline-option.h"
#include "android/utils/debug.h"
#include "android/utils/misc.h"
+#include "android/utils/system.h"
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
@@ -15,11 +16,16 @@ debug_tags[] = {
static void parse_debug_tags( const char* tags );
void parse_env_debug_tags( void );
+enum {
+ OPTION_IS_FLAG = 0,
+ OPTION_IS_PARAM,
+ OPTION_IS_LIST,
+};
typedef struct {
const char* name;
int var_offset;
- int var_is_param;
+ int var_type;
int var_is_config;
} OptionInfo;
@@ -28,10 +34,11 @@ typedef struct {
static const OptionInfo option_keys[] = {
-#define OPT_PARAM(_name,_template,_descr) OPTION(_name,1,0)
-#define OPT_FLAG(_name,_descr) OPTION(_name,0,0)
-#define CFG_PARAM(_name,_template,_descr) OPTION(_name,1,1)
-#define CFG_FLAG(_name,_descr) OPTION(_name,0,1)
+#define OPT_FLAG(_name,_descr) OPTION(_name,OPTION_IS_FLAG,0)
+#define OPT_PARAM(_name,_template,_descr) OPTION(_name,OPTION_IS_PARAM,0)
+#define OPT_LIST(_name,_template,_descr) OPTION(_name,OPTION_IS_LIST,0)
+#define CFG_FLAG(_name,_descr) OPTION(_name,OPTION_IS_FLAG,1)
+#define CFG_PARAM(_name,_template,_descr) OPTION(_name,OPTION_IS_PARAM,1)
#include "android/cmdline-options.h"
{ NULL, 0, 0, 0 }
};
@@ -145,15 +152,31 @@ android_parse_options( int *pargc, char** *pargv, AndroidOptions* opt )
if ( !strcmp( oo->name, arg2 ) ) {
void* field = (char*)opt + oo->var_offset;
- if (oo->var_is_param) {
- /* parameter option */
+ if (oo->var_type != OPTION_IS_FLAG) {
+ /* parameter/list option */
if (nargs == 0) {
derror( "-%s must be followed by parameter (see -help-%s)",
arg, arg );
exit(1);
}
nargs--;
- ((char**)field)[0] = *aread++;
+
+ if (oo->var_type == OPTION_IS_PARAM)
+ {
+ ((char**)field)[0] = *aread++;
+ }
+ else if (oo->var_type == OPTION_IS_LIST)
+ {
+ ParamList** head = (ParamList**)field;
+ ParamList* pl;
+ ANEW0(pl);
+ /* note: store list items in reverse order here
+ * the list is reversed later in this function.
+ */
+ pl->param = *aread++;
+ pl->next = *head;
+ *head = pl;
+ }
} else {
/* flag option */
((int*)field)[0] = 1;
@@ -182,6 +205,28 @@ android_parse_options( int *pargc, char** *pargv, AndroidOptions* opt )
awrite[0] = NULL;
+ /* reverse any parameter list before exit.
+ */
+ {
+ const OptionInfo* oo = option_keys;
+
+ for ( ; oo->name; oo++ ) {
+ if ( oo->var_type == OPTION_IS_LIST ) {
+ ParamList** head = (ParamList**)((char*)opt + oo->var_offset);
+ ParamList* prev = NULL;
+ ParamList* cur = *head;
+
+ while (cur != NULL) {
+ ParamList* next = cur->next;
+ cur->next = prev;
+ prev = cur;
+ cur = next;
+ }
+ *head = prev;
+ }
+ }
+ }
+
return 0;
}