-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.patch
More file actions
73 lines (65 loc) · 2.03 KB
/
init.patch
File metadata and controls
73 lines (65 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Subject: [PATCH] init: Add support for kernels that don't have finit_module
Some kernels don't have finit_module, which makes booting Android 7.0
impossible if people can't backport it themselves, so set
KERNEL_HAS_FINIT_MODULE := false in BoardConfig.mk file to
allow booting 7.0 even when the kernel doesn't have finit_
module :)
diff --git a/init/Android.mk b/init/Android.mk
index a19b158..d66ac5a 100644
--- a/init/Android.mk
+++ b/init/Android.mk
@@ -95,6 +95,10 @@
watchdogd.cpp \
vendor_init.cpp
+ifeq ($(KERNEL_HAS_FINIT_MODULE), false)
+LOCAL_CFLAGS += -DNO_FINIT_MODULE
+endif
+
LOCAL_MODULE:= init
LOCAL_C_INCLUDES += \
system/core/mkbootimg
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 1df4e91..10c4bb9 100755
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -29,7 +29,9 @@
#include <sys/socket.h>
#include <sys/mount.h>
#include <sys/resource.h>
+#ifndef NO_FINIT_MODULE
#include <sys/syscall.h>
+#endif
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -73,20 +75,34 @@
#define chmod DO_NOT_USE_CHMOD_USE_FCHMODAT_SYMLINK_NOFOLLOW
+#ifdef NO_FINIT_MODULE
+// System call provided by bionic but not in any header file.
+extern "C" int init_module(void *, unsigned long, const char *);
+#endif
+
static constexpr std::chrono::nanoseconds kCommandRetryTimeout = 5s;
static int insmod(const char *filename, const char *options, int flags) {
+#ifndef NO_FINIT_MODULE
int fd = open(filename, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (fd == -1) {
PLOG(ERROR) << "insmod: open(\"" << filename << "\") failed";
+#else
+ std::string module;
+ if (!read_file(filename, &module)) {
+#endif
return -1;
}
+#ifndef NO_FINIT_MODULE
int rc = syscall(__NR_finit_module, fd, options, flags);
if (rc == -1) {
PLOG(ERROR) << "finit_module for \"" << filename << "\" failed";
}
close(fd);
return rc;
+#else
+ return init_module(&module[0], module.size(), options);
+#endif
}
static int __ifupdown(const char *interface, int up) {