]>
Commit | Line | Data |
---|---|---|
20701c69 AM |
1 | diff -urN busybox-1.00-pre2.org/include/applets.h busybox-1.00-pre2/include/applets.h |
2 | --- busybox-1.00-pre2.org/include/applets.h 2003-08-02 23:46:48.000000000 +0200 | |
3 | +++ busybox-1.00-pre2/include/applets.h 2003-08-03 00:08:29.000000000 +0200 | |
4 | @@ -286,6 +286,9 @@ | |
5 | #ifdef CONFIG_INSMOD | |
6 | APPLET(insmod, insmod_main, _BB_DIR_SBIN, _BB_SUID_NEVER) | |
765226f2 | 7 | #endif |
20701c69 | 8 | +#ifdef CONFIG_FEATURE_REALLY_NEW_MODULE_INTERFACE |
8b17e116 | 9 | + APPLET(insmod_ng, insmod_ng_main, _BB_DIR_SBIN, _BB_SUID_NEVER) |
765226f2 | 10 | +#endif |
20701c69 AM |
11 | #ifdef CONFIG_IP |
12 | APPLET(ip, ip_main, _BB_DIR_BIN, _BB_SUID_NEVER) | |
765226f2 | 13 | #endif |
20701c69 AM |
14 | diff -urN busybox-1.00-pre2.org/include/usage.h busybox-1.00-pre2/include/usage.h |
15 | --- busybox-1.00-pre2.org/include/usage.h 2003-08-02 23:46:48.000000000 +0200 | |
16 | +++ busybox-1.00-pre2/include/usage.h 2003-08-03 00:01:40.000000000 +0200 | |
17 | @@ -1312,6 +1312,11 @@ | |
18 | " [ [i|o]seq ] [ [i|o]key KEY ] [ [i|o]csum ]\n" \ | |
19 | " [ ttl TTL ] [ tos TOS ] [ [no]pmtudisc ] [ dev PHYS_DEV ]\n" | |
20 | ||
21 | +#define insmod_ng_trivial_usage \ | |
22 | + "MODULE [symbol=value]..." | |
23 | +#define insmod_ng_full_usage \ | |
24 | + "Loads the specified kernel modules into the kernel." | |
25 | + | |
26 | #define kill_trivial_usage \ | |
27 | "[-signal] process-id [process-id ...]" | |
28 | #define kill_full_usage \ | |
29 | diff -urN busybox-1.00-pre2.org/modutils/Config.in busybox-1.00-pre2/modutils/Config.in | |
30 | --- busybox-1.00-pre2.org/modutils/Config.in 2003-08-02 23:46:49.000000000 +0200 | |
31 | +++ busybox-1.00-pre2/modutils/Config.in 2003-08-03 00:06:09.000000000 +0200 | |
32 | @@ -33,6 +33,15 @@ | |
33 | Support module loading for newer (post 2.1) Linux kernels. | |
34 | endif | |
35 | ||
36 | +if CONFIG_FEATURE_NEW_MODULE_INTERFACE | |
37 | +config CONFIG_FEATURE_REALLY_NEW_MODULE_INTERFACE | |
38 | + bool " Support new (port 2.5) Linux kernels" | |
39 | + default y | |
40 | + depends on CONFIG_INSMOD | |
41 | + help | |
42 | + Support module loading for newer (port 2.5) Linux kernels. | |
43 | +endif | |
44 | + | |
45 | config CONFIG_FEATURE_INSMOD_VERSION_CHECKING | |
46 | bool " Module version checking" | |
47 | default n | |
48 | diff -urN busybox-1.00-pre2.org/modutils/insmod.c busybox-1.00-pre2/modutils/insmod.c | |
49 | --- busybox-1.00-pre2.org/modutils/insmod.c 2003-08-02 23:46:49.000000000 +0200 | |
50 | +++ busybox-1.00-pre2/modutils/insmod.c 2003-08-03 00:01:35.000000000 +0200 | |
51 | @@ -4049,6 +4049,14 @@ | |
765226f2 MM |
52 | |
53 | printf("Using %s\n", m_filename); | |
54 | ||
55 | +#ifdef BB_INSMOD_NG | |
56 | + if (create_module(NULL, 0) < 0 && errno == ENOSYS) { | |
57 | + optind--; | |
58 | + argv[optind] = m_filename; | |
59 | + return insmod_ng_main(argc - optind, argv + optind); | |
60 | + } | |
61 | +#endif | |
62 | + | |
63 | if ((f = obj_load(fp, LOADBITS)) == NULL) | |
20701c69 | 64 | bb_perror_msg_and_die("Could not load the module"); |
765226f2 | 65 | |
20701c69 AM |
66 | diff -urN busybox-1.00-pre2.org/modutils/insmod_ng.c busybox-1.00-pre2/modutils/insmod_ng.c |
67 | --- busybox-1.00-pre2.org/modutils/insmod_ng.c 1970-01-01 01:00:00.000000000 +0100 | |
68 | +++ busybox-1.00-pre2/modutils/insmod_ng.c 2003-08-03 00:01:35.000000000 +0200 | |
765226f2 MM |
69 | @@ -0,0 +1,110 @@ |
70 | +/* vi: set sw=4 ts=4: */ | |
71 | +/* | |
72 | + * insmod for 2.5 kernels implementation for busybox | |
73 | + * busybox version by Michal Moskal <malekith@pld-linux.org> | |
74 | + * | |
75 | + * Copyright (C) 2001 Rusty Russell. | |
76 | + * Copyright (C) 2002 Rusty Russell, IBM Corporation. | |
77 | + * | |
78 | + * This program is free software; you can redistribute it and/or modify | |
79 | + * it under the terms of the GNU General Public License as published by | |
80 | + * the Free Software Foundation; either version 2 of the License, or | |
81 | + * (at your option) any later version. | |
82 | + * | |
83 | + * This program is distributed in the hope that it will be useful, | |
84 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
85 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
86 | + * GNU General Public License for more details. | |
87 | + * | |
88 | + * You should have received a copy of the GNU General Public License | |
89 | + * along with this program; if not, write to the Free Software | |
90 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
91 | + */ | |
92 | + | |
93 | +#include <string.h> | |
94 | +#include <stdlib.h> | |
95 | +#include <unistd.h> | |
96 | +#include <fcntl.h> | |
97 | +#include <sys/mman.h> | |
98 | +#include <sys/types.h> | |
99 | +#include <sys/stat.h> | |
100 | +#include <unistd.h> | |
101 | +#include <errno.h> | |
102 | +#include <asm/unistd.h> | |
103 | +#include <sys/syscall.h> | |
104 | + | |
105 | +#include "busybox.h" | |
106 | + | |
107 | +#define __NR_init_module_25 __NR_init_module | |
108 | +static _syscall3(long, init_module_25, void *, map, size_t, len, char *, options) | |
109 | + | |
110 | +/* We use error numbers in a loose translation... */ | |
111 | +static const char *moderror(int err) | |
112 | +{ | |
113 | + switch (err) { | |
114 | + case ENOEXEC: | |
115 | + return "Invalid module format"; | |
116 | + case ENOENT: | |
117 | + return "Unknown symbol in module"; | |
118 | + case ESRCH: | |
119 | + return "Module has wrong symbol version"; | |
120 | + case EINVAL: | |
121 | + return "Invalid parameters"; | |
122 | + default: | |
123 | + return strerror(err); | |
124 | + } | |
125 | +} | |
126 | + | |
127 | +extern int insmod_ng_main(int argc, char **argv) | |
128 | +{ | |
129 | + int i; | |
130 | + int fd; | |
131 | + long int ret; | |
132 | + struct stat st; | |
133 | + unsigned long len; | |
134 | + void *map; | |
135 | + char *filename, *options = xstrdup(""); | |
136 | + | |
137 | + filename = argv[1]; | |
138 | + if (!filename) | |
139 | + show_usage(); | |
140 | + | |
141 | + /* Rest is options */ | |
142 | + for (i = 2; i < argc; i++) { | |
143 | + options = xrealloc(options, | |
144 | + strlen(options) + 2 + strlen(argv[i]) + 2); | |
145 | + /* Spaces handled by "" pairs, but no way of escaping quotes */ | |
146 | + if (strchr(argv[i], ' ')) { | |
147 | + strcat(options, "\""); | |
148 | + strcat(options, argv[i]); | |
149 | + strcat(options, "\""); | |
150 | + } else { | |
151 | + strcat(options, argv[i]); | |
152 | + } | |
153 | + strcat(options, " "); | |
154 | + } | |
155 | + | |
156 | + if ((fd = open(filename, O_RDONLY, 0)) < 0) | |
157 | + perror_msg_and_die("cannot open module `%s'", filename); | |
158 | + | |
159 | + fstat(fd, &st); | |
160 | + len = st.st_size; | |
161 | + map = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0); | |
162 | + if (map == MAP_FAILED) | |
163 | + perror_msg_and_die("cannot mmap `%s'", filename); | |
164 | + | |
165 | + ret = init_module_25(map, len, options); | |
166 | + if (ret != 0) | |
167 | + perror_msg_and_die("cannot insert `%s': %s (%li)", | |
168 | + filename, moderror(errno), ret); | |
169 | + | |
170 | + return 0; | |
171 | +} | |
172 | + | |
173 | +/* | |
174 | +Local Variables: | |
175 | +c-file-style: "linux" | |
176 | +c-basic-offset: 4 | |
177 | +tab-width: 4 | |
178 | +End: | |
179 | +*/ | |
20701c69 AM |
180 | diff -urN busybox-1.00-pre2.org/modutils/Makefile.in busybox-1.00-pre2/modutils/Makefile.in |
181 | --- busybox-1.00-pre2.org/modutils/Makefile.in 2003-08-02 23:46:49.000000000 +0200 | |
182 | +++ busybox-1.00-pre2/modutils/Makefile.in 2003-08-03 00:06:59.000000000 +0200 | |
183 | @@ -24,6 +24,7 @@ | |
765226f2 | 184 | |
20701c69 AM |
185 | MODUTILS-y:= |
186 | MODUTILS-$(CONFIG_INSMOD) += insmod.o | |
187 | +MODUTILS-$(CONFIG_FEATURE_REALLY_NEW_MODULE_INTERFACE) += insmod_ng.o | |
188 | MODUTILS-$(CONFIG_LSMOD) += lsmod.o | |
189 | MODUTILS-$(CONFIG_MODPROBE) += modprobe.o | |
190 | MODUTILS-$(CONFIG_RMMOD) += rmmod.o |