aboutsummaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
authortimr <timr@69ca8d6d-28ef-0310-b511-8ec308f3f277>2002-12-14 01:58:59 +0000
committertimr <timr@69ca8d6d-28ef-0310-b511-8ec308f3f277>2002-12-14 01:58:59 +0000
commit9717b74d98e5422c72d22fe6b4e49ba83309bea1 (patch)
treea056983d1162502b58e2aca4c2ebf3c9c7b9c6be /modutils
parent4fd25dc69c14e33ae10f6ca2715295a2617dade7 (diff)
downloadbusybox-w32-9717b74d98e5422c72d22fe6b4e49ba83309bea1.tar.gz
busybox-w32-9717b74d98e5422c72d22fe6b4e49ba83309bea1.tar.bz2
busybox-w32-9717b74d98e5422c72d22fe6b4e49ba83309bea1.zip
rmmod -a removed modules recursively
git-svn-id: svn://busybox.net/trunk/busybox@6214 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'modutils')
-rw-r--r--modutils/lsmod.c17
-rw-r--r--modutils/rmmod.c20
2 files changed, 18 insertions, 19 deletions
diff --git a/modutils/lsmod.c b/modutils/lsmod.c
index d51da2d16..0d5ac756b 100644
--- a/modutils/lsmod.c
+++ b/modutils/lsmod.c
@@ -98,23 +98,6 @@ static const int NEW_MOD_VISITED = 8;
98static const int NEW_MOD_USED_ONCE = 16; 98static const int NEW_MOD_USED_ONCE = 16;
99static const int NEW_MOD_INITIALIZING = 64; 99static const int NEW_MOD_INITIALIZING = 64;
100 100
101static int my_query_module(const char *name, int which, void **buf,
102 size_t *bufsize, size_t *ret)
103{
104 int my_ret;
105
106 my_ret = query_module(name, which, *buf, *bufsize, ret);
107
108 if (my_ret == -1 && errno == ENOSPC) {
109 *buf = xrealloc(*buf, *ret);
110 *bufsize = *ret;
111
112 my_ret = query_module(name, which, *buf, *bufsize, ret);
113 }
114
115 return my_ret;
116}
117
118extern int lsmod_main(int argc, char **argv) 101extern int lsmod_main(int argc, char **argv)
119{ 102{
120 struct module_info info; 103 struct module_info info;
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();