aboutsummaryrefslogtreecommitdiff
path: root/modutils/rmmod.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-12-11 01:42:13 +0000
committerEric Andersen <andersen@codepoet.org>2003-12-11 01:42:13 +0000
commite7047887b040da7035f11d0fe48d76bd67381c9c (patch)
tree4fc4c04847936656adf9d1d3aef35edd1ac5ffe7 /modutils/rmmod.c
parent37f4116ecb03fcf5de2bc8aab8d480b9b063bab5 (diff)
downloadbusybox-w32-e7047887b040da7035f11d0fe48d76bd67381c9c.tar.gz
busybox-w32-e7047887b040da7035f11d0fe48d76bd67381c9c.tar.bz2
busybox-w32-e7047887b040da7035f11d0fe48d76bd67381c9c.zip
Update modutils with 2.6 module support
Diffstat (limited to 'modutils/rmmod.c')
-rw-r--r--modutils/rmmod.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/modutils/rmmod.c b/modutils/rmmod.c
index a4ea70410..311b03dc4 100644
--- a/modutils/rmmod.c
+++ b/modutils/rmmod.c
@@ -25,6 +25,8 @@
25#include <unistd.h> 25#include <unistd.h>
26#include <stdlib.h> 26#include <stdlib.h>
27#include <getopt.h> 27#include <getopt.h>
28#include <fcntl.h>
29#include <sys/syscall.h>
28#include "busybox.h" 30#include "busybox.h"
29 31
30extern int delete_module(const char * name); 32extern int delete_module(const char * name);
@@ -37,10 +39,17 @@ extern int rmmod_main(int argc, char **argv)
37 size_t pnmod = -1; /* previous number of modules */ 39 size_t pnmod = -1; /* previous number of modules */
38 void *buf; /* hold the module names which we ignore but must get */ 40 void *buf; /* hold the module names which we ignore but must get */
39 size_t bufsize = 0; 41 size_t bufsize = 0;
42 unsigned int flags = O_NONBLOCK|O_EXCL;
40 43
41 /* Parse command line. */ 44 /* Parse command line. */
42 while ((n = getopt(argc, argv, "a")) != EOF) { 45 while ((n = getopt(argc, argv, "a")) != EOF) {
43 switch (n) { 46 switch (n) {
47 case 'w': // --wait
48 flags &= ~O_NONBLOCK;
49 break;
50 case 'f': // --force
51 flags |= O_TRUNC;
52 break;
44 case 'a': 53 case 'a':
45 /* Unload _all_ unused modules via NULL delete_module() call */ 54 /* Unload _all_ unused modules via NULL delete_module() call */
46 /* until the number of modules does not change */ 55 /* until the number of modules does not change */
@@ -67,7 +76,7 @@ extern int rmmod_main(int argc, char **argv)
67 bb_show_usage(); 76 bb_show_usage();
68 77
69 for (n = optind; n < argc; n++) { 78 for (n = optind; n < argc; n++) {
70 if (delete_module(argv[n]) < 0) { 79 if (syscall(__NR_delete_module, argv[n], flags) < 0) {
71 bb_perror_msg("%s", argv[n]); 80 bb_perror_msg("%s", argv[n]);
72 ret = EXIT_FAILURE; 81 ret = EXIT_FAILURE;
73 } 82 }