struct list_head *i = p; (*pos)++; if (i->next == &modules) return NULL; return i->next;} static void m_stop(struct seq_file *m, void *p){ mutex_unlock(&module_mutex);} static int m_show(struct seq_file *m, void *p){ struct module *mod = list_entry(p, struct module, list); seq_printf(m, "%s %lu", mod->name, mod->init_size + mod->core_size); print_unload_info(m, mod); /* Informative for users. */ seq_printf(m, " %s", mod->state == MODULE_STATE_GOING ? "Unloading": mod->state == MODULE_STATE_COMING ? "Loading": "Live"); /* Used by oprofile and other similar tools. */ seq_printf(m, " 0x%p", mod->module_core); seq_printf(m, "\n"); return 0;} /* Format: modulename size refcount deps address Where refcount is a number or -, and deps is a comma-separated list of depends or -.*/struct seq_operations modules_op = { .start = m_start, .next = m_next, .stop = m_stop, .show = m_show}; /* Given an address, look for it in the module exception tables. */const struct exception_table_entry *search_module_extables(unsigned long addr){ unsigned long flags; const struct exception_table_entry *e = NULL; struct module *mod; spin_lock_irqsave(&modlist_lock, flags); list_for_each_entry(mod, &modules, list) { if (mod->num_exentries == 0) continue; e = search_extable(mod->extable, mod->extable + mod->num_exentries - 1, addr); if (e) break; } spin_unlock_irqrestore(&modlist_lock, flags); /* Now, if we found one, we are running inside it now, hence we cannot unload the module, hence no refcnt needed. */ return e;} /* Is this a valid kernel address? We don't grab the lock: we are oopsing. */struct module *__module_text_address(unsigned long addr){ struct module *mod; list_for_each_entry(mod, &modules, list) if (within(addr, mod->module_init, mod->init_text_size) || within(addr, mod->module_core, mod->core_text_size)) return mod; return NULL;} struct module *module_text_address(unsigned long addr){ struct module *mod; unsigned long flags; spin_lock_irqsave(&modlist_lock, flags); mod = __module_text_address(addr); spin_unlock_irqrestore(&modlist_lock, flags); return mod;} /* Don't grab lock, we're oopsing. */void print_modules(void){ struct module *mod; printk("Modules linked in:"); list_for_each_entry(mod, &modules, list) printk(" %s", mod->name); printk("\n");} void module_add_driver(struct module *mod, struct device_driver *drv){ if (!mod || !drv) return; /* Don't check return code; this call is idempotent */ sysfs_create_link(&drv->kobj, &mod->mkobj.kobj, "module");}EXPORT_SYMBOL(module_add_driver); void module_remove_driver(struct device_driver *drv){ if (!drv) return; sysfs_remove_link(&drv->kobj, "module");}EXPORT_SYMBOL(module_remove_driver); #ifdef CONFIG_MODVERSIONS/* Generate the signature for struct module here, too, for modversions. */void struct_module(struct module *mod) { return; }EXPORT_SYMBOL(struct_module);#endifLines 2001–2126 of 2126. Previous lines
struct list_head *i = p; (*pos)++; if (i->next == &modules) return NULL; return i->next; } static void m_stop(struct seq_file *m, void *p) { mutex_unlock(&module_mutex); } static int m_show(struct seq_file *m, void *p) { struct module *mod = list_entry(p, struct module, list); seq_printf(m, "%s %lu", mod->name, mod->init_size + mod->core_size); print_unload_info(m, mod); /* Informative for users. */ seq_printf(m, " %s", mod->state == MODULE_STATE_GOING ? "Unloading": mod->state == MODULE_STATE_COMING ? "Loading": "Live"); /* Used by oprofile and other similar tools. */ seq_printf(m, " 0x%p", mod->module_core); seq_printf(m, "\n"); return 0; } /* Format: modulename size refcount deps address Where refcount is a number or -, and deps is a comma-separated list of depends or -. */ struct seq_operations modules_op = { .start = m_start, .next = m_next, .stop = m_stop, .show = m_show }; /* Given an address, look for it in the module exception tables. */ const struct exception_table_entry *search_module_extables(unsigned long addr) { unsigned long flags; const struct exception_table_entry *e = NULL; struct module *mod; spin_lock_irqsave(&modlist_lock, flags); list_for_each_entry(mod, &modules, list) { if (mod->num_exentries == 0) continue; e = search_extable(mod->extable, mod->extable + mod->num_exentries - 1, addr); if (e) break; } spin_unlock_irqrestore(&modlist_lock, flags); /* Now, if we found one, we are running inside it now, hence we cannot unload the module, hence no refcnt needed. */ return e; } /* Is this a valid kernel address? We don't grab the lock: we are oopsing. */ struct module *__module_text_address(unsigned long addr) { struct module *mod; list_for_each_entry(mod, &modules, list) if (within(addr, mod->module_init, mod->init_text_size) || within(addr, mod->module_core, mod->core_text_size)) return mod; return NULL; } struct module *module_text_address(unsigned long addr) { struct module *mod; unsigned long flags; spin_lock_irqsave(&modlist_lock, flags); mod = __module_text_address(addr); spin_unlock_irqrestore(&modlist_lock, flags); return mod; } /* Don't grab lock, we're oopsing. */ void print_modules(void) { struct module *mod; printk("Modules linked in:"); list_for_each_entry(mod, &modules, list) printk(" %s", mod->name); printk("\n"); } void module_add_driver(struct module *mod, struct device_driver *drv) { if (!mod || !drv) return; /* Don't check return code; this call is idempotent */ sysfs_create_link(&drv->kobj, &mod->mkobj.kobj, "module"); } EXPORT_SYMBOL(module_add_driver); void module_remove_driver(struct device_driver *drv) { if (!drv) return; sysfs_remove_link(&drv->kobj, "module"); } EXPORT_SYMBOL(module_remove_driver); #ifdef CONFIG_MODVERSIONS /* Generate the signature for struct module here, too, for modversions. */ void struct_module(struct module *mod) { return; } EXPORT_SYMBOL(struct_module); #endif