Merge "Revert "fix 'adb shell'"" am: 0117aabea0
am: 243d810fea
Change-Id: I26aeb80cad7a20bf8c4ed09222bcd8b0a2799d88
diff --git a/init/Android.bp b/init/Android.bp
index d939fcc..6ee9132 100644
--- a/init/Android.bp
+++ b/init/Android.bp
@@ -185,9 +185,11 @@
static_libs: ["libinit"],
required: [
"e2fsdroid",
+ "init.rc",
"mke2fs",
"sload_f2fs",
"make_f2fs",
+ "ueventd.rc",
],
srcs: ["main.cpp"],
symlinks: ["ueventd"],
diff --git a/init/init.cpp b/init/init.cpp
index 6ea2d00..ff86f8d 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -136,7 +136,7 @@
std::string bootscript = GetProperty("ro.boot.init_rc", "");
if (bootscript.empty()) {
- parser.ParseConfig("/init.rc");
+ parser.ParseConfig("/system/etc/init/hw/init.rc");
if (!parser.ParseConfig("/system/etc/init")) {
late_import_paths.emplace_back("/system/etc/init");
}
diff --git a/init/ueventd.cpp b/init/ueventd.cpp
index 59f91ee..d2b503b 100644
--- a/init/ueventd.cpp
+++ b/init/ueventd.cpp
@@ -288,7 +288,7 @@
// TODO: cleanup platform ueventd.rc to remove vendor specific device node entries (b/34968103)
auto hardware = android::base::GetProperty("ro.hardware", "");
- auto ueventd_configuration = ParseConfig({"/ueventd.rc", "/vendor/ueventd.rc",
+ auto ueventd_configuration = ParseConfig({"/system/etc/ueventd.rc", "/vendor/ueventd.rc",
"/odm/ueventd.rc", "/ueventd." + hardware + ".rc"});
uevent_handlers.emplace_back(std::make_unique<DeviceHandler>(
diff --git a/libutils/include/utils/Flattenable.h b/libutils/include/utils/Flattenable.h
index 953b859..17c5e10 100644
--- a/libutils/include/utils/Flattenable.h
+++ b/libutils/include/utils/Flattenable.h
@@ -52,7 +52,12 @@
template<size_t N>
static size_t align(void*& buffer) {
- return align<N>( const_cast<void const*&>(buffer) );
+ static_assert(!(N & (N - 1)), "Can only align to a power of 2.");
+ void* b = buffer;
+ buffer = reinterpret_cast<void*>((uintptr_t(buffer) + (N-1)) & ~(N-1));
+ size_t delta = size_t(uintptr_t(buffer) - uintptr_t(b));
+ memset(b, 0, delta);
+ return delta;
}
static void advance(void*& buffer, size_t& size, size_t offset) {
diff --git a/rootdir/Android.bp b/rootdir/Android.bp
new file mode 100644
index 0000000..96b5e0d
--- /dev/null
+++ b/rootdir/Android.bp
@@ -0,0 +1,26 @@
+// Copyright 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.
+
+prebuilt_etc {
+ name: "init.rc",
+ src: "init.rc",
+ sub_dir: "init/hw",
+ required: ["fsverity_init"],
+}
+
+prebuilt_etc {
+ name: "ueventd.rc",
+ src: "ueventd.rc",
+ recovery_available: true,
+}
diff --git a/rootdir/Android.mk b/rootdir/Android.mk
index 19f117f..994d9ae 100644
--- a/rootdir/Android.mk
+++ b/rootdir/Android.mk
@@ -1,22 +1,6 @@
LOCAL_PATH:= $(call my-dir)
#######################################
-# init.rc
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := init.rc
-LOCAL_SRC_FILES := $(LOCAL_MODULE)
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
-LOCAL_REQUIRED_MODULES := fsverity_init
-
-# The init symlink must be a post install command of a file that is to TARGET_ROOT_OUT.
-# Since init.rc is required for init and satisfies that requirement, we hijack it to create the symlink.
-LOCAL_POST_INSTALL_CMD := ln -sf /system/bin/init $(TARGET_ROOT_OUT)/init
-
-include $(BUILD_PREBUILT)
-
-#######################################
# init-debug.rc
include $(CLEAR_VARS)
@@ -148,6 +132,10 @@
LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/postinstall
endif
+# The init symlink must be a post install command of a file that is to TARGET_ROOT_OUT.
+# Since init.environ.rc is required for init and satisfies that requirement, we hijack it to create the symlink.
+LOCAL_POST_INSTALL_CMD += ; ln -sf /system/bin/init $(TARGET_ROOT_OUT)/init
+
include $(BUILD_SYSTEM)/base_rules.mk
$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/init.environ.rc.in
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 0827247..bc18e27 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -5,11 +5,11 @@
#
import /init.environ.rc
-import /init.usb.rc
+import /system/etc/init/hw/init.usb.rc
import /init.${ro.hardware}.rc
import /vendor/etc/init/hw/init.${ro.hardware}.rc
-import /init.usb.configfs.rc
-import /init.${ro.zygote}.rc
+import /system/etc/init/hw/init.usb.configfs.rc
+import /system/etc/init/hw/init.${ro.zygote}.rc
# Cgroups are mounted right before early-init using list from /etc/cgroups.json
on early-init