Merge "Rename functions in libvendorsupport" into main
diff --git a/init/Android.bp b/init/Android.bp
index 181de2e..2d16f60 100644
--- a/init/Android.bp
+++ b/init/Android.bp
@@ -88,7 +88,6 @@
init_host_sources = [
"check_builtins.cpp",
"host_import_parser.cpp",
- "host_init_verifier.cpp",
]
soong_config_module_type {
@@ -321,7 +320,6 @@
visibility: ["//packages/modules/Virtualization/microdroid"],
}
-
soong_config_module_type {
name: "init_first_stage_cc_defaults",
module_type: "cc_defaults",
@@ -614,13 +612,13 @@
cc_binary {
name: "host_init_verifier",
defaults: ["init_host_defaults"],
- srcs: init_common_sources + init_host_sources,
+ srcs: ["host_init_verifier.cpp"] + init_common_sources + init_host_sources,
}
cc_library_host_static {
name: "libinit_host",
defaults: ["init_host_defaults"],
- srcs: init_common_sources,
+ srcs: init_common_sources + init_host_sources,
export_include_dirs: ["."],
proto: {
export_proto_headers: true,
diff --git a/init/check_builtins.cpp b/init/check_builtins.cpp
index 461ed22..9725458 100644
--- a/init/check_builtins.cpp
+++ b/init/check_builtins.cpp
@@ -28,9 +28,9 @@
#include <android-base/parsedouble.h>
#include <android-base/parseint.h>
#include <android-base/strings.h>
+#include <property_info_parser/property_info_parser.h>
#include "builtin_arguments.h"
-#include "host_init_verifier.h"
#include "interface_utils.h"
#include "property_type.h"
#include "rlimit_parser.h"
@@ -39,6 +39,9 @@
using android::base::ParseInt;
using android::base::StartsWith;
+using android::properties::BuildTrie;
+using android::properties::PropertyInfoArea;
+using android::properties::PropertyInfoEntry;
#define ReturnIfAnyArgsEmpty() \
for (const auto& arg : args) { \
@@ -50,6 +53,26 @@
namespace android {
namespace init {
+const PropertyInfoArea* property_info_area;
+
+Result<void> InitializeHostPropertyInfoArea(const std::vector<PropertyInfoEntry>& property_infos) {
+ static std::string serialized_contexts;
+ std::string trie_error;
+ if (!BuildTrie(property_infos, "u:object_r:default_prop:s0", "string", &serialized_contexts,
+ &trie_error)) {
+ return Error() << "Unable to serialize property contexts: " << trie_error;
+ }
+
+ property_info_area = reinterpret_cast<const PropertyInfoArea*>(serialized_contexts.c_str());
+ return {};
+}
+
+static Result<void> check_stub(const BuiltinArguments& args) {
+ return {};
+}
+
+#include "generated_stub_builtin_function_map.h"
+
Result<void> check_chown(const BuiltinArguments& args) {
if (!args[1].empty()) {
auto uid = DecodeUid(args[1]);
diff --git a/init/check_builtins.h b/init/check_builtins.h
index dc1b752..9b00a7c 100644
--- a/init/check_builtins.h
+++ b/init/check_builtins.h
@@ -19,6 +19,10 @@
#include "builtin_arguments.h"
#include "result.h"
+#include <vector>
+
+#include <property_info_serializer/property_info_serializer.h>
+
namespace android {
namespace init {
@@ -43,5 +47,8 @@
Result<void> check_wait(const BuiltinArguments& args);
Result<void> check_wait_for_prop(const BuiltinArguments& args);
+Result<void> InitializeHostPropertyInfoArea(
+ const std::vector<properties::PropertyInfoEntry>& property_infos);
+
} // namespace init
} // namespace android
diff --git a/init/host_init_verifier.cpp b/init/host_init_verifier.cpp
index 662185c..f746ab9 100644
--- a/init/host_init_verifier.cpp
+++ b/init/host_init_verifier.cpp
@@ -14,8 +14,6 @@
// limitations under the License.
//
-#include "host_init_verifier.h"
-
#include <errno.h>
#include <getopt.h>
#include <pwd.h>
@@ -36,6 +34,7 @@
#include <android-base/strings.h>
#include <generated_android_ids.h>
#include <hidl/metadata.h>
+#include <property_info_parser/property_info_parser.h>
#include <property_info_serializer/property_info_serializer.h>
#include "action.h"
@@ -57,9 +56,7 @@
using android::base::ParseInt;
using android::base::ReadFileToString;
using android::base::Split;
-using android::properties::BuildTrie;
using android::properties::ParsePropertyInfoFile;
-using android::properties::PropertyInfoArea;
using android::properties::PropertyInfoEntry;
static std::vector<std::string> passwd_files;
@@ -148,12 +145,6 @@
namespace android {
namespace init {
-static Result<void> check_stub(const BuiltinArguments& args) {
- return {};
-}
-
-#include "generated_stub_builtin_function_map.h"
-
void PrintUsage() {
fprintf(stdout, R"(usage: host_init_verifier [options]
@@ -196,8 +187,6 @@
return result;
}
-const PropertyInfoArea* property_info_area;
-
void HandlePropertyContexts(const std::string& filename,
std::vector<PropertyInfoEntry>* property_infos) {
auto file_contents = std::string();
@@ -288,16 +277,11 @@
}
SetKnownInterfaces(*interface_inheritance_hierarchy_map);
- std::string serialized_contexts;
- std::string trie_error;
- if (!BuildTrie(property_infos, "u:object_r:default_prop:s0", "string", &serialized_contexts,
- &trie_error)) {
- LOG(ERROR) << "Unable to serialize property contexts: " << trie_error;
+ if (auto result = InitializeHostPropertyInfoArea(property_infos); !result.ok()) {
+ LOG(ERROR) << result.error();
return EXIT_FAILURE;
}
- property_info_area = reinterpret_cast<const PropertyInfoArea*>(serialized_contexts.c_str());
-
if (!partition_map.empty()) {
std::vector<std::string> vendor_prefixes;
for (const auto& partition : {"vendor", "odm"}) {
diff --git a/init/host_init_verifier.h b/init/host_init_verifier.h
deleted file mode 100644
index 5d24f2a..0000000
--- a/init/host_init_verifier.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <property_info_parser/property_info_parser.h>
-
-namespace android {
-namespace init {
-
-extern const android::properties::PropertyInfoArea* property_info_area;
-
-} // namespace init
-} // namespace android