]> git.pld-linux.org Git - packages/busybox.git/blame - busybox-insmod_ng.patch
- dropped, use mdadm instead
[packages/busybox.git] / busybox-insmod_ng.patch
CommitLineData
68773608
AM
1diff -urN busybox-1.00-pre3.org/include/applets.h busybox-1.00-pre3/include/applets.h
2--- busybox-1.00-pre3.org/include/applets.h 2003-09-15 20:55:05.000000000 +0200
3+++ busybox-1.00-pre3/include/applets.h 2003-09-15 21:03:21.000000000 +0200
4@@ -283,6 +283,9 @@
5 #ifdef CONFIG_INSMOD
6 APPLET(insmod, insmod_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
7 #endif
8+#ifdef CONFIG_FEATURE_REALLY_NEW_MODULE_INTERFACE
9+ APPLET(insmod_ng, insmod_ng_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
10+#endif
11 #ifdef CONFIG_IP
12 APPLET(ip, ip_main, _BB_DIR_BIN, _BB_SUID_NEVER)
13 #endif
14diff -urN busybox-1.00-pre3.org/include/usage.h busybox-1.00-pre3/include/usage.h
15--- busybox-1.00-pre3.org/include/usage.h 2003-09-15 20:55:05.000000000 +0200
16+++ busybox-1.00-pre3/include/usage.h 2003-09-15 21:03:24.000000000 +0200
17@@ -1318,6 +1318,11 @@
18 #define insmod_ng_full_usage \
19 "Loads the specified kernel modules into the kernel."
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 \
29diff -urN busybox-1.00-pre3.org/modutils/Config.in busybox-1.00-pre3/modutils/Config.in
30--- busybox-1.00-pre3.org/modutils/Config.in 2003-09-15 20:55:05.000000000 +0200
31+++ busybox-1.00-pre3/modutils/Config.in 2003-09-15 21:03:24.000000000 +0200
20701c69
AM
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
68773608
AM
48diff -urN busybox-1.00-pre3.org/modutils/insmod.c busybox-1.00-pre3/modutils/insmod.c
49--- busybox-1.00-pre3.org/modutils/insmod.c 2003-09-15 20:55:05.000000000 +0200
50+++ busybox-1.00-pre3/modutils/insmod.c 2003-09-15 21:03:25.000000000 +0200
51@@ -4141,6 +4141,14 @@
52 }
53 #endif
54
55+#ifdef CONFIG_FEATURE_REALLY_NEW_MODULE_INTERFACE
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)
64 bb_perror_msg_and_die("Could not load the module");
65
66diff -urN busybox-1.00-pre3.org/modutils/insmod_ng.c busybox-1.00-pre3/modutils/insmod_ng.c
67--- busybox-1.00-pre3.org/modutils/insmod_ng.c 1970-01-01 01:00:00.000000000 +0100
68+++ busybox-1.00-pre3/modutils/insmod_ng.c 2003-09-15 21:03:25.000000000 +0200
cb43079d 69@@ -0,0 +1,109 @@
765226f2
MM
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+
765226f2
MM
107+/* We use error numbers in a loose translation... */
108+static const char *moderror(int err)
109+{
110+ switch (err) {
111+ case ENOEXEC:
112+ return "Invalid module format";
113+ case ENOENT:
114+ return "Unknown symbol in module";
115+ case ESRCH:
116+ return "Module has wrong symbol version";
117+ case EINVAL:
118+ return "Invalid parameters";
119+ default:
120+ return strerror(err);
121+ }
122+}
123+
124+extern int insmod_ng_main(int argc, char **argv)
125+{
126+ int i;
127+ int fd;
128+ long int ret;
129+ struct stat st;
130+ unsigned long len;
131+ void *map;
5f5eaac3 132+ char *filename, *options = bb_xstrdup("");
765226f2
MM
133+
134+ filename = argv[1];
5f5eaac3
AM
135+ if (!filename) {
136+ bb_show_usage();
137+ return -1;
138+ }
765226f2
MM
139+
140+ /* Rest is options */
141+ for (i = 2; i < argc; i++) {
142+ options = xrealloc(options,
143+ strlen(options) + 2 + strlen(argv[i]) + 2);
144+ /* Spaces handled by "" pairs, but no way of escaping quotes */
145+ if (strchr(argv[i], ' ')) {
146+ strcat(options, "\"");
147+ strcat(options, argv[i]);
148+ strcat(options, "\"");
149+ } else {
150+ strcat(options, argv[i]);
151+ }
152+ strcat(options, " ");
153+ }
154+
155+ if ((fd = open(filename, O_RDONLY, 0)) < 0)
5f5eaac3 156+ bb_perror_msg_and_die("cannot open module `%s'", filename);
765226f2
MM
157+
158+ fstat(fd, &st);
159+ len = st.st_size;
160+ map = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
161+ if (map == MAP_FAILED)
5f5eaac3 162+ bb_perror_msg_and_die("cannot mmap `%s'", filename);
765226f2 163+
cb43079d 164+ ret = init_module(map, len, options);
765226f2 165+ if (ret != 0)
5f5eaac3 166+ bb_perror_msg_and_die("cannot insert `%s': %s (%li)",
765226f2
MM
167+ filename, moderror(errno), ret);
168+
169+ return 0;
170+}
171+
172+/*
173+Local Variables:
174+c-file-style: "linux"
175+c-basic-offset: 4
176+tab-width: 4
177+End:
178+*/
68773608
AM
179diff -urN busybox-1.00-pre3.org/modutils/Makefile.in busybox-1.00-pre3/modutils/Makefile.in
180--- busybox-1.00-pre3.org/modutils/Makefile.in 2003-09-15 20:55:05.000000000 +0200
181+++ busybox-1.00-pre3/modutils/Makefile.in 2003-09-15 21:03:25.000000000 +0200
20701c69 182@@ -24,6 +24,7 @@
765226f2 183
20701c69
AM
184 MODUTILS-y:=
185 MODUTILS-$(CONFIG_INSMOD) += insmod.o
186+MODUTILS-$(CONFIG_FEATURE_REALLY_NEW_MODULE_INTERFACE) += insmod_ng.o
187 MODUTILS-$(CONFIG_LSMOD) += lsmod.o
188 MODUTILS-$(CONFIG_MODPROBE) += modprobe.o
189 MODUTILS-$(CONFIG_RMMOD) += rmmod.o
This page took 0.063485 seconds and 4 git commands to generate.