diff options
author | Mike Lockwood <lockwood@android.com> | 2011-06-08 17:31:27 -0700 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2011-06-09 15:42:54 -0700 |
commit | 1f0bd32f90161940d531040677099f32eef21fc4 (patch) | |
tree | 4b21232a7ce5d3391a8e1b5ad43877e1d75cf9b9 /init | |
parent | f5cb5b24356fae2dfa3477589ee0f3c094479e63 (diff) | |
download | system_core-1f0bd32f90161940d531040677099f32eef21fc4.tar.gz system_core-1f0bd32f90161940d531040677099f32eef21fc4.tar.bz2 system_core-1f0bd32f90161940d531040677099f32eef21fc4.zip |
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 <lockwood@android.com>
Diffstat (limited to 'init')
-rw-r--r-- | init/builtins.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/init/builtins.c b/init/builtins.c index f43b0485..bfdd6540 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++; |