• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Revision7d406cb654028a11841908999e0d7189edf6f970 (tree)
Time2016-07-27 03:54:20
AuthorChih-Wei Huang <cwhuang@linu...>
CommiterJaap Jan Meijer

Log Message

init: add modprobe to load kernel requested modules

Change Summary

Incremental Difference

--- a/init/Android.mk
+++ b/init/Android.mk
@@ -104,6 +104,7 @@ LOCAL_STATIC_LIBRARIES := \
104104
105105 # Create symlinks
106106 LOCAL_POST_INSTALL_CMD := $(hide) mkdir -p $(TARGET_ROOT_OUT)/sbin; \
107+ ln -sf ../init $(TARGET_ROOT_OUT)/sbin/modprobe; \
107108 ln -sf ../init $(TARGET_ROOT_OUT)/sbin/ueventd; \
108109 ln -sf ../init $(TARGET_ROOT_OUT)/sbin/watchdogd
109110
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -59,6 +59,7 @@
5959 #include "bootchart.h"
6060 #include "signal_handler.h"
6161 #include "keychords.h"
62+#include "keywords.h"
6263 #include "init_parser.h"
6364 #include "util.h"
6465 #include "ueventd.h"
@@ -1020,7 +1021,37 @@ static int charging_mode_booting(void) {
10201021 #endif
10211022 }
10221023
1024+int modprobe_main(int argc, char **argv)
1025+{
1026+ char *prog = argv[0];
1027+
1028+ /* We only accept requests from root user (kernel) */
1029+ if (getuid())
1030+ return -EPERM;
1031+
1032+ /* Kernel will launch a user space program specified by
1033+ * /proc/sys/kernel/modprobe to load modules.
1034+ * No deferred loading in this case.
1035+ */
1036+ while (argc > 1 && (!strcmp(argv[1], "-q") || !strcmp(argv[1], "--"))) {
1037+ klog_set_level(KLOG_NOTICE_LEVEL);
1038+ argc--, argv++;
1039+ }
1040+
1041+ if (argc < 2) {
1042+ /* it is called without enough arguments */
1043+ return -EINVAL;
1044+ }
1045+
1046+ NOTICE("%s %s\n", prog, argv[1]);
1047+ return module_probe(argv[1]) ? do_probemod(argc, argv) : 0;
1048+}
1049+
10231050 int main(int argc, char** argv) {
1051+ if (strstr(argv[0], "modprobe")) {
1052+ return modprobe_main(argc, argv);
1053+ }
1054+
10241055 if (!strcmp(basename(argv[0]), "ueventd")) {
10251056 return ueventd_main(argc, argv);
10261057 }