aboutsummaryrefslogtreecommitdiff
path: root/modutils/rmmod.c
diff options
context:
space:
mode:
authorTim Riker <tim@rikers.org>2002-12-14 01:58:59 +0000
committerTim Riker <tim@rikers.org>2002-12-14 01:58:59 +0000
commitcf93274663877cb4d722a23d8c418470eb90332a (patch)
treea056983d1162502b58e2aca4c2ebf3c9c7b9c6be /modutils/rmmod.c
parent6fe1960ff5e4c7c993a8bc3add5361ee55323afe (diff)
downloadbusybox-w32-cf93274663877cb4d722a23d8c418470eb90332a.tar.gz
busybox-w32-cf93274663877cb4d722a23d8c418470eb90332a.tar.bz2
busybox-w32-cf93274663877cb4d722a23d8c418470eb90332a.zip
rmmod -a removed modules recursively
Diffstat (limited to 'modutils/rmmod.c')
-rw-r--r--modutils/rmmod.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/modutils/rmmod.c b/modutils/rmmod.c
index affe975fa..0103d9145 100644
--- a/modutils/rmmod.c
+++ b/modutils/rmmod.c
@@ -34,14 +34,30 @@ extern int delete_module(const char * name);
34extern int rmmod_main(int argc, char **argv) 34extern int rmmod_main(int argc, char **argv)
35{ 35{
36 int n, ret = EXIT_SUCCESS; 36 int n, ret = EXIT_SUCCESS;
37 size_t nmod = 0; /* number of modules */
38 size_t pnmod = -1; /* previous number of modules */
39 void *buf; /* hold the module names which we ignore but must get */
40 size_t bufsize = 0;
37 41
38 /* Parse command line. */ 42 /* Parse command line. */
39 while ((n = getopt(argc, argv, "a")) != EOF) { 43 while ((n = getopt(argc, argv, "a")) != EOF) {
40 switch (n) { 44 switch (n) {
41 case 'a': 45 case 'a':
42 /* Unload _all_ unused modules via NULL delete_module() call */ 46 /* Unload _all_ unused modules via NULL delete_module() call */
43 if (delete_module(NULL)) 47 /* until the number of modules does not change */
44 perror_msg_and_die("rmmod"); 48 buf = xmalloc(bufsize = 256);
49 while (nmod != pnmod) {
50 if (delete_module(NULL))
51 perror_msg_and_die("rmmod");
52 pnmod = nmod;
53 /* 1 == QM_MODULES */
54 if (my_query_module(NULL, 1, &buf, &bufsize, &nmod)) {
55 perror_msg_and_die("QM_MODULES");
56 }
57 }
58#ifdef CONFIG_FEATURE_CLEAN_UP
59 free(buf);
60#endif
45 return EXIT_SUCCESS; 61 return EXIT_SUCCESS;
46 default: 62 default:
47 show_usage(); 63 show_usage();