As previously mentioned by a few people.. yeah, your module is buggy
inside cleanup_module() (or whatever you called your cleanup function) and
is thus causing these problems.  If you REALLY want to know how to remove
a module in that screwed up 'deleted' state you can take a look at the
code I wrote to do just that a long time ago (I actually used it to clean
up this vmware module that was crashed and it worked reasonably well)..
here is the code:  (But I warn you.. your mileage may vary!  Really the
best thing to do, as pointed out by others.. is reboot and fix the
cleanup_module() code in your module)...

Here goes (again, this is for academic interest only! don't flame me with
"yeah this is unholy, yeah you are evil, yeah osama bin laden is your
uncle"):

/*
kill_some_module.c

   DESCRIPTION:

   Cheap hack to kill screwey modules.  Probably won't work
   since chances are if your cleanup_module() segfaulted once
   it will probably segfault again! The REAL way to do this
   is to tinker even further with kernel module structures
   to undo all the damage the module may have done (at
   least in the module structures) and then kfree it...
   but I was lazy and thus only came up with this...

   AUTHOR:

   Calin Culianu <[EMAIL PROTECTED]>

   INFO:

   compile with:

   gcc -I/usr/src/yourkernel/include -c kill_some_module.c

   install with:

   insmod kill_some_module.o module_to_kill=your_module_name
*/
#define MODULE
#define __KERNEL__
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/errno.h>
#include <linux/kmod.h>
#include <linux/string.h>

char module_to_kill[256] = "tt_mod";

MODULE_PARM(module_to_kill, "255s");
MODULE_PARM_DESC(module_to_kill, "The module name for which you want to
cleanup the status.");


int init_module(void);
void cleanup_module(void);
static struct module * find_module (const char * name);


int init_module(void) {
        struct module *mod = find_module(module_to_kill);
        if (mod > 0) {
                int curr_use_count;

                while ( (curr_use_count = GET_USE_COUNT(mod) )) {
                  if (curr_use_count > 0) {
                        __MOD_DEC_USE_COUNT(mod);
                  } else {
                        __MOD_INC_USE_COUNT(mod);
                  }
                }
                mod->flags = MOD_RUNNING | MOD_USED_ONCE;
                //mod->cleanup(); // GULP!
                printk("Fixed statuses on %s.. any effect??\n"
                       "Try unloading the module now..\n",
module_to_kill);
        } else {
                printk("Could not find module %s, exiting quietly.\n",
                        module_to_kill);
        }
        printk("(Please ignore error message reported by insmod)\n");
        return -ENOMSG;
}

void cleanup_module(void) { }

static struct module * find_module (const char * name) {
        struct module *curr = &__this_module;
        while (curr) {
                if (!strcmp(curr->name,name)) {
                        return curr; /* we found it! */
                }
                curr = curr->next;
        }
        return 0;
}



On Tue, 13 Nov 2001, Tim Beamish wrote:

> I inserted a self made module called 'tt_mod' into rtlinux and when I
> tried to remove it, I got a segmentation fault. I did an lsmod and got
> this:
>
> Module                  Size  Used by
> rtl_fifo                9792   0  (unused)
> tt_mod                     0   0  (deleted)
> rtl_sched              27856   0  [tt_mod]
> rtl_posixio             7216   0  [rtl_fifo tt_mod]
> rtl_time                4736   0  [tt_mod rtl_sched rtl_posixio]
> rtl                    18080   0  [rtl_fifo tt_mod rtl_sched rtl_posixio rtl_time]
> mbuff                   6368   2  [tt_mod]
> es1371                 28176   0  (autoclean)
> ac97_codec              8768   0  (autoclean) [es1371]
> soundcore               4048   4  (autoclean) [es1371]
> usb-uhci               22416   0  (unused)
> usbcore                29616   0  [usb-uhci]
>
> It looks like the module is still loaded so I tried to remove it with
> rmmod and got this:
> rmmod: module tt_mod is not loaded
>
> So I tried to insert it again and I got this message:
> insmod: a module named tt_mod already exists
>
> And so I tried to remove it and I got this:
> rmmod: module tt_mod is not loaded
>
> And on and on...
>
> So I tried to stop rtlinux and got this:
> rmmod: mbuff is in use
> rmmod: rtl is in use
> rmmod: rtl_posixio is in use
> rmmod: rtl_sched is in use
> rmmod: rtl_time is in use
>
> Scheme: (-) not loaded, (+) loaded
>   (+) mbuff
>   (+) rtl
>   (-) rtl_fifo
>   (+) rtl_posixio
>   (+) rtl_sched
>   (+) rtl_time
>
> I can't insert tt_mod because it's already there and I can't remove it
> because it isn't there. Now I can't even stop rtlinux as everything
> seems to be in use. Is there a way to clean out the loaded modules in
> rtlinux and force it to quit?
>
> Tim
>
>
> -- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> --
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/
>


-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/

Reply via email to