Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
* git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus: modpost: Fix modpost's license checking V3 module: add /sys/module/<name>/uevent files module: change attr callbacks to take struct module_kobject modules: make arch's use default loader hooks modules: add default loader hook implementations param: fix return value handling in param_set_*
This commit is contained in:
@@ -545,9 +545,9 @@ static void setup_modinfo_##field(struct module *mod, const char *s) \
|
||||
mod->field = kstrdup(s, GFP_KERNEL); \
|
||||
} \
|
||||
static ssize_t show_modinfo_##field(struct module_attribute *mattr, \
|
||||
struct module *mod, char *buffer) \
|
||||
struct module_kobject *mk, char *buffer) \
|
||||
{ \
|
||||
return sprintf(buffer, "%s\n", mod->field); \
|
||||
return sprintf(buffer, "%s\n", mk->mod->field); \
|
||||
} \
|
||||
static int modinfo_##field##_exists(struct module *mod) \
|
||||
{ \
|
||||
@@ -902,9 +902,9 @@ void symbol_put_addr(void *addr)
|
||||
EXPORT_SYMBOL_GPL(symbol_put_addr);
|
||||
|
||||
static ssize_t show_refcnt(struct module_attribute *mattr,
|
||||
struct module *mod, char *buffer)
|
||||
struct module_kobject *mk, char *buffer)
|
||||
{
|
||||
return sprintf(buffer, "%u\n", module_refcount(mod));
|
||||
return sprintf(buffer, "%u\n", module_refcount(mk->mod));
|
||||
}
|
||||
|
||||
static struct module_attribute refcnt = {
|
||||
@@ -952,11 +952,11 @@ static inline int module_unload_init(struct module *mod)
|
||||
#endif /* CONFIG_MODULE_UNLOAD */
|
||||
|
||||
static ssize_t show_initstate(struct module_attribute *mattr,
|
||||
struct module *mod, char *buffer)
|
||||
struct module_kobject *mk, char *buffer)
|
||||
{
|
||||
const char *state = "unknown";
|
||||
|
||||
switch (mod->state) {
|
||||
switch (mk->mod->state) {
|
||||
case MODULE_STATE_LIVE:
|
||||
state = "live";
|
||||
break;
|
||||
@@ -975,10 +975,27 @@ static struct module_attribute initstate = {
|
||||
.show = show_initstate,
|
||||
};
|
||||
|
||||
static ssize_t store_uevent(struct module_attribute *mattr,
|
||||
struct module_kobject *mk,
|
||||
const char *buffer, size_t count)
|
||||
{
|
||||
enum kobject_action action;
|
||||
|
||||
if (kobject_action_type(buffer, count, &action) == 0)
|
||||
kobject_uevent(&mk->kobj, action);
|
||||
return count;
|
||||
}
|
||||
|
||||
struct module_attribute module_uevent = {
|
||||
.attr = { .name = "uevent", .mode = 0200 },
|
||||
.store = store_uevent,
|
||||
};
|
||||
|
||||
static struct module_attribute *modinfo_attrs[] = {
|
||||
&modinfo_version,
|
||||
&modinfo_srcversion,
|
||||
&initstate,
|
||||
&module_uevent,
|
||||
#ifdef CONFIG_MODULE_UNLOAD
|
||||
&refcnt,
|
||||
#endif
|
||||
@@ -1187,7 +1204,7 @@ struct module_sect_attrs
|
||||
};
|
||||
|
||||
static ssize_t module_sect_show(struct module_attribute *mattr,
|
||||
struct module *mod, char *buf)
|
||||
struct module_kobject *mk, char *buf)
|
||||
{
|
||||
struct module_sect_attr *sattr =
|
||||
container_of(mattr, struct module_sect_attr, mattr);
|
||||
@@ -1697,6 +1714,15 @@ static void unset_module_core_ro_nx(struct module *mod) { }
|
||||
static void unset_module_init_ro_nx(struct module *mod) { }
|
||||
#endif
|
||||
|
||||
void __weak module_free(struct module *mod, void *module_region)
|
||||
{
|
||||
vfree(module_region);
|
||||
}
|
||||
|
||||
void __weak module_arch_cleanup(struct module *mod)
|
||||
{
|
||||
}
|
||||
|
||||
/* Free a module, remove from lists, etc. */
|
||||
static void free_module(struct module *mod)
|
||||
{
|
||||
@@ -1851,6 +1877,26 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int __weak apply_relocate(Elf_Shdr *sechdrs,
|
||||
const char *strtab,
|
||||
unsigned int symindex,
|
||||
unsigned int relsec,
|
||||
struct module *me)
|
||||
{
|
||||
pr_err("module %s: REL relocation unsupported\n", me->name);
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
int __weak apply_relocate_add(Elf_Shdr *sechdrs,
|
||||
const char *strtab,
|
||||
unsigned int symindex,
|
||||
unsigned int relsec,
|
||||
struct module *me)
|
||||
{
|
||||
pr_err("module %s: RELA relocation unsupported\n", me->name);
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
static int apply_relocations(struct module *mod, const struct load_info *info)
|
||||
{
|
||||
unsigned int i;
|
||||
@@ -2235,6 +2281,11 @@ static void dynamic_debug_remove(struct _ddebug *debug)
|
||||
ddebug_remove_module(debug->modname);
|
||||
}
|
||||
|
||||
void * __weak module_alloc(unsigned long size)
|
||||
{
|
||||
return size == 0 ? NULL : vmalloc_exec(size);
|
||||
}
|
||||
|
||||
static void *module_alloc_update_bounds(unsigned long size)
|
||||
{
|
||||
void *ret = module_alloc(size);
|
||||
@@ -2645,6 +2696,14 @@ static void flush_module_icache(const struct module *mod)
|
||||
set_fs(old_fs);
|
||||
}
|
||||
|
||||
int __weak module_frob_arch_sections(Elf_Ehdr *hdr,
|
||||
Elf_Shdr *sechdrs,
|
||||
char *secstrings,
|
||||
struct module *mod)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct module *layout_and_allocate(struct load_info *info)
|
||||
{
|
||||
/* Module within temporary copy. */
|
||||
@@ -2716,6 +2775,13 @@ static void module_deallocate(struct module *mod, struct load_info *info)
|
||||
module_free(mod, mod->module_core);
|
||||
}
|
||||
|
||||
int __weak module_finalize(const Elf_Ehdr *hdr,
|
||||
const Elf_Shdr *sechdrs,
|
||||
struct module *me)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int post_relocation(struct module *mod, const struct load_info *info)
|
||||
{
|
||||
/* Sort exception table now relocations are done. */
|
||||
|
@@ -225,8 +225,8 @@ int parse_args(const char *name,
|
||||
int ret; \
|
||||
\
|
||||
ret = strtolfn(val, 0, &l); \
|
||||
if (ret == -EINVAL || ((type)l != l)) \
|
||||
return -EINVAL; \
|
||||
if (ret < 0 || ((type)l != l)) \
|
||||
return ret < 0 ? ret : -EINVAL; \
|
||||
*((type *)kp->arg) = l; \
|
||||
return 0; \
|
||||
} \
|
||||
@@ -511,7 +511,7 @@ struct module_param_attrs
|
||||
#define to_param_attr(n) container_of(n, struct param_attribute, mattr)
|
||||
|
||||
static ssize_t param_attr_show(struct module_attribute *mattr,
|
||||
struct module *mod, char *buf)
|
||||
struct module_kobject *mk, char *buf)
|
||||
{
|
||||
int count;
|
||||
struct param_attribute *attribute = to_param_attr(mattr);
|
||||
@@ -531,7 +531,7 @@ static ssize_t param_attr_show(struct module_attribute *mattr,
|
||||
|
||||
/* sysfs always hands a nul-terminated string in buf. We rely on that. */
|
||||
static ssize_t param_attr_store(struct module_attribute *mattr,
|
||||
struct module *owner,
|
||||
struct module_kobject *km,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
int err;
|
||||
@@ -730,6 +730,10 @@ static struct module_kobject * __init locate_module_kobject(const char *name)
|
||||
mk->kobj.kset = module_kset;
|
||||
err = kobject_init_and_add(&mk->kobj, &module_ktype, NULL,
|
||||
"%s", name);
|
||||
#ifdef CONFIG_MODULES
|
||||
if (!err)
|
||||
err = sysfs_create_file(&mk->kobj, &module_uevent.attr);
|
||||
#endif
|
||||
if (err) {
|
||||
kobject_put(&mk->kobj);
|
||||
printk(KERN_ERR
|
||||
@@ -807,7 +811,7 @@ static void __init param_sysfs_builtin(void)
|
||||
}
|
||||
|
||||
ssize_t __modver_version_show(struct module_attribute *mattr,
|
||||
struct module *mod, char *buf)
|
||||
struct module_kobject *mk, char *buf)
|
||||
{
|
||||
struct module_version_attribute *vattr =
|
||||
container_of(mattr, struct module_version_attribute, mattr);
|
||||
@@ -852,7 +856,7 @@ static ssize_t module_attr_show(struct kobject *kobj,
|
||||
if (!attribute->show)
|
||||
return -EIO;
|
||||
|
||||
ret = attribute->show(attribute, mk->mod, buf);
|
||||
ret = attribute->show(attribute, mk, buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -871,7 +875,7 @@ static ssize_t module_attr_store(struct kobject *kobj,
|
||||
if (!attribute->store)
|
||||
return -EIO;
|
||||
|
||||
ret = attribute->store(attribute, mk->mod, buf, len);
|
||||
ret = attribute->store(attribute, mk, buf, len);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user