diff options
author | Sami Tolvanen <samitolvanen@google.com> | 2015-03-19 10:00:34 +0000 |
---|---|---|
committer | Sami Tolvanen <samitolvanen@google.com> | 2015-03-19 10:11:17 +0000 |
commit | acbf9bef43bc650ed84ba891183ebdf689dafb64 (patch) | |
tree | c09a6fee40c660e73d11090b8d79573047ca162a /init | |
parent | b054582b90de67a5839345b3a39ad683329f1453 (diff) | |
download | system_core-acbf9bef43bc650ed84ba891183ebdf689dafb64.zip system_core-acbf9bef43bc650ed84ba891183ebdf689dafb64.tar.gz system_core-acbf9bef43bc650ed84ba891183ebdf689dafb64.tar.bz2 |
Add init command to set verified properties
Add a command that updates dm-verity state and sets partition.%.verified
properties used by adb remount.
This is needed in init since fs_mgr cannot set properties:
I6a28cccb1ccce960841af20a4b20c32d424b5524
Change-Id: I0fdf5bc29c56690dcadff9d0eb216d3c68483538
Diffstat (limited to 'init')
-rw-r--r-- | init/builtins.cpp | 24 | ||||
-rw-r--r-- | init/init_parser.cpp | 1 | ||||
-rw-r--r-- | init/keywords.h | 2 |
3 files changed, 27 insertions, 0 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp index fb1aa7c..01217c1 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -687,6 +687,30 @@ int do_verity_load_state(int nargs, char **args) { return -1; } +static void verity_update_property(struct fstab_rec *fstab, + const char *mount_point, int status) { + char key[PROP_NAME_MAX]; + int ret; + + ret = snprintf(key, PROP_NAME_MAX, "partition.%s.verified", mount_point); + if (ret >= PROP_NAME_MAX) { + ERROR("Error setting verified property for %s: name too long\n", + mount_point); + return; + } + + ret = property_set(key, "1"); + if (ret < 0) + ERROR("Error setting verified property %s: %d\n", key, ret); +} + +int do_verity_update_state(int nargs, char **args) { + if (nargs == 1) { + return fs_mgr_update_verity_state(verity_update_property); + } + return -1; +} + int do_write(int nargs, char **args) { const char *path = args[1]; diff --git a/init/init_parser.cpp b/init/init_parser.cpp index f3d34b2..7db203f 100644 --- a/init/init_parser.cpp +++ b/init/init_parser.cpp @@ -202,6 +202,7 @@ static int lookup_keyword(const char *s) break; case 'v': if (!strcmp(s, "erity_load_state")) return K_verity_load_state; + if (!strcmp(s, "erity_update_state")) return K_verity_update_state; break; case 'w': if (!strcmp(s, "rite")) return K_write; diff --git a/init/keywords.h b/init/keywords.h index c8327c3..09f645b 100644 --- a/init/keywords.h +++ b/init/keywords.h @@ -37,6 +37,7 @@ int do_loglevel(int nargs, char **args); int do_load_persist_props(int nargs, char **args); int do_load_all_props(int nargs, char **args); int do_verity_load_state(int nargs, char **args); +int do_verity_update_state(int nargs, char **args); int do_wait(int nargs, char **args); #define __MAKE_KEYWORD_ENUM__ #define KEYWORD(symbol, flags, nargs, func) K_##symbol, @@ -89,6 +90,7 @@ enum { KEYWORD(sysclktz, COMMAND, 1, do_sysclktz) KEYWORD(user, OPTION, 0, 0) KEYWORD(verity_load_state, COMMAND, 0, do_verity_load_state) + KEYWORD(verity_update_state, COMMAND, 0, do_verity_update_state) KEYWORD(wait, COMMAND, 1, do_wait) KEYWORD(write, COMMAND, 2, do_write) KEYWORD(copy, COMMAND, 2, do_copy) |