]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
module: add /sys/module/<name>/uevent files
authorKay Sievers <kay.sievers@vrfy.org>
Sun, 24 Jul 2011 12:36:04 +0000 (22:06 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Sun, 24 Jul 2011 12:36:04 +0000 (22:06 +0930)
Userspace wants to manage module parameters with udev rules.
This currently only works for loaded modules, but not for
built-in ones.

To allow access to the built-in modules we need to
re-trigger all module load events that happened before any
userspace was running. We already do the same thing for all
devices, subsystems(buses) and drivers.

This adds the currently missing /sys/module/<name>/uevent files
to all module entries.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (split & trivial fix)
include/linux/module.h
kernel/module.c
kernel/params.c

index b87e7625a98c5999a71ec9aa0df28971f79f773b..1c30087a2d8134e60696a04665ad39c4b01bc7c5 100644 (file)
@@ -75,6 +75,7 @@ struct module_version_attribute {
 extern ssize_t __modver_version_show(struct module_attribute *,
                                     struct module_kobject *, char *);
 
+extern struct module_attribute module_uevent;
 
 /* These are either module local, or the kernel's dummy ones. */
 extern int init_module(void);
index a4295e67dd836f7eed37f99c88cd30b9ae3d2a0d..04379f92f843cea5d3cfd0b0631685c921a390f5 100644 (file)
@@ -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
index 37e9b20a718bfbbe53b35cf5d79fb919123a4f52..22df3e0d142a58aff04b134323d59266963a3fce 100644 (file)
@@ -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