summaryrefslogtreecommitdiff
path: root/libc/system_properties/system_properties.cpp
diff options
context:
space:
mode:
authorTom Cherry <tomcherry@google.com>2017-12-13 01:28:29 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-12-13 01:28:29 +0000
commite6e8f6ee77ac0be9b950ddd94f52ebcefe4433ce (patch)
treee9f19eaab6d54c42730a8fb3fe96a455ac008b11 /libc/system_properties/system_properties.cpp
parenteb7347aedbc61ba45555aef3e6e863f0d90b407b (diff)
parent79b724ca5a33e5dff7c2530b2649648021c1258d (diff)
Merge "Add support for serialized property contexts"
Diffstat (limited to 'libc/system_properties/system_properties.cpp')
-rw-r--r--libc/system_properties/system_properties.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/libc/system_properties/system_properties.cpp b/libc/system_properties/system_properties.cpp
index 89a6fe74d..f67fc4d4a 100644
--- a/libc/system_properties/system_properties.cpp
+++ b/libc/system_properties/system_properties.cpp
@@ -59,6 +59,7 @@
#include "context_node.h"
#include "contexts.h"
#include "contexts_pre_split.h"
+#include "contexts_serialized.h"
#include "contexts_split.h"
#include "prop_area.h"
#include "prop_info.h"
@@ -71,6 +72,7 @@
static union ContextsUnion {
ContextsUnion() {}
~ContextsUnion() {}
+ ContextsSerialized contexts_serialized;
ContextsSplit contexts_split;
ContextsPreSplit contexts_pre_split;
} contexts_union;
@@ -283,11 +285,19 @@ int __system_properties_init() {
}
contexts = nullptr;
if (is_dir(property_filename)) {
- new (&contexts_union.contexts_split) ContextsSplit();
- if (!contexts_union.contexts_split.Initialize(false)) {
- return -1;
+ if (access("/dev/__properties__/property_info", R_OK) == 0) {
+ new (&contexts_union.contexts_serialized) ContextsSerialized();
+ if (!contexts_union.contexts_serialized.Initialize(false)) {
+ return -1;
+ }
+ contexts = &contexts_union.contexts_serialized;
+ } else {
+ new (&contexts_union.contexts_split) ContextsSplit();
+ if (!contexts_union.contexts_split.Initialize(false)) {
+ return -1;
+ }
+ contexts = &contexts_union.contexts_split;
}
- contexts = &contexts_union.contexts_split;
} else {
new (&contexts_union.contexts_pre_split) ContextsPreSplit();
if (!contexts_union.contexts_pre_split.Initialize(false)) {
@@ -314,9 +324,9 @@ int __system_property_area_init() {
}
// We set this unconditionally as we want tests to continue on regardless of if this failed
// and property_service will abort on an error condition, so no harm done.
- new (&contexts_union.contexts_split) ContextsSplit;
- contexts = &contexts_union.contexts_split;
- if (!contexts_union.contexts_split.Initialize(true)) {
+ new (&contexts_union.contexts_serialized) ContextsSerialized;
+ contexts = &contexts_union.contexts_serialized;
+ if (!contexts_union.contexts_serialized.Initialize(true)) {
return -1;
}
return 0;