2017-05-10 02:11:57 +02:00
|
|
|
//
|
|
|
|
// Copyright (C) 2017 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.
|
|
|
|
//
|
|
|
|
|
|
|
|
cc_defaults {
|
|
|
|
name: "init_defaults",
|
|
|
|
cpp_std: "experimental",
|
|
|
|
sanitize: {
|
2017-07-26 23:17:09 +02:00
|
|
|
misc_undefined: ["signed-integer-overflow"],
|
2017-05-10 02:11:57 +02:00
|
|
|
},
|
2017-10-03 00:20:07 +02:00
|
|
|
cflags: [
|
2017-05-10 02:11:57 +02:00
|
|
|
"-DLOG_UEVENTS=0",
|
|
|
|
"-Wall",
|
|
|
|
"-Wextra",
|
|
|
|
"-Wno-unused-parameter",
|
|
|
|
"-Werror",
|
|
|
|
"-DALLOW_LOCAL_PROP_OVERRIDE=0",
|
|
|
|
"-DALLOW_PERMISSIVE_SELINUX=0",
|
|
|
|
"-DREBOOT_BOOTLOADER_ON_PANIC=0",
|
|
|
|
"-DWORLD_WRITABLE_KMSG=0",
|
|
|
|
"-DDUMP_ON_UMOUNT_FAILURE=0",
|
|
|
|
"-DSHUTDOWN_ZERO_TIMEOUT=0",
|
|
|
|
],
|
|
|
|
product_variables: {
|
|
|
|
debuggable: {
|
|
|
|
cppflags: [
|
|
|
|
"-UALLOW_LOCAL_PROP_OVERRIDE",
|
|
|
|
"-DALLOW_LOCAL_PROP_OVERRIDE=1",
|
|
|
|
"-UALLOW_PERMISSIVE_SELINUX",
|
|
|
|
"-DALLOW_PERMISSIVE_SELINUX=1",
|
|
|
|
"-UREBOOT_BOOTLOADER_ON_PANIC",
|
|
|
|
"-DREBOOT_BOOTLOADER_ON_PANIC=1",
|
|
|
|
"-UWORLD_WRITABLE_KMSG",
|
|
|
|
"-DWORLD_WRITABLE_KMSG=1",
|
|
|
|
"-UDUMP_ON_UMOUNT_FAILURE",
|
|
|
|
"-DDUMP_ON_UMOUNT_FAILURE=1",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
eng: {
|
|
|
|
cppflags: [
|
|
|
|
"-USHUTDOWN_ZERO_TIMEOUT",
|
|
|
|
"-DSHUTDOWN_ZERO_TIMEOUT=1",
|
|
|
|
],
|
|
|
|
},
|
2017-08-23 23:57:07 +02:00
|
|
|
uml: {
|
|
|
|
cppflags: ["-DUSER_MODE_LINUX"],
|
2018-02-17 02:58:14 +01:00
|
|
|
},
|
2017-05-10 02:11:57 +02:00
|
|
|
},
|
2018-01-19 23:25:48 +01:00
|
|
|
static_libs: [
|
|
|
|
"libseccomp_policy",
|
|
|
|
"libprocessgroup",
|
|
|
|
"libavb",
|
|
|
|
"libprotobuf-cpp-lite",
|
|
|
|
"libpropertyinfoserializer",
|
|
|
|
"libpropertyinfoparser",
|
2018-06-01 12:26:42 +02:00
|
|
|
],
|
|
|
|
shared_libs: [
|
|
|
|
"libbase",
|
2018-09-04 06:29:14 +02:00
|
|
|
"libbinder",
|
2018-07-26 07:35:45 +02:00
|
|
|
"libbootloader_message",
|
|
|
|
"libcutils",
|
2018-11-15 17:43:48 +01:00
|
|
|
"libcrypto",
|
2018-06-01 12:26:42 +02:00
|
|
|
"libdl",
|
2018-07-26 07:35:45 +02:00
|
|
|
"libext4_utils",
|
|
|
|
"libfs_mgr",
|
2018-10-23 22:10:33 +02:00
|
|
|
"libfscrypt",
|
2019-01-04 03:16:56 +01:00
|
|
|
"libgsi",
|
2018-07-26 07:35:45 +02:00
|
|
|
"libhidl-gen-utils",
|
|
|
|
"libkeyutils",
|
|
|
|
"liblog",
|
|
|
|
"liblogwrap",
|
2018-11-06 23:12:05 +01:00
|
|
|
"liblp",
|
2018-06-19 09:55:05 +02:00
|
|
|
"libselinux",
|
2018-09-04 06:29:14 +02:00
|
|
|
"libutils",
|
2018-01-19 23:25:48 +01:00
|
|
|
],
|
2018-12-26 09:34:39 +01:00
|
|
|
bootstrap: true,
|
2017-05-10 02:11:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_static {
|
|
|
|
name: "libinit",
|
2018-07-20 23:57:00 +02:00
|
|
|
recovery_available: true,
|
2017-05-10 02:11:57 +02:00
|
|
|
defaults: ["init_defaults"],
|
|
|
|
srcs: [
|
|
|
|
"action.cpp",
|
2018-02-14 00:36:14 +01:00
|
|
|
"action_manager.cpp",
|
2018-02-14 00:25:29 +01:00
|
|
|
"action_parser.cpp",
|
2018-11-15 17:43:48 +01:00
|
|
|
"boringssl_self_test.cpp",
|
2018-01-19 23:25:48 +01:00
|
|
|
"bootchart.cpp",
|
|
|
|
"builtins.cpp",
|
2017-05-10 02:11:57 +02:00
|
|
|
"capabilities.cpp",
|
|
|
|
"descriptors.cpp",
|
|
|
|
"devices.cpp",
|
2015-10-25 01:20:18 +02:00
|
|
|
"epoll.cpp",
|
2017-05-26 00:58:59 +02:00
|
|
|
"firmware_handler.cpp",
|
2018-11-06 23:12:05 +01:00
|
|
|
"first_stage_init.cpp",
|
2018-07-21 00:18:04 +02:00
|
|
|
"first_stage_mount.cpp",
|
2017-05-10 02:11:57 +02:00
|
|
|
"import_parser.cpp",
|
2018-01-19 23:25:48 +01:00
|
|
|
"init.cpp",
|
|
|
|
"keychords.cpp",
|
2018-07-09 20:12:00 +02:00
|
|
|
"modalias_handler.cpp",
|
Proper mount namespace configuration for bionic
This CL fixes the design problem of the previous mechanism for providing
the bootstrap bionic and the runtime bionic to the same path.
Previously, bootstrap bionic was self-bind-mounted; i.e.
/system/bin/libc.so is bind-mounted to itself. And the runtime bionic
was bind-mounted on top of the bootstrap bionic. This has not only caused
problems like `adb sync` not working(b/122737045), but also is quite
difficult to understand due to the double-and-self mounting.
This is the new design:
Most importantly, these four are all distinct:
1) bootstrap bionic (/system/lib/bootstrap/libc.so)
2) runtime bionic (/apex/com.android.runtime/lib/bionic/libc.so)
3) mount point for 1) and 2) (/bionic/lib/libc.so)
4) symlink for 3) (/system/lib/libc.so -> /bionic/lib/libc.so)
Inside the mount namespace of the pre-apexd processes, 1) is
bind-mounted to 3). Likewise, inside the mount namespace of the
post-apexd processes, 2) is bind-mounted to 3). In other words, there is
no self-mount, and no double-mount.
Another change is that mount points are under /bionic and the legacy
paths become symlinks to the mount points. This is to make sure that
there is no bind mounts under /system, which is breaking some apps.
Finally, code for creating mount namespaces, mounting bionic, etc are
refactored to mount_namespace.cpp
Bug: 120266448
Bug: 123275379
Test: m, device boots, adb sync/push/pull works,
especially with following paths:
/bionic/lib64/libc.so
/bionic/bin/linker64
/system/lib64/bootstrap/libc.so
/system/bin/bootstrap/linker64
Change-Id: Icdfbdcc1efca540ac854d4df79e07ee61fca559f
2019-01-16 15:00:59 +01:00
|
|
|
"mount_namespace.cpp",
|
2017-05-10 02:11:57 +02:00
|
|
|
"parser.cpp",
|
2017-08-05 00:59:03 +02:00
|
|
|
"persistent_properties.cpp",
|
2017-09-16 00:44:04 +02:00
|
|
|
"persistent_properties.proto",
|
2017-08-10 02:13:21 +02:00
|
|
|
"property_service.cpp",
|
2017-12-11 10:40:07 +01:00
|
|
|
"property_type.cpp",
|
2018-01-19 23:25:48 +01:00
|
|
|
"reboot.cpp",
|
2018-08-03 22:36:18 +02:00
|
|
|
"reboot_utils.cpp",
|
2017-08-10 21:22:44 +02:00
|
|
|
"security.cpp",
|
|
|
|
"selinux.cpp",
|
2017-05-10 02:11:57 +02:00
|
|
|
"service.cpp",
|
2018-01-19 23:25:48 +01:00
|
|
|
"sigchld_handler.cpp",
|
2017-09-13 00:58:47 +02:00
|
|
|
"subcontext.cpp",
|
|
|
|
"subcontext.proto",
|
2018-11-06 23:12:05 +01:00
|
|
|
"switch_root.cpp",
|
2017-08-25 19:39:25 +02:00
|
|
|
"rlimit_parser.cpp",
|
2017-07-27 21:54:48 +02:00
|
|
|
"tokenizer.cpp",
|
2017-05-26 00:58:59 +02:00
|
|
|
"uevent_listener.cpp",
|
2018-01-19 23:25:48 +01:00
|
|
|
"ueventd.cpp",
|
2017-05-26 00:58:59 +02:00
|
|
|
"ueventd_parser.cpp",
|
2017-05-10 02:11:57 +02:00
|
|
|
"util.cpp",
|
|
|
|
],
|
|
|
|
whole_static_libs: ["libcap"],
|
2018-03-29 03:45:35 +02:00
|
|
|
header_libs: ["bootimg_headers"],
|
2017-09-16 00:44:04 +02:00
|
|
|
proto: {
|
|
|
|
type: "lite",
|
|
|
|
export_proto_headers: true,
|
|
|
|
},
|
2018-09-04 06:29:14 +02:00
|
|
|
|
|
|
|
target: {
|
|
|
|
recovery: {
|
|
|
|
cflags: ["-DRECOVERY"],
|
|
|
|
exclude_shared_libs: ["libbinder", "libutils"],
|
|
|
|
},
|
|
|
|
},
|
2017-05-10 02:11:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_binary {
|
2018-07-20 23:57:00 +02:00
|
|
|
name: "init_second_stage",
|
|
|
|
recovery_available: true,
|
|
|
|
stem: "init",
|
2017-05-10 02:11:57 +02:00
|
|
|
defaults: ["init_defaults"],
|
2018-07-20 23:57:00 +02:00
|
|
|
static_libs: ["libinit"],
|
2017-07-06 20:43:45 +02:00
|
|
|
required: [
|
|
|
|
"e2fsdroid",
|
|
|
|
"mke2fs",
|
2017-11-29 04:26:34 +01:00
|
|
|
"sload_f2fs",
|
|
|
|
"make_f2fs",
|
2017-07-06 20:43:45 +02:00
|
|
|
],
|
2018-01-19 23:25:48 +01:00
|
|
|
srcs: ["main.cpp"],
|
2018-07-20 23:57:00 +02:00
|
|
|
symlinks: ["ueventd"],
|
2018-09-04 06:29:14 +02:00
|
|
|
target: {
|
|
|
|
recovery: {
|
|
|
|
cflags: ["-DRECOVERY"],
|
|
|
|
exclude_shared_libs: ["libbinder", "libutils"],
|
|
|
|
},
|
|
|
|
},
|
Proper mount namespace configuration for bionic
This CL fixes the design problem of the previous mechanism for providing
the bootstrap bionic and the runtime bionic to the same path.
Previously, bootstrap bionic was self-bind-mounted; i.e.
/system/bin/libc.so is bind-mounted to itself. And the runtime bionic
was bind-mounted on top of the bootstrap bionic. This has not only caused
problems like `adb sync` not working(b/122737045), but also is quite
difficult to understand due to the double-and-self mounting.
This is the new design:
Most importantly, these four are all distinct:
1) bootstrap bionic (/system/lib/bootstrap/libc.so)
2) runtime bionic (/apex/com.android.runtime/lib/bionic/libc.so)
3) mount point for 1) and 2) (/bionic/lib/libc.so)
4) symlink for 3) (/system/lib/libc.so -> /bionic/lib/libc.so)
Inside the mount namespace of the pre-apexd processes, 1) is
bind-mounted to 3). Likewise, inside the mount namespace of the
post-apexd processes, 2) is bind-mounted to 3). In other words, there is
no self-mount, and no double-mount.
Another change is that mount points are under /bionic and the legacy
paths become symlinks to the mount points. This is to make sure that
there is no bind mounts under /system, which is breaking some apps.
Finally, code for creating mount namespaces, mounting bionic, etc are
refactored to mount_namespace.cpp
Bug: 120266448
Bug: 123275379
Test: m, device boots, adb sync/push/pull works,
especially with following paths:
/bionic/lib64/libc.so
/bionic/bin/linker64
/system/lib64/bootstrap/libc.so
/system/bin/bootstrap/linker64
Change-Id: Icdfbdcc1efca540ac854d4df79e07ee61fca559f
2019-01-16 15:00:59 +01:00
|
|
|
ldflags: ["-Wl,--rpath,/system/${LIB}/bootstrap"],
|
2017-05-10 02:11:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Tests
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
cc_test {
|
|
|
|
name: "init_tests",
|
|
|
|
defaults: ["init_defaults"],
|
2018-08-24 18:40:04 +02:00
|
|
|
compile_multilib: "first",
|
2017-05-10 02:11:57 +02:00
|
|
|
srcs: [
|
|
|
|
"devices_test.cpp",
|
|
|
|
"init_test.cpp",
|
2018-05-15 20:19:43 +02:00
|
|
|
"keychords_test.cpp",
|
2017-08-05 00:59:03 +02:00
|
|
|
"persistent_properties_test.cpp",
|
2017-05-10 02:11:57 +02:00
|
|
|
"property_service_test.cpp",
|
2017-12-11 10:40:07 +01:00
|
|
|
"property_type_test.cpp",
|
2017-08-03 21:54:07 +02:00
|
|
|
"result_test.cpp",
|
2017-08-25 19:39:25 +02:00
|
|
|
"rlimit_parser_test.cpp",
|
2017-05-10 02:11:57 +02:00
|
|
|
"service_test.cpp",
|
2017-09-13 00:58:47 +02:00
|
|
|
"subcontext_test.cpp",
|
2018-06-26 22:56:34 +02:00
|
|
|
"tokenizer_test.cpp",
|
2018-07-18 00:28:16 +02:00
|
|
|
"ueventd_parser_test.cpp",
|
2017-07-15 01:29:23 +02:00
|
|
|
"ueventd_test.cpp",
|
2017-05-10 02:11:57 +02:00
|
|
|
"util_test.cpp",
|
|
|
|
],
|
2018-01-19 23:25:48 +01:00
|
|
|
static_libs: ["libinit"],
|
2018-04-28 01:12:06 +02:00
|
|
|
test_suites: ["device-tests"],
|
2017-05-10 02:11:57 +02:00
|
|
|
}
|
|
|
|
|
2017-09-13 00:58:47 +02:00
|
|
|
cc_benchmark {
|
|
|
|
name: "init_benchmarks",
|
|
|
|
defaults: ["init_defaults"],
|
|
|
|
srcs: [
|
|
|
|
"subcontext_benchmark.cpp",
|
|
|
|
],
|
2018-01-19 23:25:48 +01:00
|
|
|
static_libs: ["libinit"],
|
2017-09-13 00:58:47 +02:00
|
|
|
}
|
|
|
|
|
2018-02-14 01:50:08 +01:00
|
|
|
// Host Verifier
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
genrule {
|
|
|
|
name: "generated_stub_builtin_function_map",
|
|
|
|
out: ["generated_stub_builtin_function_map.h"],
|
|
|
|
srcs: ["builtins.cpp"],
|
2018-03-01 06:40:46 +01:00
|
|
|
cmd: "sed -n '/Builtin-function-map start/{:a;n;/Builtin-function-map end/q;p;ba}' $(in) | sed -e 's/do_[^}]*/do_stub/g' > $(out)",
|
2018-02-14 01:50:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_binary {
|
|
|
|
name: "host_init_verifier",
|
|
|
|
host_supported: true,
|
|
|
|
cpp_std: "experimental",
|
|
|
|
cflags: [
|
|
|
|
"-Wall",
|
|
|
|
"-Wextra",
|
|
|
|
"-Wno-unused-parameter",
|
|
|
|
"-Werror",
|
|
|
|
],
|
|
|
|
static_libs: [
|
|
|
|
"libbase",
|
|
|
|
"libselinux",
|
|
|
|
],
|
|
|
|
whole_static_libs: ["libcap"],
|
|
|
|
shared_libs: [
|
|
|
|
"libprotobuf-cpp-lite",
|
|
|
|
"libhidl-gen-utils",
|
|
|
|
"libprocessgroup",
|
|
|
|
"liblog",
|
|
|
|
"libcutils",
|
|
|
|
],
|
2018-06-21 00:49:48 +02:00
|
|
|
srcs: [
|
|
|
|
"action.cpp",
|
|
|
|
"action_manager.cpp",
|
|
|
|
"action_parser.cpp",
|
|
|
|
"capabilities.cpp",
|
|
|
|
"descriptors.cpp",
|
|
|
|
"epoll.cpp",
|
|
|
|
"keychords.cpp",
|
|
|
|
"import_parser.cpp",
|
|
|
|
"host_import_parser.cpp",
|
|
|
|
"host_init_verifier.cpp",
|
|
|
|
"host_init_stubs.cpp",
|
|
|
|
"parser.cpp",
|
|
|
|
"rlimit_parser.cpp",
|
|
|
|
"tokenizer.cpp",
|
|
|
|
"service.cpp",
|
|
|
|
"subcontext.cpp",
|
|
|
|
"subcontext.proto",
|
|
|
|
"util.cpp",
|
|
|
|
],
|
2018-02-14 01:50:08 +01:00
|
|
|
proto: {
|
|
|
|
type: "lite",
|
|
|
|
},
|
2018-06-21 00:49:48 +02:00
|
|
|
generated_headers: [
|
|
|
|
"generated_stub_builtin_function_map",
|
|
|
|
"generated_android_ids"
|
|
|
|
],
|
2018-03-01 02:20:27 +01:00
|
|
|
target: {
|
2018-03-01 06:40:46 +01:00
|
|
|
android: {
|
|
|
|
enabled: false,
|
|
|
|
},
|
2018-03-01 02:20:27 +01:00
|
|
|
darwin: {
|
2018-06-21 00:49:48 +02:00
|
|
|
enabled: false,
|
2018-03-01 02:20:27 +01:00
|
|
|
},
|
|
|
|
},
|
2018-02-14 01:50:08 +01:00
|
|
|
}
|
|
|
|
|
2017-05-10 02:11:57 +02:00
|
|
|
subdirs = ["*"]
|