mirror of
https://github.com/sheumann/hush.git
synced 2024-10-29 20:27:40 +00:00
Deal with the fact that 2.6.x kernels replace any '-'s in the
module name with a '_'. -Erik
This commit is contained in:
parent
aea8e0eea7
commit
c0693ed61b
@ -26,9 +26,33 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include "busybox.h"
|
#include "busybox.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_FEATURE_2_6_MODULES
|
||||||
|
static inline void filename2modname(char *modname, const char *filename)
|
||||||
|
{
|
||||||
|
const char *afterslash;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
afterslash = strrchr(filename, '/');
|
||||||
|
if (!afterslash)
|
||||||
|
afterslash = filename;
|
||||||
|
else
|
||||||
|
afterslash++;
|
||||||
|
|
||||||
|
/* Convert to underscores, stop at first . */
|
||||||
|
for (i = 0; afterslash[i] && afterslash[i] != '.'; i++) {
|
||||||
|
if (afterslash[i] == '-')
|
||||||
|
modname[i] = '_';
|
||||||
|
else
|
||||||
|
modname[i] = afterslash[i];
|
||||||
|
}
|
||||||
|
modname[i] = '\0';
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
extern int rmmod_main(int argc, char **argv)
|
extern int rmmod_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int n, ret = EXIT_SUCCESS;
|
int n, ret = EXIT_SUCCESS;
|
||||||
@ -81,10 +105,18 @@ extern int rmmod_main(int argc, char **argv)
|
|||||||
if (optind == argc)
|
if (optind == argc)
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
|
|
||||||
for (n = optind; n < argc; n++) {
|
{
|
||||||
if (syscall(__NR_delete_module, argv[n], flags) < 0) {
|
#ifdef CONFIG_FEATURE_2_6_MODULES
|
||||||
bb_perror_msg("%s", argv[n]);
|
char module_name[strlen(argv[n]) + 1];
|
||||||
ret = EXIT_FAILURE;
|
filename2modname(module_name, argv[n]);
|
||||||
|
#else
|
||||||
|
#define module_name argv[n]
|
||||||
|
#endif
|
||||||
|
for (n = optind; n < argc; n++) {
|
||||||
|
if (syscall(__NR_delete_module, module_name, flags) < 0) {
|
||||||
|
bb_perror_msg("%s", argv[n]);
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user