aboutsummaryrefslogtreecommitdiff
path: root/modutils
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
parent6fe1960ff5e4c7c993a8bc3add5361ee55323afe (diff)
downloadbusybox-cf93274663877cb4d722a23d8c418470eb90332a.tar.gz
rmmod -a removed modules recursively
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;
static const int NEW_MOD_USED_ONCE = 16;
static const int NEW_MOD_INITIALIZING = 64;
-static int my_query_module(const char *name, int which, void **buf,
- size_t *bufsize, size_t *ret)
-{
- int my_ret;
-
- my_ret = query_module(name, which, *buf, *bufsize, ret);
-
- if (my_ret == -1 && errno == ENOSPC) {
- *buf = xrealloc(*buf, *ret);
- *bufsize = *ret;
-
- my_ret = query_module(name, which, *buf, *bufsize, ret);
- }
-
- return my_ret;
-}
-
extern int lsmod_main(int argc, char **argv)
{
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);
extern int rmmod_main(int argc, char **argv)
{
int n, ret = EXIT_SUCCESS;
+ size_t nmod = 0; /* number of modules */
+ size_t pnmod = -1; /* previous number of modules */
+ void *buf; /* hold the module names which we ignore but must get */
+ size_t bufsize = 0;
/* Parse command line. */
while ((n = getopt(argc, argv, "a")) != EOF) {
switch (n) {
case 'a':
/* Unload _all_ unused modules via NULL delete_module() call */
- if (delete_module(NULL))
- perror_msg_and_die("rmmod");
+ /* until the number of modules does not change */
+ buf = xmalloc(bufsize = 256);
+ while (nmod != pnmod) {
+ if (delete_module(NULL))
+ perror_msg_and_die("rmmod");
+ pnmod = nmod;
+ /* 1 == QM_MODULES */
+ if (my_query_module(NULL, 1, &buf, &bufsize, &nmod)) {
+ perror_msg_and_die("QM_MODULES");
+ }
+ }
+#ifdef CONFIG_FEATURE_CLEAN_UP
+ free(buf);
+#endif
return EXIT_SUCCESS;
default:
show_usage();