• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

修訂fe8a6e8e89a6708238bf4da60cad5ccd6c128f8c (tree)
時間2016-07-27 03:49:13
作者Andrew Boie <andrew.p.boie@inte...>
CommiterJaap Jan Meijer

Log Message

init: Add 'readprops' command

This reads the contents of a text file and sets system properties
based on its contents.

Change-Id: Ic03de7ee9afb8a12439d0dff343560011e152beb
For: AXIA-102
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>

Change Summary

差異

--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -675,6 +675,14 @@ int do_stop(int nargs, char **args)
675675 return 0;
676676 }
677677
678+int do_readprops(int nargs, char **args)
679+{
680+ if (nargs == 2) {
681+ return load_properties_from_file(args[1], NULL);
682+ }
683+ return -1;
684+}
685+
678686 int do_restart(int nargs, char **args)
679687 {
680688 struct service *svc;
--- a/init/init_parser.cpp
+++ b/init/init_parser.cpp
@@ -177,6 +177,7 @@ static int lookup_keyword(const char *s)
177177 if (!strcmp(s, "robemod")) return K_probemod;
178178 break;
179179 case 'r':
180+ if (!strcmp(s, "eadprops")) return K_readprops;
180181 if (!strcmp(s, "estart")) return K_restart;
181182 if (!strcmp(s, "estorecon")) return K_restorecon;
182183 if (!strcmp(s, "estorecon_recursive")) return K_restorecon_recursive;
--- a/init/keywords.h
+++ b/init/keywords.h
@@ -17,6 +17,7 @@ int do_mount_all(int nargs, char **args);
1717 int do_mount(int nargs, char **args);
1818 int do_powerctl(int nargs, char **args);
1919 int do_probemod(int nargs, char **args);
20+int do_readprops(int nargs, char **args);
2021 int do_restart(int nargs, char **args);
2122 int do_restorecon(int nargs, char **args);
2223 int do_restorecon_recursive(int nargs, char **args);
@@ -81,6 +82,7 @@ enum {
8182 KEYWORD(on, SECTION, 0, 0)
8283 KEYWORD(powerctl, COMMAND, 1, do_powerctl)
8384 KEYWORD(probemod, COMMAND, 1, do_probemod)
85+ KEYWORD(readprops, COMMAND, 1, do_readprops)
8486 KEYWORD(restart, COMMAND, 1, do_restart)
8587 KEYWORD(restorecon, COMMAND, 1, do_restorecon)
8688 KEYWORD(restorecon_recursive, COMMAND, 1, do_restorecon_recursive)
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -385,8 +385,6 @@ void get_property_workspace(int *fd, int *sz)
385385 *sz = pa_workspace.size;
386386 }
387387
388-static void load_properties_from_file(const char *, const char *);
389-
390388 /*
391389 * Filter is used to decide which properties to load: NULL loads all keys,
392390 * "ro.foo.*" is a prefix match, and "ro.foo.bar" is an exact match.
@@ -451,14 +449,18 @@ static void load_properties(char *data, const char *filter)
451449 * Filter is used to decide which properties to load: NULL loads all keys,
452450 * "ro.foo.*" is a prefix match, and "ro.foo.bar" is an exact match.
453451 */
454-static void load_properties_from_file(const char* filename, const char* filter) {
452+int load_properties_from_file(const char* filename, const char* filter) {
455453 Timer t;
456454 std::string data;
457455 if (read_file(filename, &data)) {
458456 data.push_back('\n');
459457 load_properties(&data[0], filter);
458+ } else {
459+ ERROR("Unable to read property file '%s'\n", filename);
460+ return -1;
460461 }
461462 NOTICE("(Loading properties from %s took %.2fs.)\n", filename, t.duration());
463+ return 0;
462464 }
463465
464466 static void load_persistent_properties() {
--- a/init/property_service.h
+++ b/init/property_service.h
@@ -22,6 +22,7 @@
2222
2323 extern void property_init(void);
2424 extern void property_load_boot_defaults(void);
25+extern int load_properties_from_file(const char *fn, const char *);
2526 extern void load_persist_props(void);
2627 extern void load_system_props(void);
2728 extern void start_property_service(void);
--- a/init/readme.txt
+++ b/init/readme.txt
@@ -238,6 +238,10 @@ powerctl
238238 restart <service>
239239 Like stop, but doesn't disable the service.
240240
241+readprops <path>
242+ Read and set system properties based on the contents of a text file
243+ at <path>
244+
241245 restorecon <path> [ <path> ]*
242246 Restore the file named by <path> to the security context specified
243247 in the file_contexts configuration.