system/corennnnn
Revision | 7d406cb654028a11841908999e0d7189edf6f970 (tree) |
---|---|
Time | 2016-07-27 03:54:20 |
Author | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Jaap Jan Meijer |
init: add modprobe to load kernel requested modules
@@ -104,6 +104,7 @@ LOCAL_STATIC_LIBRARIES := \ | ||
104 | 104 | |
105 | 105 | # Create symlinks |
106 | 106 | LOCAL_POST_INSTALL_CMD := $(hide) mkdir -p $(TARGET_ROOT_OUT)/sbin; \ |
107 | + ln -sf ../init $(TARGET_ROOT_OUT)/sbin/modprobe; \ | |
107 | 108 | ln -sf ../init $(TARGET_ROOT_OUT)/sbin/ueventd; \ |
108 | 109 | ln -sf ../init $(TARGET_ROOT_OUT)/sbin/watchdogd |
109 | 110 |
@@ -59,6 +59,7 @@ | ||
59 | 59 | #include "bootchart.h" |
60 | 60 | #include "signal_handler.h" |
61 | 61 | #include "keychords.h" |
62 | +#include "keywords.h" | |
62 | 63 | #include "init_parser.h" |
63 | 64 | #include "util.h" |
64 | 65 | #include "ueventd.h" |
@@ -1020,7 +1021,37 @@ static int charging_mode_booting(void) { | ||
1020 | 1021 | #endif |
1021 | 1022 | } |
1022 | 1023 | |
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 | + | |
1023 | 1050 | int main(int argc, char** argv) { |
1051 | + if (strstr(argv[0], "modprobe")) { | |
1052 | + return modprobe_main(argc, argv); | |
1053 | + } | |
1054 | + | |
1024 | 1055 | if (!strcmp(basename(argv[0]), "ueventd")) { |
1025 | 1056 | return ueventd_main(argc, argv); |
1026 | 1057 | } |