[PATCH] Modules: Allow sysfs module parameters to be written to.

From: Greg KH
Date: Tue Jan 25 2005 - 15:30:38 EST


Linus, please apply this to your tree, it fixes the module parameter
stuff in sysfs so that it actually works. Was verified by Marcel.

-----------

Fixes a bug in the current tree preventing the sysfs module parameters from being able
to be changed at all from userspace. It's as if someone just forgot to write this function...

Signed-off-by: Greg Kroah-Hartman <greg@xxxxxxxxx>

diff -Nru a/kernel/params.c b/kernel/params.c
--- a/kernel/params.c 2005-01-24 21:07:40 -08:00
+++ b/kernel/params.c 2005-01-24 21:07:40 -08:00
@@ -640,9 +640,33 @@
return ret;
}

+static ssize_t module_attr_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buf, size_t len)
+{
+ struct module_attribute *attribute;
+ struct module_kobject *mk;
+ int ret;
+
+ attribute = to_module_attr(attr);
+ mk = to_module_kobject(kobj);
+
+ if (!attribute->store)
+ return -EPERM;
+
+ if (!try_module_get(mk->mod))
+ return -ENODEV;
+
+ ret = attribute->store(attribute, mk->mod, buf, len);
+
+ module_put(mk->mod);
+
+ return ret;
+}
+
static struct sysfs_ops module_sysfs_ops = {
.show = module_attr_show,
- .store = NULL,
+ .store = module_attr_store,
};

#else
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/