diff options
| author | David Ng <dave@codeaurora.org> | 2012-01-04 12:15:11 -0800 |
|---|---|---|
| committer | Steve Kondik <shade@chemlab.org> | 2012-09-11 13:38:28 -0700 |
| commit | be5bb1d4aa98e066c44e5ee8a54a9bf92b17aa37 (patch) | |
| tree | 8ea2c997a8444c51bdb521485767c3003e2665e9 /init/builtins.c | |
| parent | 39948802fac7b6344c4dd5723fc7be2fcc4225ec (diff) | |
| download | system_core-be5bb1d4aa98e066c44e5ee8a54a9bf92b17aa37.tar.gz system_core-be5bb1d4aa98e066c44e5ee8a54a9bf92b17aa37.tar.bz2 system_core-be5bb1d4aa98e066c44e5ee8a54a9bf92b17aa37.zip | |
init: Add "export_rc" command to export env from a specified file
New export_rc command to import environment variables from
a specified file at the time the command is executed.
Differences between "import" and "export_rc":
1) export_rc can only import environment vars
2) export_rc is performed when the command
is executed rather than at the time the
command is parsed (i.e. "import")
Example:
in /init.rc:
on post-fs
export_rc /system/etc/init.xyz.rc
in /system/etc/init.xyz.rc:
export LD_PRELOAD /system/lib/libxyz.so
Change-Id: If616dea5b508c27e9f7a95b5e9db696ecea2fdee
Diffstat (limited to 'init/builtins.c')
| -rw-r--r-- | init/builtins.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/init/builtins.c b/init/builtins.c index 5dfa215e..0d87274f 100644 --- a/init/builtins.c +++ b/init/builtins.c @@ -15,6 +15,7 @@ */ #include <sys/types.h> +#include <sys/wait.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> @@ -54,6 +55,7 @@ void add_environment(const char *name, const char *value); extern int init_module(void *, unsigned long, const char *); +extern int init_export_rc_file(const char *); static int write_file(const char *path, const char *value) { @@ -221,6 +223,23 @@ int do_class_reset(int nargs, char **args) return 0; } +int do_export_rc(int nargs, char **args) +{ + /* Import environments from a specified file. + * The file content is of the form: + * export <env name> <value> + * e.g. + * export LD_PRELOAD /system/lib/xyz.so + * export PROMPT abcde + * Differences between "import" and "export_rc": + * 1) export_rc can only import environment vars + * 2) export_rc is performed when the command + * is executed rather than at the time the + * command is parsed (i.e. "import") + */ + return init_export_rc_file(args[1]); +} + int do_domainname(int nargs, char **args) { return write_file("/proc/sys/kernel/domainname", args[1]); |
