diff options
| author | Mike Lockwood <lockwood@android.com> | 2011-06-07 17:30:11 -0700 |
|---|---|---|
| committer | Mike Lockwood <lockwood@android.com> | 2011-06-09 15:42:31 -0700 |
| commit | 2c4d5dc41505d28cff369cfbe8b17ac81106d936 (patch) | |
| tree | c09b9037699e7d6eeb149f56b51474ca45a11d6a /init/builtins.c | |
| parent | b36f136738f6ed35c9686e1d42b57655eba9ce8d (diff) | |
| download | system_core-2c4d5dc41505d28cff369cfbe8b17ac81106d936.tar.gz system_core-2c4d5dc41505d28cff369cfbe8b17ac81106d936.tar.bz2 system_core-2c4d5dc41505d28cff369cfbe8b17ac81106d936.zip | |
init: Add support for writing system property value to a file in init.rc
The write command will write a property value if the value starts with a "$'
For example:
write /sys/class/android_usb/iSerial $ro.serialno
Use double leading '$' if you need to write a string that starts with '$':
write /data/foo $$hello
to write "$hello" to /data/foo
Change-Id: I55431ac7715a5347bb95c3a15aee97c575444dde
Diffstat (limited to 'init/builtins.c')
| -rw-r--r-- | init/builtins.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/init/builtins.c b/init/builtins.c index 23ef2245..dad75454 100644 --- a/init/builtins.c +++ b/init/builtins.c @@ -527,7 +527,23 @@ int do_sysclktz(int nargs, char **args) int do_write(int nargs, char **args) { - return write_file(args[1], args[2]); + char *path = args[1]; + char *value = args[2]; + if (value[0] == '$') { + /* Write 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 writing to %s\n", value, path); + return -EINVAL; + } + } /* else fall through to support double '$' prefix for writing + * string literals that start with '$' + */ + } + + return write_file(path, value); } int do_copy(int nargs, char **args) |
