From 1f0bd32f90161940d531040677099f32eef21fc4 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Wed, 8 Jun 2011 17:31:27 -0700 Subject: [PATCH] init: Add support for assigning system properties to system properties in init.rc For example: setprop sys.usb.config $persist.sys.usb.config Change-Id: I7b4e1ed1335906b32621bd96a341b0f94bbee7f5 Signed-off-by: Mike Lockwood --- init/builtins.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/init/builtins.c b/init/builtins.c index f43b04850..bfdd65402 100644 --- a/init/builtins.c +++ b/init/builtins.c @@ -440,7 +440,24 @@ int do_setkey(int nargs, char **args) int do_setprop(int nargs, char **args) { - property_set(args[1], args[2]); + const char *name = args[1]; + const char *value = args[2]; + + if (value[0] == '$') { + /* Use the value of a system property if value starts with '$' */ + value++; + if (value[0] != '$') { + value = property_get(value); + if (!value) { + ERROR("property %s has no value for assigning to %s\n", value, name); + return -EINVAL; + } + } /* else fall through to support double '$' prefix for setting properties + * to string literals that start with '$' + */ + } + + property_set(name, value); return 0; } @@ -522,8 +539,8 @@ int do_sysclktz(int nargs, char **args) int do_write(int nargs, char **args) { - char *path = args[1]; - char *value = args[2]; + const char *path = args[1]; + const char *value = args[2]; if (value[0] == '$') { /* Write the value of a system property if value starts with '$' */ value++;