diff -urN busybox-1.00-pre3.org/include/applets.h busybox-1.00-pre3/include/applets.h --- busybox-1.00-pre3.org/include/applets.h 2003-09-15 20:55:05.000000000 +0200 +++ busybox-1.00-pre3/include/applets.h 2003-09-15 21:03:21.000000000 +0200 @@ -283,6 +283,9 @@ #ifdef CONFIG_INSMOD APPLET(insmod, insmod_main, _BB_DIR_SBIN, _BB_SUID_NEVER) #endif +#ifdef CONFIG_FEATURE_REALLY_NEW_MODULE_INTERFACE + APPLET(insmod_ng, insmod_ng_main, _BB_DIR_SBIN, _BB_SUID_NEVER) +#endif #ifdef CONFIG_IP APPLET(ip, ip_main, _BB_DIR_BIN, _BB_SUID_NEVER) #endif diff -urN busybox-1.00-pre3.org/include/usage.h busybox-1.00-pre3/include/usage.h --- busybox-1.00-pre3.org/include/usage.h 2003-09-15 20:55:05.000000000 +0200 +++ busybox-1.00-pre3/include/usage.h 2003-09-15 21:03:24.000000000 +0200 @@ -1318,6 +1318,11 @@ #define insmod_ng_full_usage \ "Loads the specified kernel modules into the kernel." +#define insmod_ng_trivial_usage \ + "MODULE [symbol=value]..." +#define insmod_ng_full_usage \ + "Loads the specified kernel modules into the kernel." + #define kill_trivial_usage \ "[-signal] process-id [process-id ...]" #define kill_full_usage \ diff -urN busybox-1.00-pre3.org/modutils/Config.in busybox-1.00-pre3/modutils/Config.in --- busybox-1.00-pre3.org/modutils/Config.in 2003-09-15 20:55:05.000000000 +0200 +++ busybox-1.00-pre3/modutils/Config.in 2003-09-15 21:03:24.000000000 +0200 @@ -33,6 +33,15 @@ Support module loading for newer (post 2.1) Linux kernels. endif +if CONFIG_FEATURE_NEW_MODULE_INTERFACE +config CONFIG_FEATURE_REALLY_NEW_MODULE_INTERFACE + bool " Support new (port 2.5) Linux kernels" + default y + depends on CONFIG_INSMOD + help + Support module loading for newer (port 2.5) Linux kernels. +endif + config CONFIG_FEATURE_INSMOD_VERSION_CHECKING bool " Module version checking" default n diff -urN busybox-1.00-pre3.org/modutils/insmod.c busybox-1.00-pre3/modutils/insmod.c --- busybox-1.00-pre3.org/modutils/insmod.c 2003-09-15 20:55:05.000000000 +0200 +++ busybox-1.00-pre3/modutils/insmod.c 2003-09-15 21:03:25.000000000 +0200 @@ -4141,6 +4141,14 @@ } #endif +#ifdef CONFIG_FEATURE_REALLY_NEW_MODULE_INTERFACE + if (create_module(NULL, 0) < 0 && errno == ENOSYS) { + optind--; + argv[optind] = m_filename; + return insmod_ng_main(argc - optind, argv + optind); + } +#endif + if ((f = obj_load(fp, LOADBITS)) == NULL) bb_perror_msg_and_die("Could not load the module"); diff -urN busybox-1.00-pre3.org/modutils/insmod_ng.c busybox-1.00-pre3/modutils/insmod_ng.c --- busybox-1.00-pre3.org/modutils/insmod_ng.c 1970-01-01 01:00:00.000000000 +0100 +++ busybox-1.00-pre3/modutils/insmod_ng.c 2003-09-15 21:03:25.000000000 +0200 @@ -0,0 +1,109 @@ +/* vi: set sw=4 ts=4: */ +/* + * insmod for 2.5 kernels implementation for busybox + * busybox version by Michal Moskal + * + * Copyright (C) 2001 Rusty Russell. + * Copyright (C) 2002 Rusty Russell, IBM Corporation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "busybox.h" + +/* We use error numbers in a loose translation... */ +static const char *moderror(int err) +{ + switch (err) { + case ENOEXEC: + return "Invalid module format"; + case ENOENT: + return "Unknown symbol in module"; + case ESRCH: + return "Module has wrong symbol version"; + case EINVAL: + return "Invalid parameters"; + default: + return strerror(err); + } +} + +extern int insmod_ng_main(int argc, char **argv) +{ + int i; + int fd; + long int ret; + struct stat st; + unsigned long len; + void *map; + char *filename, *options = bb_xstrdup(""); + + filename = argv[1]; + if (!filename) { + bb_show_usage(); + return -1; + } + + /* Rest is options */ + for (i = 2; i < argc; i++) { + options = xrealloc(options, + strlen(options) + 2 + strlen(argv[i]) + 2); + /* Spaces handled by "" pairs, but no way of escaping quotes */ + if (strchr(argv[i], ' ')) { + strcat(options, "\""); + strcat(options, argv[i]); + strcat(options, "\""); + } else { + strcat(options, argv[i]); + } + strcat(options, " "); + } + + if ((fd = open(filename, O_RDONLY, 0)) < 0) + bb_perror_msg_and_die("cannot open module `%s'", filename); + + fstat(fd, &st); + len = st.st_size; + map = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0); + if (map == MAP_FAILED) + bb_perror_msg_and_die("cannot mmap `%s'", filename); + + ret = init_module(map, len, options); + if (ret != 0) + bb_perror_msg_and_die("cannot insert `%s': %s (%li)", + filename, moderror(errno), ret); + + return 0; +} + +/* +Local Variables: +c-file-style: "linux" +c-basic-offset: 4 +tab-width: 4 +End: +*/ diff -urN busybox-1.00-pre3.org/modutils/Makefile.in busybox-1.00-pre3/modutils/Makefile.in --- busybox-1.00-pre3.org/modutils/Makefile.in 2003-09-15 20:55:05.000000000 +0200 +++ busybox-1.00-pre3/modutils/Makefile.in 2003-09-15 21:03:25.000000000 +0200 @@ -24,6 +24,7 @@ MODUTILS-y:= MODUTILS-$(CONFIG_INSMOD) += insmod.o +MODUTILS-$(CONFIG_FEATURE_REALLY_NEW_MODULE_INTERFACE) += insmod_ng.o MODUTILS-$(CONFIG_LSMOD) += lsmod.o MODUTILS-$(CONFIG_MODPROBE) += modprobe.o MODUTILS-$(CONFIG_RMMOD) += rmmod.o