aboutsummaryrefslogtreecommitdiff
path: root/core/busybox/patches/modprobe-kernel-version.patch
blob: 2d4274ad02d9a08404594e57a8386aaa88e2d977 (plain)
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
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index 0a372a049..ecb29a8fd 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -111,7 +111,7 @@
 //usage:       "   from the command line\n"
 //usage:
 //usage:#define modprobe_trivial_usage
-//usage:	"[-alrqvsD" IF_FEATURE_MODPROBE_BLACKLIST("b") "]"
+//usage:	"[-alrqvsD" IF_FEATURE_MODPROBE_BLACKLIST("b") "]" " [-S VERSION]"
 //usage:	" MODULE" IF_FEATURE_CMDLINE_MODULE_OPTIONS(" [SYMBOL=VALUE]...")
 //usage:#define modprobe_full_usage "\n\n"
 //usage:       "	-a	Load multiple MODULEs"
@@ -121,6 +121,7 @@
 //usage:     "\n	-v	Verbose"
 //usage:     "\n	-s	Log to syslog"
 //usage:     "\n	-D	Show dependencies"
+//usage:     "\n	-S	Set kernel version"
 //usage:	IF_FEATURE_MODPROBE_BLACKLIST(
 //usage:     "\n	-b	Apply blacklist to module names too"
 //usage:	)
@@ -131,7 +132,7 @@
  * Note2: -b is always accepted, but if !FEATURE_MODPROBE_BLACKLIST,
  * it is a no-op.
  */
-#define MODPROBE_OPTS  "alrDb"
+#define MODPROBE_OPTS  "alrDS:b"
 /* -a and -D _are_ in fact compatible */
 #define MODPROBE_COMPLEMENTARY "q-v:v-q:l--arD:r--alD:a--lr:D--rl"
 //#define MODPROBE_OPTS  "acd:lnrt:C:b"
@@ -147,7 +148,8 @@ enum {
 	//OPT_VERONLY    = (INSMOD_OPT_UNUSED << x), /* V */
 	//OPT_CONFIGFILE = (INSMOD_OPT_UNUSED << x), /* C */
 	OPT_SHOW_DEPS    = (INSMOD_OPT_UNUSED << 3), /* D */
-	OPT_BLACKLIST    = (INSMOD_OPT_UNUSED << 4) * ENABLE_FEATURE_MODPROBE_BLACKLIST,
+	OPT_KERNEL       = (INSMOD_OPT_UNUSED << 4), /* S */
+	OPT_BLACKLIST    = (INSMOD_OPT_UNUSED << 5) * ENABLE_FEATURE_MODPROBE_BLACKLIST,
 };
 #if ENABLE_LONG_OPTS
 static const char modprobe_longopts[] ALIGN1 =
@@ -560,6 +562,7 @@ int modprobe_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int modprobe_main(int argc UNUSED_PARAM, char **argv)
 {
 	int rc;
+	char *kernel;
 	unsigned opt;
 	struct module_entry *me;
 
@@ -567,13 +570,20 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
 
 	opt = getopt32long(argv, "^" INSMOD_OPTS MODPROBE_OPTS "\0" MODPROBE_COMPLEMENTARY,
 			modprobe_longopts
-			INSMOD_ARGS
+			INSMOD_ARGS,
+			&kernel
 	);
 	argv += optind;
 
+	/* Set user specified kernel version */
+	if (opt & OPT_KERNEL) {
+	    safe_strncpy(G.uts.release, kernel, sizeof(G.uts.release));
+	} else {
+	    uname(&G.uts);
+	}
+
 	/* Goto modules location */
 	xchdir(CONFIG_DEFAULT_MODULES_DIR);
-	uname(&G.uts);
 	xchdir(G.uts.release);
 
 	if (opt & OPT_LIST_ONLY) {