system/corennnnn
Revisão | 6b71e30be33ac9ae1af29f3ec823fc7abe44eae5 (tree) |
---|---|
Hora | 2016-10-16 18:01:30 |
Autor | DodoGTA GT <aidas957@gmai...> |
Commiter | DodoGTA GT |
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 :)
Change-Id: Iec63c1846cdc5e5bb3b61610ea438cf8eff8635b
@@ -99,6 +99,10 @@ ifneq ($(TARGET_IGNORE_RO_BOOT_REVISION),) | ||
99 | 99 | LOCAL_CFLAGS += -DIGNORE_RO_BOOT_REVISION |
100 | 100 | endif |
101 | 101 | |
102 | +ifeq ($(KERNEL_HAS_FINIT_MODULE), false) | |
103 | +LOCAL_CFLAGS += -DNO_FINIT_MODULE | |
104 | +endif | |
105 | + | |
102 | 106 | LOCAL_MODULE:= init |
103 | 107 | LOCAL_C_INCLUDES += \ |
104 | 108 | system/extras/ext4_utils \ |
@@ -29,7 +29,9 @@ | ||
29 | 29 | #include <sys/socket.h> |
30 | 30 | #include <sys/mount.h> |
31 | 31 | #include <sys/resource.h> |
32 | +#ifndef NO_FINIT_MODULE | |
32 | 33 | #include <sys/syscall.h> |
34 | +#endif | |
33 | 35 | #include <sys/time.h> |
34 | 36 | #include <sys/types.h> |
35 | 37 | #include <sys/stat.h> |
@@ -69,20 +71,34 @@ using android::base::StringPrintf; | ||
69 | 71 | #define UNMOUNT_CHECK_MS 5000 |
70 | 72 | #define UNMOUNT_CHECK_TIMES 10 |
71 | 73 | |
74 | +#ifdef NO_FINIT_MODULE | |
75 | +// System call provided by bionic but not in any header file. | |
76 | +extern "C" int init_module(void *, unsigned long, const char *); | |
77 | +#endif | |
78 | + | |
72 | 79 | static const int kTerminateServiceDelayMicroSeconds = 50000; |
73 | 80 | |
74 | 81 | static int insmod(const char *filename, const char *options) { |
82 | +#ifndef NO_FINIT_MODULE | |
75 | 83 | int fd = open(filename, O_RDONLY | O_NOFOLLOW | O_CLOEXEC); |
76 | 84 | if (fd == -1) { |
77 | 85 | ERROR("insmod: open(\"%s\") failed: %s", filename, strerror(errno)); |
86 | +#else | |
87 | + std::string module; | |
88 | + if (!read_file(filename, &module)) { | |
89 | +#endif | |
78 | 90 | return -1; |
79 | 91 | } |
92 | +#ifndef NO_FINIT_MODULE | |
80 | 93 | int rc = syscall(__NR_finit_module, fd, options, 0); |
81 | 94 | if (rc == -1) { |
82 | 95 | ERROR("finit_module for \"%s\" failed: %s", filename, strerror(errno)); |
83 | 96 | } |
84 | 97 | close(fd); |
85 | 98 | return rc; |
99 | +#else | |
100 | + return init_module(&module[0], module.size(), options); | |
101 | +#endif | |
86 | 102 | } |
87 | 103 | |
88 | 104 | static int __ifupdown(const char *interface, int up) { |