aboutsummaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-07-20 10:05:13 +0000
committerEric Andersen <andersen@codepoet.org>2004-07-20 10:05:13 +0000
commitc0693ed61bce201b4307252c48c6b96fa09319f9 (patch)
tree855f1c2c6398cb861837c3ff7e701514fd994aa8 /modutils
parentaea8e0eea7bbdf3eeefcd977dcce0ece79f40f21 (diff)
downloadbusybox-w32-c0693ed61bce201b4307252c48c6b96fa09319f9.tar.gz
busybox-w32-c0693ed61bce201b4307252c48c6b96fa09319f9.tar.bz2
busybox-w32-c0693ed61bce201b4307252c48c6b96fa09319f9.zip
Deal with the fact that 2.6.x kernels replace any '-'s in the
module name with a '_'. -Erik
Diffstat (limited to 'modutils')
-rw-r--r--modutils/rmmod.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/modutils/rmmod.c b/modutils/rmmod.c
index 5576eb6a1..3693aec7c 100644
--- a/modutils/rmmod.c
+++ b/modutils/rmmod.c
@@ -26,9 +26,33 @@
26#include <stdlib.h> 26#include <stdlib.h>
27#include <getopt.h> 27#include <getopt.h>
28#include <fcntl.h> 28#include <fcntl.h>
29#include <string.h>
29#include <sys/syscall.h> 30#include <sys/syscall.h>
30#include "busybox.h" 31#include "busybox.h"
31 32
33#ifdef CONFIG_FEATURE_2_6_MODULES
34static inline void filename2modname(char *modname, const char *filename)
35{
36 const char *afterslash;
37 unsigned int i;
38
39 afterslash = strrchr(filename, '/');
40 if (!afterslash)
41 afterslash = filename;
42 else
43 afterslash++;
44
45 /* Convert to underscores, stop at first . */
46 for (i = 0; afterslash[i] && afterslash[i] != '.'; i++) {
47 if (afterslash[i] == '-')
48 modname[i] = '_';
49 else
50 modname[i] = afterslash[i];
51 }
52 modname[i] = '\0';
53}
54#endif
55
32extern int rmmod_main(int argc, char **argv) 56extern int rmmod_main(int argc, char **argv)
33{ 57{
34 int n, ret = EXIT_SUCCESS; 58 int n, ret = EXIT_SUCCESS;
@@ -81,10 +105,18 @@ extern int rmmod_main(int argc, char **argv)
81 if (optind == argc) 105 if (optind == argc)
82 bb_show_usage(); 106 bb_show_usage();
83 107
84 for (n = optind; n < argc; n++) { 108 {
85 if (syscall(__NR_delete_module, argv[n], flags) < 0) { 109#ifdef CONFIG_FEATURE_2_6_MODULES
86 bb_perror_msg("%s", argv[n]); 110 char module_name[strlen(argv[n]) + 1];
87 ret = EXIT_FAILURE; 111 filename2modname(module_name, argv[n]);
112#else
113#define module_name argv[n]
114#endif
115 for (n = optind; n < argc; n++) {
116 if (syscall(__NR_delete_module, module_name, flags) < 0) {
117 bb_perror_msg("%s", argv[n]);
118 ret = EXIT_FAILURE;
119 }
88 } 120 }
89 } 121 }
90 122