support android-16.0.0_r2
This commit is contained in:
147
android-16.0.0_r2/system/core/0001-fix-booting.patch
Normal file
147
android-16.0.0_r2/system/core/0001-fix-booting.patch
Normal file
@@ -0,0 +1,147 @@
|
||||
From a74c433d22faa74ec7d16fd7b7f5cdbcbc4aaef8 Mon Sep 17 00:00:00 2001
|
||||
From: Ziyang Zhou <ziyang.zhou@outlook.com>
|
||||
Date: Sun, 9 May 2021 23:09:00 +0800
|
||||
Subject: [PATCH 1/7] fix booting
|
||||
|
||||
---
|
||||
fs_mgr/libfstab/boot_config.cpp | 6 ++++--
|
||||
init/first_stage_init.cpp | 18 +++++++++++++++---
|
||||
init/init.cpp | 0
|
||||
init/property_service.cpp | 0
|
||||
init/service.cpp | 1 +
|
||||
libcutils/ashmem-dev.cpp | 2 +-
|
||||
rootdir/init.rc | 2 +-
|
||||
7 files changed, 22 insertions(+), 7 deletions(-)
|
||||
mode change 100644 => 100755 init/init.cpp
|
||||
mode change 100644 => 100755 init/property_service.cpp
|
||||
|
||||
diff --git a/fs_mgr/libfstab/boot_config.cpp b/fs_mgr/libfstab/boot_config.cpp
|
||||
index b21495e..7993d15 100644
|
||||
--- a/fs_mgr/libfstab/boot_config.cpp
|
||||
+++ b/fs_mgr/libfstab/boot_config.cpp
|
||||
@@ -154,13 +154,15 @@ bool GetKernelCmdlineFromString(const std::string& cmdline, const std::string& k
|
||||
|
||||
void ImportKernelCmdline(const std::function<void(std::string, std::string)>& fn) {
|
||||
std::string cmdline;
|
||||
- android::base::ReadFileToString("/proc/cmdline", &cmdline);
|
||||
+ android::base::ReadFileToString("/proc/self/cmdline", &cmdline); // HACKED
|
||||
+ std::replace(cmdline.begin(), cmdline.end(), '\0', ' '); // HACKED
|
||||
ImportKernelCmdlineFromString(android::base::Trim(cmdline), fn);
|
||||
}
|
||||
|
||||
bool GetKernelCmdline(const std::string& key, std::string* out) {
|
||||
std::string cmdline;
|
||||
- android::base::ReadFileToString("/proc/cmdline", &cmdline);
|
||||
+ android::base::ReadFileToString("/proc/self/cmdline", &cmdline); // HACKED
|
||||
+ std::replace(cmdline.begin(), cmdline.end(), '\0', ' '); // HACKED
|
||||
return GetKernelCmdlineFromString(android::base::Trim(cmdline), key, out);
|
||||
}
|
||||
|
||||
diff --git a/init/first_stage_init.cpp b/init/first_stage_init.cpp
|
||||
index e06a645..6406662 100644
|
||||
--- a/init/first_stage_init.cpp
|
||||
+++ b/init/first_stage_init.cpp
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <android-base/chrono_utils.h>
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
+#include <android-base/strings.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <android/avf_cc_flags.h>
|
||||
#include <fs_mgr.h>
|
||||
@@ -352,6 +353,8 @@ int FirstStageMain(int argc, char** argv) {
|
||||
CHECKCALL(mkdir("/dev/pts", 0755));
|
||||
CHECKCALL(mkdir("/dev/socket", 0755));
|
||||
CHECKCALL(mkdir("/dev/dm-user", 0755));
|
||||
+ mount("/system/etc", "/etc", "none", MS_BIND, NULL); // cgroup fix
|
||||
+ unshare(CLONE_NEWCGROUP);
|
||||
CHECKCALL(mount("devpts", "/dev/pts", "devpts", 0, NULL));
|
||||
#define MAKE_STR(x) __STRING(x)
|
||||
CHECKCALL(mount("proc", "/proc", "proc", 0, "hidepid=2,gid=" MAKE_STR(AID_READPROC)));
|
||||
@@ -420,7 +423,6 @@ int FirstStageMain(int argc, char** argv) {
|
||||
for (const auto& [error_string, error_errno] : errors) {
|
||||
LOG(ERROR) << error_string << " " << strerror(error_errno);
|
||||
}
|
||||
- LOG(FATAL) << "Init encountered errors starting first stage, aborting";
|
||||
}
|
||||
|
||||
LOG(INFO) << "init first stage started!";
|
||||
@@ -557,12 +559,22 @@ int FirstStageMain(int argc, char** argv) {
|
||||
1);
|
||||
|
||||
const char* path = "/system/bin/init";
|
||||
- const char* args[] = {path, "selinux_setup", nullptr};
|
||||
+ std::vector<const char *> args = {path, "second_stage"};
|
||||
+ std::string init_cmdline;
|
||||
+ android::base::ReadFileToString("/proc/self/cmdline", &init_cmdline);
|
||||
+ std::replace(init_cmdline.begin(), init_cmdline.end(), '\0', ' ');
|
||||
+ auto cmd_vector = android::base::Split(android::base::Trim(init_cmdline), " ");
|
||||
+ int i = 0;
|
||||
+ for (const auto& entry : cmd_vector) {
|
||||
+ if (i++ == 0) continue; // ignore first arg '/init'
|
||||
+ args.push_back(entry.c_str());
|
||||
+ }
|
||||
+ args.push_back(nullptr);
|
||||
auto fd = open("/dev/kmsg", O_WRONLY | O_CLOEXEC);
|
||||
dup2(fd, STDOUT_FILENO);
|
||||
dup2(fd, STDERR_FILENO);
|
||||
close(fd);
|
||||
- execv(path, const_cast<char**>(args));
|
||||
+ execv(path, const_cast<char**>(args.data()));
|
||||
|
||||
// execv() only returns if an error happened, in which case we
|
||||
// panic and never fall through this conditional.
|
||||
diff --git a/init/init.cpp b/init/init.cpp
|
||||
old mode 100644
|
||||
new mode 100755
|
||||
diff --git a/init/property_service.cpp b/init/property_service.cpp
|
||||
old mode 100644
|
||||
new mode 100755
|
||||
diff --git a/init/service.cpp b/init/service.cpp
|
||||
index 5630020..bd1f43f 100644
|
||||
--- a/init/service.cpp
|
||||
+++ b/init/service.cpp
|
||||
@@ -77,6 +77,7 @@ namespace android {
|
||||
namespace init {
|
||||
|
||||
static Result<std::string> ComputeContextFromExecutable(const std::string& service_path) {
|
||||
+ se_hack1("HACKED");
|
||||
std::string computed_context;
|
||||
|
||||
char* raw_con = nullptr;
|
||||
diff --git a/libcutils/ashmem-dev.cpp b/libcutils/ashmem-dev.cpp
|
||||
index 80c4f4c..f4d9e2a 100644
|
||||
--- a/libcutils/ashmem-dev.cpp
|
||||
+++ b/libcutils/ashmem-dev.cpp
|
||||
@@ -176,7 +176,7 @@ static int __ashmem_open_locked() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
- android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(ashmem_device_path.c_str(), O_RDWR | O_CLOEXEC)));
|
||||
+ android::base::unique_fd fd(TEMP_FAILURE_RETRY(open("/dev/ashmem", O_RDWR | O_CLOEXEC)));
|
||||
if (!fd.ok()) {
|
||||
ALOGE("Unable to open ashmem device: %m");
|
||||
return -1;
|
||||
diff --git a/rootdir/init.rc b/rootdir/init.rc
|
||||
index 471059b..52c967d 100644
|
||||
--- a/rootdir/init.rc
|
||||
+++ b/rootdir/init.rc
|
||||
@@ -15,6 +15,7 @@ import /system/etc/init/hw/init.${ro.zygote}.rc
|
||||
on early-init
|
||||
# Disable sysrq from keyboard
|
||||
write /proc/sys/kernel/sysrq 0
|
||||
+ mount sysfs sysfs /sys remount rw nodev
|
||||
|
||||
# Android doesn't need kernel module autoloading, and it causes SELinux
|
||||
# denials. So disable it by setting modprobe to the empty string. Note: to
|
||||
@@ -541,7 +542,6 @@ on post-fs
|
||||
|
||||
# Once everything is setup, no need to modify /.
|
||||
# The bind+remount combination allows this to work in containers.
|
||||
- mount rootfs rootfs / remount bind ro nodev
|
||||
|
||||
# Mount default storage into root namespace
|
||||
mount none /mnt/user/0 /storage bind rec
|
||||
--
|
||||
2.49.0
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
From 810a90e48678b11038ad7982dd9bb1e04c1e1efb Mon Sep 17 00:00:00 2001
|
||||
From: Ziyang Zhou <ziyang.zhou@outlook.com>
|
||||
Date: Sat, 26 Jun 2021 05:42:24 +0000
|
||||
Subject: [PATCH 2/7] allow override ro.* prop
|
||||
|
||||
---
|
||||
init/property_service.cpp | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/init/property_service.cpp b/init/property_service.cpp
|
||||
index 83e9a0d..bd55dcc 100755
|
||||
--- a/init/property_service.cpp
|
||||
+++ b/init/property_service.cpp
|
||||
@@ -1391,6 +1391,8 @@ static void ProcessKernelCmdline() {
|
||||
android::fs_mgr::ImportKernelCmdline([&](const std::string& key, const std::string& value) {
|
||||
if (StartsWith(key, ANDROIDBOOT_PREFIX)) {
|
||||
InitPropertySet("ro.boot." + key.substr(ANDROIDBOOT_PREFIX.size()), value);
|
||||
+ } else if (StartsWith(key, "ro.")) {
|
||||
+ InitPropertySet(key, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
--
|
||||
2.49.0
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
From 01ea704105418bbf7bc45d1199bef3d36db0c58d Mon Sep 17 00:00:00 2001
|
||||
From: Ziyang Zhou <ziyang.zhou@outlook.com>
|
||||
Date: Sun, 27 Jun 2021 09:49:22 +0000
|
||||
Subject: [PATCH 3/7] ? fix first stage mount
|
||||
|
||||
---
|
||||
init/first_stage_init.cpp | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/init/first_stage_init.cpp b/init/first_stage_init.cpp
|
||||
index 6406662..13c7553 100644
|
||||
--- a/init/first_stage_init.cpp
|
||||
+++ b/init/first_stage_init.cpp
|
||||
@@ -530,6 +530,7 @@ int FirstStageMain(int argc, char** argv) {
|
||||
if (!fsm) {
|
||||
fsm = CreateFirstStageMount(cmdline);
|
||||
}
|
||||
+ #if 0
|
||||
if (!fsm) {
|
||||
LOG(FATAL) << "FirstStageMount not available";
|
||||
}
|
||||
@@ -539,8 +540,9 @@ int FirstStageMain(int argc, char** argv) {
|
||||
}
|
||||
|
||||
if (!fsm->DoFirstStageMount()) {
|
||||
- LOG(FATAL) << "Failed to mount required partitions early ...";
|
||||
+ LOG(ERROR) << "Failed to mount required partitions early ...";
|
||||
}
|
||||
+ #endif
|
||||
}
|
||||
|
||||
struct stat new_root_info {};
|
||||
--
|
||||
2.49.0
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
From b3426e7aa82ad2ae5b0935fc53216335310310df Mon Sep 17 00:00:00 2001
|
||||
From: Ziyang Zhou <ziyang.zhou@outlook.com>
|
||||
Date: Fri, 25 Jun 2021 15:56:47 +0000
|
||||
Subject: [PATCH 4/7] ignore input subsystem
|
||||
|
||||
---
|
||||
rootdir/ueventd.rc | 3 ---
|
||||
1 file changed, 3 deletions(-)
|
||||
|
||||
diff --git a/rootdir/ueventd.rc b/rootdir/ueventd.rc
|
||||
index 3927501..404da8f 100644
|
||||
--- a/rootdir/ueventd.rc
|
||||
+++ b/rootdir/ueventd.rc
|
||||
@@ -12,9 +12,6 @@ subsystem drm
|
||||
devname uevent_devpath
|
||||
dirname /dev/dri
|
||||
|
||||
-subsystem input
|
||||
- devname uevent_devpath
|
||||
- dirname /dev/input
|
||||
|
||||
subsystem sound
|
||||
devname uevent_devpath
|
||||
--
|
||||
2.49.0
|
||||
|
||||
24
android-16.0.0_r2/system/core/0005-ignore-devfs-mount.patch
Normal file
24
android-16.0.0_r2/system/core/0005-ignore-devfs-mount.patch
Normal file
@@ -0,0 +1,24 @@
|
||||
From ddb69215b3cd4ecee0993fa6bbd1752b71ac511b Mon Sep 17 00:00:00 2001
|
||||
From: Ziyang Zhou <ziyang.zhou@outlook.com>
|
||||
Date: Fri, 17 Dec 2021 22:44:33 +0800
|
||||
Subject: [PATCH 5/7] ignore devfs mount
|
||||
|
||||
---
|
||||
init/first_stage_init.cpp | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/init/first_stage_init.cpp b/init/first_stage_init.cpp
|
||||
index 13c7553..8485b3d 100644
|
||||
--- a/init/first_stage_init.cpp
|
||||
+++ b/init/first_stage_init.cpp
|
||||
@@ -349,7 +349,6 @@ int FirstStageMain(int argc, char** argv) {
|
||||
CHECKCALL(setenv("PATH", _PATH_DEFPATH, 1));
|
||||
// Get the basic filesystem setup we need put together in the initramdisk
|
||||
// on / and then we'll let the rc file figure out the rest.
|
||||
- CHECKCALL(mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755"));
|
||||
CHECKCALL(mkdir("/dev/pts", 0755));
|
||||
CHECKCALL(mkdir("/dev/socket", 0755));
|
||||
CHECKCALL(mkdir("/dev/dm-user", 0755));
|
||||
--
|
||||
2.49.0
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
From 4f325fbbcd4ff9c5ddedb6d3d3a1f587cfc950bd Mon Sep 17 00:00:00 2001
|
||||
From: Ziyang Zhou <ziyang.zhou@outlook.com>
|
||||
Date: Thu, 6 Jan 2022 20:47:28 +0800
|
||||
Subject: [PATCH 6/7] auto alloc binder devices
|
||||
|
||||
---
|
||||
rootdir/init.rc | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/rootdir/init.rc b/rootdir/init.rc
|
||||
index 52c967d..bc92e33 100644
|
||||
--- a/rootdir/init.rc
|
||||
+++ b/rootdir/init.rc
|
||||
@@ -219,6 +219,7 @@ on init
|
||||
mkdir /dev/binderfs
|
||||
mount binder binder /dev/binderfs stats=global
|
||||
chmod 0755 /dev/binderfs
|
||||
+ exec -- /vendor/bin/binder_alloc /dev/binderfs/binder-control binder hwbinder vndbinder
|
||||
|
||||
# Mount fusectl
|
||||
mount fusectl none /sys/fs/fuse/connections
|
||||
--
|
||||
2.49.0
|
||||
|
||||
24
android-16.0.0_r2/system/core/0007-skip-fusectl-mount.patch
Normal file
24
android-16.0.0_r2/system/core/0007-skip-fusectl-mount.patch
Normal file
@@ -0,0 +1,24 @@
|
||||
From 46eb689748f2c3d0ee19e0e247046249490a10b6 Mon Sep 17 00:00:00 2001
|
||||
From: Ziyang Zhou <ziyang.zhou@outlook.com>
|
||||
Date: Sat, 2 Sep 2023 17:10:16 +0800
|
||||
Subject: [PATCH 7/7] skip fusectl mount
|
||||
|
||||
---
|
||||
rootdir/init.rc | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/rootdir/init.rc b/rootdir/init.rc
|
||||
index bc92e33..63ff049 100644
|
||||
--- a/rootdir/init.rc
|
||||
+++ b/rootdir/init.rc
|
||||
@@ -222,7 +222,6 @@ on init
|
||||
exec -- /vendor/bin/binder_alloc /dev/binderfs/binder-control binder hwbinder vndbinder
|
||||
|
||||
# Mount fusectl
|
||||
- mount fusectl none /sys/fs/fuse/connections
|
||||
|
||||
symlink /dev/binderfs/binder /dev/binder
|
||||
symlink /dev/binderfs/hwbinder /dev/hwbinder
|
||||
--
|
||||
2.49.0
|
||||
|
||||
Reference in New Issue
Block a user